API 文档 | EclipseClasspath |
---|
生成的 Eclipse 项目的构建路径设置。由 GenerateEclipseClasspath
任务用于生成 Eclipse .classpath 文件。
以下示例演示了各种配置选项。请记住,所有属性都有合理的默认值;只有在默认值不符合您的需求时才显式配置它们。
plugins { id 'java' id 'eclipse' } configurations { provided someBoringConfig } eclipse { //if you want parts of paths in resulting file to be replaced by variables (files): pathVariables 'GRADLE_HOME': file('/best/software/gradle'), 'TOMCAT_HOME': file('../tomcat') classpath { //you can tweak the classpath of the Eclipse project by adding extra configurations: plusConfigurations += [ configurations.provided ] //you can also remove configurations from the classpath: minusConfigurations += [ configurations.someBoringConfig ] //if you want to append extra containers: containers 'someFriendlyContainer', 'andYetAnotherContainer' //customizing the classes output directory: defaultOutputDir = file('build-eclipse') //default settings for downloading sources and Javadoc: downloadSources = true downloadJavadoc = false //if you want to expose test classes to dependent projects containsTestFixtures = true //customizing which Eclipse source directories should be marked as test testSourceSets = [sourceSets.test] //customizing which dependencies should be marked as test on the project's classpath testConfigurations = [configurations.testCompileClasspath, configurations.testRuntimeClasspath] } }
为了处理边缘情况,用户可以对生成的 XML 文件执行高级配置。还可以通过 beforeMerged 和 whenMerged 闭包影响 Eclipse 插件合并现有配置的方式。
beforeMerged 和 whenMerged 闭包接收一个 Classpath
对象。
高级配置示例
plugins { id 'java' id 'eclipse' } eclipse { classpath { file { //if you want to mess with the resulting XML in whatever way you fancy withXml { def node = it.asNode() node.appendNode('xml', 'is what I love') } //closure executed after .classpath content is loaded from existing file //but before gradle build information is merged beforeMerged { classpath -> //you can tinker with the Classpath here } //closure executed after .classpath content is loaded from existing file //and after gradle build information is merged whenMerged { classpath -> //you can tinker with the Classpath here } } } }
属性 | 描述 |
containers | 要添加的类路径容器。 |
defaultOutputDir | Eclipse 放置编译后的类的默认输出目录。 |
downloadJavadoc | 是否下载 Javadoc Jar 并将其与依赖 Jar 关联。默认为 false。 |
downloadSources | 是否下载源 Jar 并将其与依赖 Jar 关联。默认为 true。 |
file | |
minusConfigurations | 要从类路径条目中排除其文件的配置。 |
plusConfigurations | 要作为类路径条目添加其文件的配置。 |
方法 | 描述 |
containers(containers) | 要进一步添加的类路径容器。 |
file(action) | 支持高级配置,例如修改输出 XML 或影响现有 .classpath 文件内容与 Gradle 构建信息合并的方式。传递给 whenMerged{} 和 beforeMerged{} 闭包的对象类型为 |
File
defaultOutputDir
Eclipse 放置编译后的类的默认输出目录。
请参阅 EclipseClasspath
获取示例。
- 使用
eclipse
和java
插件时的默认值 ${project.projectDir}
/bin/default
Collection
<Configuration
>
minusConfigurations
Collection
<Configuration
>要从类路径条目中排除其文件的配置。
请参阅 EclipseClasspath
获取示例。
- 使用
eclipse
和java
插件时的默认值 []
Collection
<Configuration
>
plusConfigurations
Collection
<Configuration
>要作为类路径条目添加其文件的配置。
请参阅 EclipseClasspath
获取示例。
- 使用
eclipse
和java
插件时的默认值 project.configurations.testRuntime
void
file
(Action
<? super XmlFileContentMerger
>
action)
Action
<? super XmlFileContentMerger
>支持高级配置,例如修改输出 XML 或影响现有 .classpath 文件内容与 Gradle 构建信息合并的方式。传递给 whenMerged{} 和 beforeMerged{} 闭包的对象类型为 Classpath
。
请参阅 EclipseProject
获取示例。
支持高级配置,例如修改输出 XML 或影响现有 .classpath 文件内容与 Gradle 构建信息合并的方式。传递给 whenMerged{} 和 beforeMerged{} 闭包的对象类型为 Classpath
。
请参阅 EclipseProject
获取示例。
- 委托给
XmlFileContentMerger
来自file