Previously I was using Gradle 1.0-milestone-3.
Upgraded for another unrelated reason to the current, Gradle 1.0 (as of 19th Jul 2012).
Now the build is broken, as the tasks I used to be able to insert into the correct position of the build, no longer get run.
That is, the ‘dependsOn’ doesn’t work as it used to.
What I used to achieve, is insert a task that was always run directly after the ‘classes’ task of the java build. This was done, by suggestion from someone on a gradle forum (in earlier days), like this:
task obfuscate(dependsOn: classes) << {
// the body of the task
}
The problem is demonstrated by the following script. I have also inserted here below the output from the build script, as run by both versions. Note the difference in the latest version (the obfuscate task is never run).
How can I get back my obfuscate task? Was it wrong to do it like this previously? Is it a bug?
thanks in advance for any ideas/help.
sean
apply plugin: 'java'
def buildTime = new java.util.Date()
dependencies {
}
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'test'
}
resources {
srcDir 'test'
}
}
}
task obfuscate(dependsOn: classes) << {
println "in obfuscate"
}
task jar(dependsOn: obfuscate, type: Jar, overwrite: true){ // we provide our own main jar task
manifest.from("src/META-INF/MANIFEST.MF")
// because our main jar should be obfuscated
manifest.attributes 'Build-Time': buildTime.toString()
from project.sourceSets.main.resources
from "$buildDir/obfuscated-classes-extra"
}
task unobfuscatedJar(dependsOn: classes, type: Jar) { // we also provide an extra jar task, to provide our unobfuscated jar
baseName = "${project.name}-unobfuscated"
manifest.from("src/META-INF/MANIFEST.MF")
manifest.attributes 'Build-Time': buildTime.toString()
from "$buildDir/classes/main"
}
the output
------------------------------------------------------------
Gradle 1.0-milestone-3
------------------------------------------------------------
Gradle build time: Monday, 25 April 2011 5:40:11 PM EST
Groovy: 1.7.10
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_24 (Sun Microsystems Inc. 19.1-b02)
OS: Linux 3.2.0-26-generic-pae i386
sean@svUbuntu10:~/dev/test$ gradle build
:compileJava UP-TO-DATE
:processResources
:classes
:obfuscate
in obfuscate
:jar
:unobfuscatedJar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test
:check
:build
BUILD SUCCESSFUL
Total time: 4.526 secs
=============================================
sean@svUbuntu10:~/dev/test$ /mnt/data/bin/gradle-1.0/bin/gradle build
:compileJava
:processResources
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test
:check
:build
BUILD SUCCESSFUL
Total time: 6.618 secs