在我的build.gradle
文件中,我具有以下内容:
...
dependencies {
...
testCompile (group: 'org.uncommons', name: 'reportng', version: '1.1.2') { exclude group: 'org.testng', module: 'testng' }
...
}
...
reportng
需要velocity-1.4.jar
和velocity-dep-1.4.jar
,实际上上述testCompile
依赖关系导致这两个JAR会作为“导出”(即,它们在Eclipse““的” Java Build Path”对话框被选中)。这两个JAR设置为导出的事实是一个问题。我需要它们仍然被获取但不被导出。
从Gradle doc可以理解,这是通过按照他们的示例使用
.classpath
来完成的:apply plugin: 'java'
apply plugin: 'eclipse'
configurations {
provided
someBoringConfig
}
eclipse {
classpath {
//if you don't want some classpath entries 'exported' in Eclipse
noExportConfigurations += configurations.provided
}
}
我的问题是我没有
noExportConfigurations
节,虽然我当然可以添加一个,但我不知道要放什么,以便排除导出的不是整个configurations {}
而是仅附带的两个JAR它。
最佳答案
您可能会想要类似:
configurations {
noExport
}
dependencies {
// replace with correct values
noExport "foo:velocity:1.4"
noExport "foo:velocity-dep:1.4"
}
eclipse {
classpath {
noExportConfigurations += configurations.noExport
}
}
PS:请不要在此处和http://forums.gradle.org上重复发布。
关于eclipse - Gradle + Eclipse:如何不导出依赖关系的JAR?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22021289/