使用了面向 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 位置和 native 库位置显示为不可修改。这些可以从 Gradle 配置文件中设置吗?
如何通过 Eclipse 和 Gradle 设置这些?
最佳答案
您可以放置nameOfJar-sources.jar
同一目录中实际库旁边的文件。 Gradle 将使用它作为源附件。我想这同样适用于 javadocs,即 nameOfJar-javadoc.jar
会被捡起来的。我不知道如何处理 native 库。
这可能在 Gradle 文档的某处有所描述,但我不知道在哪里可以找到它们。
关于eclipse - 如何在 Eclipse 中为 Gradle 项目的本地依赖项指定源附件、Javadoc 位置和 native 库位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38598710/