How to reference the built jar

Hi folks, I need to perform obfuscation on the jar that gets built by the Java plugin. What is the cleanest way to reference the jar file that is produced from the main source set?

I can do something like archivesBaseName + “-${version}.jar”, but I was wondering if there is a better way.

‘jar.outputs.files’ if you need a ‘FileCollection’, and ‘jar.archivePath’ or ‘jar.outputs.files.singleFile’ if you need a ‘File’. Passing ‘jar.outputs.files’ to another task has the advantage that Gradle can automatically infer the task dependency.


Thanks very much Peter. I’ll give that a try.