Hi,
inspired by some other posts on this list I decided to have a look at
Gradle again (after I chose Gant over Gradle 0.1 a while ago) and
tried to migrate a Gant script to Gradle (which worked, just probably
not very elagantly) and also to add some Gradle Goodness. Here I'm
having problems.
So I'm trying to do automated version numbering and again, I guess,
there are much better ways but I'm trying to understand why the code
below is not working when I call 'gradle minor jar'.
I guess 'if (dag.hasTask(':major') || dag.hasTask(':minor'))' won't
work because 'jar' and 'minor' have different DAGs
But why aren't the doFirst() parts executed?
The printlns are only for testing purposes BTW.
I could easily work around this by setting some variable minor = true
in task minor and do all the work in patch but it just doesn't seem..
well nice..
Also, a valid argument would be that just using 'gradle minor jar' (as
far as doing minor before jar is concerned) would do the trick, but I
want 'gradle jar minor' to also work. I believe the order of tasks in
that special case should be irrelevant for the result. Maybe I'm just
being too picky here..
So I guess, in the end my questions really are:
Why doesn't the doFirst() work here?
What is the best way to create a DAG with alternative or optional paths?
Any ideas?
Martin
-----
createTask('major') {
patch.doFirst() {
versionMajor++
}
}
createTask('minor') {
task('patch').doFirst() {
versionMinor++
println 'V1'
}
patch.doFirst() {
versionMinor++
println 'V2'
}
println 'V3'
}
createTask('patch', dependsOn: 'compile') {task, dag ->
if (dag.hasTask(':major') || dag.hasTask(':minor')) {
versionPatch = 0
}
else {
versionPatch++
}
println "${versionMajor}.${versionMinor}.${versionPatch}"
ant.propertyfile(file: versionProps, comment: 'Version Information') {
entry(key: 'version.major', value: versionMajor)
entry(key: 'version.minor', value: versionMinor)
entry(key: 'version.patch', value: versionPatch)
entry(key: 'version', value:
"${versionMajor}.${versionMinor}.${versionPatch}")
entry(key: 'version.date', type: 'date', value: 'now', pattern:
'yyyy-MM-dd HH:mm:ss')
}
}
createTask('jar', dependsOn: 'patch') {
ant.jar(destfile: jarPath, compress: true, index: true ) {
fileset(dir: binDir, includes: "**/*.class")
fileset(dir: resDir, includes: "**/*")
zipgroupfileset(dir: libJarDir, includes: '*.jar' )
// add more jars here
manifest {
attribute(name: 'Main-Class', value:
"${projectPackage}.${projectMainClass}")
// attribute(name: 'Class-Path', value:
"../${libExtraDir}/sqljdbc.jar ../${libExtraDir}/core.jar ")
}
}
}
-----
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email