Gradle依赖本地jar文件

时间:2013-10-07 18:20:01

标签: java gradle

我遇到包含本地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 dependencies并查看结果


项目:ProjectB

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 请告诉我,我犯了错误。

1 个答案:

答案 0 :(得分:2)

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