Reputation: 596
I have simple task that should copy my resources before the classes task.
task copyJsMocks(type:Copy) {
println "Is java script mocks needed: " + project.hasProperty('mockServices');
def mockSrc = projectDir.toPath().toString() + "/src/test/resources/site/services";
def mockDst = buildDir.toPath().toString() + "/resources/main/site/services";
if (project.hasProperty('mockServices')) {
from mockSrc;
into mockDst;
}
classes {
dependsOn copyJsMocks;
}
...But according to the logs this task is executed at the beginning.
.....
Is java script mocks needed: true
:phantomJsStop
:clean
:cleanEnonicDeploy
:compileJava
:compileGroovy UP-TO-DATE
:processResources
:classes
How I can fix it?
Upvotes: 0
Views: 754
Reputation: 15235
Read the Gradle user guide PDF that comes with the distribution.
You'll learn that tasks are executed in two phases, the "configuration" phase and the "execution" phase. That println statement executed in the configuration phase, and you don't control the ordering of when tasks are executed in the configuration phase.
Upvotes: 1