如何获取集成到Eclipse项目中的gradle-api代码的源代码和javadoc/groovydoc?
我正在使用Gradle来构建我正在编写的Gradle插件.我正在使用Eclipse作为此项目的IDE,我用于构建此插件的Gradle脚本使用'Eclipse'插件来生成我的Eclipse项目.另外,我正在使用Eclipse的Spring Gradle插件,它从我的build.gradle文件中获取所有依赖项.
此Gradle脚本的依赖项块具有
dependencies {
compile localGroovy()
compile gradleApi()
// I want something like: 'compile gradleApiSources()' here
// I want something like: 'compile gradleApiDoc()' here as well
}
Run Code Online (Sandbox Code Playgroud)
在我学习编写Gradle插件时,能够查看Gradle的文档甚至实现以帮助我了解我正在做的事情会很有帮助.
这在 Eclipse 中对我有用:
plugins.withType(EclipsePlugin) {
plugins.withType(JavaBasePlugin) {
eclipse {
classpath {
file {
whenMerged { classpath ->
String gradleHome = gradle.getGradleHomeDir()
.absolutePath
.replace(File.separator, '/')
String gradleSourceDirectory = "${gradleHome}/src"
classpath.entries.each { entry ->
if (entry in org.gradle.plugins.ide.eclipse.model.AbstractLibrary
&& entry.library.path.contains('generated-gradle-jars')) {
entry.sourcePath =
new org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory()
.fromPath(gradleSourceDirectory)
}
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
确保您的 Gradle Home 包含源目录。如果您使用包装器,这可以通过将 更新为包装器任务中distributionUrl的-all版本来完成。
您还需要停止正在运行的 Gradle 守护进程,否则它们将保留自己的“家” : ./gradlew --stop,然后您可以继续运行任务:./gradlew eclipse
请参阅GRADLE-2133(此答案改编自)
| 归档时间: |
|
| 查看次数: |
909 次 |
| 最近记录: |