How to set proguard output jar as artifact?

(Luis Mirabal) #1

I’m trying to create a configuration to define an obfuscated jar produced by a proguard task as an artifact.

I’d like to only refer to the task producing the jar rather than the path itself but I’ve realised that ProguardTask is not an ArchiveTask. Is there any way to avoid hard-coding the path in the artifacts section?

This is what I would like to have but it doesn’t work:

configurations {

task obfuscate(type: ProguardTask) {
    injars tasks.jar
    outjars "$buildDir/obfuscated-app.jar"

artifacts {
    obfuscatedArchive obfuscate

(Chris Doré) #2

This should get you going

artifacts {
    obfuscatedArchive( obfuscate.outputs.files.singleFile ) {
        builtBy obfuscate
        // can also set classifier, extension, name, etc as needed (some defaults will be inferred from the filename)
        // see