in Code

GRADLE: How to copy files from another .jar into your resulting output .jar

In our project we like to deliver a single jar as the final product, if you need to copy files that live on an existing jar into the Gradle’s output jar, this example shows you how to do that (and more)

jar {
//this is how you change the name of the output jar
archiveName=’frostwire.jar’

//some exclusion rules to keep your .jar clean
exclude(‘META-INF/*.SF’, ‘META-INF/*.DSA’, ‘META-INF/*.RSA’, ‘META-INF/*.MF’)

//here we grab all the .class files inside messages.jar and we put them in our resulting jar
from (zipTree(‘lib/jars/messages.jar’)) {
include ‘**/*.class’
}

//how to manipulate the jar’s manifest
manifest {
attributes ‘Main-Class’: ‘com.limegroup.gnutella.gui.Main’
}
}

Write a Comment

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.