Gradle: displaying artefact locations

Gradle’s output, unlike verbose build tools like Maven, is very terse. In my opinion, a bit too terse. For example, when running gradle jar, this is the output:


:epub-organizer-core:compileJava UP-TO-DATE
:epub-organizer-core:processResources UP-TO-DATE
:epub-organizer-core:classes UP-TO-DATE
:epub-organizer-core:jar UP-TO-DATE
:epub-organizer-dropwizard:compileJava UP-TO-DATE
:epub-organizer-dropwizard:processResources UP-TO-DATE
:epub-organizer-dropwizard:classes UP-TO-DATE
:epub-organizer-dropwizard:jar UP-TO-DATE

BUILD SUCCESSFUL

Total time: 13.752 secs

Okay, that’s nice, looks good, but now what? Where’s my jar? Remembering that it’s produced in build/libs is easy, but a less frequently used task like distZip will produce it’s artefacts in a different location, so you’ll have to remember those locations to. Luckily, Gradle is a very flexible build tool, and with the help of my friend Marcin Erdmann, we came up with the following Gradle script, which you can put in ~/.gradle/init.gradle, or as I did, in my build.gradle file. If you put it in your init.gradle file, please be aware that you’ll have to remove the ‘gradle.’ prefixes.

After each build, the following will now be produced:


:epub-organizer-dropwizard:classes UP-TO-DATE
:epub-organizer-dropwizard:jar UP-TO-DATE

BUILD SUCCESSFUL

Total time: 13.752 secs

Output location: /Users/erikp/User Files/Projects/epub-organizer-gradle/epub-organizer-dropwizard/build/libs/epub-organizer-dropwizard-1.0.jar

Still pretty terse, but quite useful anyway.