Add generated source dir in KMP

Viewed 83

I'm using the OpenApiGenerator task to create data classes for my DTO. Task definition looks like this:

openApiGenerate(
    configure = {
        generatorName.set("kotlin")
        library.set("multiplatform")
        inputSpec.set("$projectDir/src/commonMain/resources/openapi/example-v1.0.yaml")
        outputDir.set("${project.buildDir}/generated/source/openapi/model")
        templateDir.set("$projectDir/src/commonMain/resources/openapi/templates/")
        modelPackage.set("com.example.model")
        globalProperties.set(
            mutableMapOf(
                "models" to "",
                "modelDocs" to "false"
            )
        )
    }
)

Also I have to add a

kotlin.srcDir("build/generated/openapi/model")

under sourceSet.commonMain to make generated files accessible from the code.

This generates me the following structure:

structure

So how can I organize structure like in section 1st (screenshot)? Cause I'm currently getting 2nd section (and want to avoid 3rd section).

0 Answers
Related