Gradle依赖本地jar文件

2024-04-08

我在包含本地 jar 文件时遇到问题。

我有两个项目:

ProjectA

ProjectB

  --libs

   ----jgrapht-jdk1.6.jar

我的构建文件包括(这是涉及projectB的部分):

project(':ProjectB') {

apply plugin: 'java'
repositories {
    mavenCentral()
}
configurations {
    compileOnly
}
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
dependencies {
    compileOnly files('libs/jgrapht-jdk1.6.jar')
    compile 'org.simpleframework:simple-xml:2.7@jar'       
}}

我运行命令 gradlew -q dependency 并查看结果


项目:项目B

archives - Configuration for archive artifacts.
No dependencies

compile - Compile classpath for source set 'main'.
\--- org.simpleframework:simple-xml:2.7

compileOnly
No dependencies

default - Configuration for default artifacts.
\--- org.simpleframework:simple-xml:2.7

runtime - Runtime classpath for source set 'main'.
\--- org.simpleframework:simple-xml:2.7

testCompile - Compile classpath for source set 'test'.
\--- org.simpleframework:simple-xml:2.7

testRuntime - Runtime classpath for source set 'test'.
\--- org.simpleframework:simple-xml:2.7

Line compile 'org.simpleframework:simple-xml:2.7@jar' - working fine,
 but line compileOnly files('libs/jgrapht-jdk1.6.jar') don't work.

我使用 gradle 1.8,Windows 7 x64 请告诉我我哪里做错了。


这是一个已知的限制,当前不显示文件依赖关系gradle dependencies。尽管如此,它们仍然有效(如果路径正确)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Gradle依赖本地jar文件 的相关文章

随机推荐