Gradle is giving me fits. I have a build.gravle that includes the java plug-in and I have built a task within it that generates a properties file and drops it into the build/classes directory. This all works like a champ. Here is my custom task.
task generateBuildSignature << {
def whoami = System.getProperty( 'user.name' );
def hostname = InetAddress.getLocalHost().getHostName();
def buildTag = System.env.BUILD_TAG ?: "dev"
ant.propertyfile( file: "${buildDir}/buildsignature.properties", comment: "This file is automatically generated - DO NOT EDIT!" ) {
entry( key: "version", value: "${project.version}" )
entry( key: "buildTimestamp", value: "${new Date().format('yyyy-MM-dd HH:mm:ss z')}" )
entry( key: "buildUser", value: "$whoami" )
entry( key: "buildSystem", value: "$hostname" )
entry( key: "buildTag", value: "$buildTag" )
}
}
Now I want to get the execution of this task integrated into the Java build lifecycle, preferably immediately after processResources or as a dependency of classes, but I’m at Chapter 23 of the documentation http://gradle.org/docs/current/userguide/java_plugin.html and it is not yet clear exactly how get my task into the dependency chain of the task(s) that come in through the java plug-in. Any advice for a fledgling gradle user?
All you have to (and can) do is to add a task dependency. For example: