This message was deleted.
# community-support
s
This message was deleted.
v
The source path in the output is configurable using the
sourceFolder
config option which is by default set to
src/main/kotlin
for the
kotlin
generator. My guess is that if you have to add
src/commonMain/kotlin
, that this is actually configured that way, except if the documented default value is wrong. I also don't like the generated sources to be an own Gradle build, but incorporate it in the existing build, so I also suppress almost all other generated files like the Gradle project files and configure the
sourceFolder
to be empty and thus directly the output directory. This is how I do it, though it is using the Java generator, as I don't like the result of the Kotlin generator for its overuse of static state / companion object state, which is has pretty negative side-effects in my case:
Copy code
val openApiGeneratorIgnoreFile = layout.projectDirectory.file(".openapi-generator-ignore")

openApiGenerate {
    generatorName.set("java")
    outputDir.set(layout.buildDirectory.dir("generated/sources/openapi/main/java").map {
        it.asFile.absolutePath
    })
    inputSpec.set(downloadNexusOpenApiSpec.map {
        it.outputs.files.singleFile.absolutePath
    })
    generateApiDocumentation.set(false)
    generateApiTests.set(false)
    generateModelDocumentation.set(false)
    generateModelTests.set(false)
    invokerPackage.set("org.sonatype.nexus.client")
    apiPackage.set("org.sonatype.nexus.client.api")
    modelPackage.set("org.sonatype.nexus.client.model")
    configOptions.set(mapOf(
        "sourceFolder" to "",
        "dateLibrary" to "java8"
    ))
    ignoreFileOverride.set(
        openApiGeneratorIgnoreFile.asFile.absolutePath
    )
}

// work-around for <https://github.com/OpenAPITools/openapi-generator/issues/10214>
tasks.openApiGenerate {
    inputs
        .files(openApiGeneratorIgnoreFile)
        .withPathSensitivity(NONE)
        .withPropertyName("openApiGeneratorIgnoreFile")
}

pluginManager.withPlugin("idea") {
    configure<IdeaModel> {
        module {
            generatedSourceDirs.addAll(tasks.openApiGenerate.get().outputs.files)
        }
    }
}

sourceSets {
    main {
        java {
            srcDir(tasks.openApiGenerate)
        }
    }
}
c
oh does it really create a whole gradle build? i never noticed that.
in my config it does not create a gralde project, just the src dir:
Copy code
% ls build/openapi/generated
src
v
Maybe you have an
.openapi-generator-ignore
file already? Or maybe you use a version where the result is different. 🤷‍♂️ But the remaining points stay valid.
c
yeah, thanks a lot. I set sourceFolder and now it works perfectly