Reputation: 8918
When you have a block like this:
sourceSets {
main {
java {
srcDir 'spec/src'
srcDir 'shared/src'
srcDir 'server/src'
}
resources {
srcDir 'spec/src'
srcDir 'shared/src'
srcDir 'server/src'
}
compiledBy 'wsGen'
}
}
What does compiledBy
accomplish? Is it just for caching/performance? Does it cause the task to be run as part of the compileJava
tasks? The API docs say that it
Registers a set of tasks which are responsible for compiling this source set into the classes directory. The paths are evaluated as per
Task.dependsOn(java.lang.Object[])
.
That's great, but I have a Gradle project that seems to be running the wsGen
task when it's not in the dependsOn
list for anything. Is compiledBy
where this is coming from?
I'm less trying to solve a problem with this question than I am just trying to understand the mechanics of this function.
Upvotes: 1
Views: 462
Reputation: 38714
Yes this is where it comes from, but no, this is not directly related to the compileJava
task. Effectively the compiledBy
option sets the builtBy
option of the ConfigurableFileCollection
that represents the output of the source set. The classes
task that is added by the JavaBasePlugin
depends on the compileJava
task, the processResources
task and said ConfigurableFileCollection
which in turn causes the task to be executed as it is an implicit transitive dependency of the classes
task.
Upvotes: 1