How to reference the built jar

( #1

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.

(Peter Niederwieser) #2

‘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.

( #3

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