简体   繁体   中英

Gradle - How to include a local library in the output jar

My Gradle project has a couple of maven dependencies. I don't want those included in my jar. It also has some dependencies on local jars. How can i include the classes from those in the output jar?

You can refer to a local repository (a directory in this case) with the following:

repositories {
    ivy {
        // URL can refer to a local directory
        url "../local-repo"
    }
}

To exclude the dependent jars from your final jar, you can use the compile configuration like this:

compileOnly files('libs/jgrapht-jdk1.6.jar')
compile 'org.simpleframework:simple-xml:2.7'

A more detailed answer can be seen over here: Gradle dependencies local jar file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM