All of `build/generated` is added to main sourceSet.
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 217
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
The plugin in it's default configuration adds the directory build/generated to the main sourceSet.
However, this is problematic, since this directory is already used as the output directory for other methods of code generation, like annotation processors.
I ran into this problem in a project where an annotation processor is used for the test sourceSet for which the generated code is placed in build/generated/sources/annotationProcessor.java/test.
Since these generated classes have dependencies which are only available in the test classpath, adding build/generated to the main sourceSet breaks the build process.
I'm able to work around this by changing the output directory for this plugin and manipulating the main sourceSet like so:
tasks.withType(com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask) {
generatedSourcesDir = "${project.buildDir.absolutePath}/dgs-codegen"
}
sourceSets {
main {
java {
def dirs = srcDirs
dirs.remove(file("${project.buildDir.absolutePath}/generated"))
srcDirs = dirs
srcDir "${project.buildDir.absolutePath}/dgs-codegen/generated"
}
}
}
But I believe that it would be better if this plugin would put its generated sources in some sub directory of build/generated instead, where they don't interfere with other generated sources.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the plugin's default source-set configuration and the GenerateJavaTask mentioned in the issue. Check how generatedSourcesDir and build/generated are used, then verify that the plugin's generated sources no longer include unrelated annotation-processor output and that the reported test-source-set build can complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100