Java Gradle 依赖本地 jar 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19231855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 15:17:14  来源:igfitidea点击:

Gradle dependencies local jar file

javagradle

提问by AndreyNik

I have problem with include local jar file.

我有包含本地 jar 文件的问题。

I have two projects:

我有两个项目:

ProjectA

ProjectB

  --libs

   ----jgrapht-jdk1.6.jar

My build file include (This is the part that concerns projectB):

我的构建文件包括(这是与 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

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



Project :ProjectB

项目:项目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.

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

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

采纳答案by Peter Niederwieser

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

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