本文介绍了Gradle依赖关系本地jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个项目:
ProjectA
ProjectB
--libs
---- jgrapht-jdk1.6.jar
我的构建文件包含(这是projectB关注的部分):
project(':ProjectB'){
apply plugin:'java'
repositories {
mavenCentral()
配置{
compileOnly
}
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
依赖关系{
compileOnly文件'libs / jgrapht-jdk1.6.jar')
compile'org.simpleframework:simple-xml:2.7@jar'
}}
我运行命令gradlew -q依赖关系并查看结果
Project:ProjectB
归档 - 配置归档工件。
没有依赖项
compile - 为源集main编译类路径。
\ --- org.simpleframework:simple-xml:2.7
compileOnly
无依赖关系
default - 默认工件配置。
\ --- org.simpleframework:simple-xml:2.7
runtime - 运行时类路径用于源集main。
\ --- org.simpleframework:simple-xml:2.7
testCompile - 为源集test编译classpath。
\ org.simpleframework:simple-xml:2.7
testRuntime - 源代码集test的运行时类路径。
\ --- org.simpleframework:simple-xml:2.7
行编译'org.simpleframework:simple-xml:2.7@jar' - 工作正常,
但是line compileOnly文件('libs / jgrapht-jdk1.6.jar')不起作用。
我使用gradle 1.8,Windows 7 x64
请告诉我,我犯了什么错误。
解决方案
这是一个已知的限制,当前不存在文件依赖关系 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 x64Tell 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).
这篇关于Gradle依赖关系本地jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!