GAV Identifier With Gradle

In moving all my home projects from Jenkins+Maven to GoCD+Artifactory+Gradle, there’s a number of intersting bumps to tackle. Here’s an early one:

    task createIdentifierArtifact << {
        new File("$buildDir/artifact-list.txt").withWriter { out ->
            out.println "${}:${}:${project.version}"
    jar.dependsOn createIdentifierArtifact

This artifact-list.txt file is marked as an artifact in GoCD. Downstream stages pick this up if they need to fetch the binaries from Artifactory (and possibly update the build.gradle dependencies section.

As all builds run inside a Docker container, this file needs to be produced outside (or fetched so the GoCD agent can pick it up). I keep a file at the top-level directory of all projects, and it will simply invoke ./gradlew createIdentifierArtifact which should produce the exact same file as will happen inside the container. It’s a violation of “build once”, but at least it’s DRY compatible.

This work by Fredrik Wendt is licensed under CC by-sa.