Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19854

Best practices on configure resources

$
0
0

So the problem here is that you have the generated sources being added to the jar from two different places - once from the outputs of the processResources task and once from the output of taskB. This is why you get the warning about duplicates. You want the generated sources added to the jar from one place and one place only. The best way to do this I think is to declare the generatedResourcesDir as an output of taskB and then couple the sourceSet declaration directly to taskB. That will cause all appropriate task dependencies to be auto-wired and you can remove the explicit wiring on the jar task. This also has the semantic advantage of creating a direct relationship between the sourceSet and the task that generates its resources (rather than something indirect via generatedSourcesDir).

task taskB {
    outputs.dir generatedResourcesDir
    doLast {
        copy { stuff into generatedResourcesDir }
    }
}

sourceSets.main {
    resources {
        srcDirs taskB
    }
}

Viewing all articles
Browse latest Browse all 19854

Trending Articles