Am 02.05.11 01:58, schrieb Marco Hunsicker:
Calling execute() on a task is something we don't really recommend.

What's the reasoning here?


I think instead you should use task dependencies. Then you can simply use the standard lifecycle tasks such as 'gradle assemble', and your source is compiled twice, as needed.

Here's an example:

In your root build script (not in the body of a task):

allprojects {
     task recompileJava(type: Compile) {
         dependsOn compileJava
         source = compileJava.source
         classpath = compileJava.classpath
         ....
     }
     classes dependsOn recompileJava
}

This seems to be what I want:

allprojects {
  task recompileJava(type: Compile) {
    dependsOn rootProject.jalopy
    source = compileJava.source
    classpath = compileJava.classpath
    convention = compileJava.convention
    destinationDir = compileJava.destinationDir
    ...
  }

  processResources.dependsOn recompileJava
}

But it does not work!

The build sequence looks fine, and my task clearly changes all source files, but Gradle still does not apply compiling, as it thinks everything is up-to-date.

The log shows:

[LIFECYCLE] :project2:recompileJava
[DEBUG] Starting to execute task ':project2:recompileJava'
[DEBUG] Determining if task ':project2:recompileJava' is up-to-date
[DEBUG] Can cache files for configuration ':project2:compile'
[DEBUG] Can cache files for directory '/home/User/Documents/gradle/project2/src/main/java' [DEBUG] Can cache files for file '/home/User/Documents/gradle/project2/target/classes/main' [DEBUG] Can cache files for file '/home/User/Documents/gradle/project2/target/dependency-cache'
[INFO] Skipping task ':project2:recompileJava' as it is up-to-date.
[INFO] Skipping task ':project2:recompileJava' as it is up-to-date
[DEBUG] Finished executing task ':project2:recompileJava'
[LIFECYCLE] :project2:recompileJava UP-TO-DATE

Is is possible to disable the up-to-date checking? For my use case, it just adds additional overhead anyway as the recompile task will only be allowed to run if there was indeed anything formatted. Thanks.
to disable the up-to-date check for your task you can add
---------------
recompileJava .outputs.upToDateWhen { false }
---------------

regards,
René

Cheers,

Marco



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



--
-----------------------
regards René

rene groeschke
http://www.breskeby.com
@breskeby


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to