使用了面向 Java 开发人员的 Eclipse IDE (Neon) 以及默认的 Gradle 插件 (Buildship?)。
Gradle Git 项目是使用 Eclipse IDE 创建的。本地 JAR 存储在workspace/ProjectName/lib/nameOfJAR.jar
目录中。使用以下build.gradle配置将其作为依赖项添加到此项目中。
...
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
flatDir {
dirs 'lib/'
}
}
dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.21'
compile name: 'nameOfJAR'
// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
testCompile 'junit:junit:4.12'
}
然后Project Explorer > Project A > Gradle > Refresh Gradle Project
用于更新 Eclipse GUI,以显示这个新的本地依赖项,通过Project Explorer > Project A > Build Path > Configure Build Path > Libraries > Project and External Dependencies > [Name of JAR]
.
但是,在展开此部分时,源附件、Javadoc 位置和本机库位置显示为non modifiable。这些可以从 Gradle 配置文件中设置吗?
如何通过 Eclipse 和 Gradle 设置这些?