且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Gradle依赖关系本地jar文件

更新时间:2022-12-12 20:32:35

这是一个已知的限制,当前不存在文件依赖关系 gradle dependencies 。他们仍然工作(如果路径是正确的)。


I have problem with include local jar file.

I have two projects:

ProjectA

ProjectB

  --libs

   ----jgrapht-jdk1.6.jar

My build file include (This is the part that concerns 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'       
}}

I run command gradlew -q dependencies and see result


Project :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.

I use gradle 1.8, Windows 7 x64 Tell me please where I made a mistake.

It's a known limitation that file dependencies aren't currently shown by gradle dependencies. They nevertheless work (if the paths are right).