简体   繁体   English

Gradle-如何在输出jar中包含本地库

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

My Gradle project has a couple of maven dependencies. 我的Gradle项目有几个Maven依赖项。 I don't want those included in my jar. 我不要那些放在我的罐子里。 It also has some dependencies on local jars. 它还对本地jar有一些依赖性。 How can i include the classes from those in the output jar? 如何在输出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: 要从最终jar中排除依赖的jar,可以使用如下的编译配置:

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 在这里可以看到更详细的答案: Gradle依赖项本地jar文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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