icerockdev / moko-network

Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev
Apache License 2.0
151 stars 29 forks source link

Allow controlling where code is generated #215

Open dalewking opened 4 months ago

dalewking commented 4 months ago

The plugin is hardcoded to generate code to build/generated directory, but that is not what i want. I want it to go to a different directory and we actually commit the generated code in to git so we can see what has changed.

It is actually possible to change where it is generated by using something like:

        configureTask {
            outputDir.set("$projectDir/desiredDirectory")
        }

But the one thing that doesn't cover is the setting up of srcDir to the sourceSet. I can do that set up myself and end up with a srcDir pointing at non-existent directory, but it seems it would be easy enough to add a property to the spec block that is the output directory that just defaults to its current location but can be changed.

In addition, it is not possible to disable the automatic configuration of srcDir. It is required to have a string for sourceSet and if that sourceSet does not exist the build fails. So perhaps make the sourceSet property nullable and if null skip the srcDir configuration.