Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a reference to the jar file produced by Gradle build?

Tags:

gradle

build

I need to sign a jar after the jar task is being done in gradle. I have a need to reference the produced jar file from the build, and I can recreate the jar file, but I really look for a property that does this for me.

Here is how I've done it:

 jar.doLast {   jarfile = project.libsDir.path + File.separator + project.Name + '-' + project.version + '.jar'   ant.signJar(jar: jarfile, .... } 

Is there a property which can be used instead of the long "path calculation"?

like image 823
tronda Avatar asked Sep 24 '09 14:09

tronda


People also ask

Where is the JAR file after gradle build?

The Jar is created under the $project/build/libs/ folder.

Where does gradle store the jar?

Gradle declares dependencies on JAR files inside your project's module_name /libs/ directory (because Gradle reads paths relative to the build.gradle file). This declares a dependency on version 12.3 of the "app-magic" library, inside the "com.example.android" namespace group.

How do I access the build gradle file?

The app level build. gradle file is located inside your project folder under app/build. gradle.


1 Answers

jar.archivePath returns a file object pointing to the generated jar file.

Update: jar.archivePath is deprecated. Look at .archiveFile instead.

like image 51
tronda Avatar answered Sep 23 '22 19:09

tronda