| 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 Jars 并将其与依赖项 Jars 关联。默认为 false。 |
downloadSources | 是否下载源 Jars 并将其与依赖 Jars 关联。默认为 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<? super XmlFileContentMerger>启用高级配置,例如修改输出 XML 或影响现有 .classpath 文件的内容与 Gradle 构建信息合并的方式。传递给 whenMerged{} 和 beforeMerged{} 闭包的对象的类型为Classpath。
请参阅EclipseProject示例。
启用高级配置,例如修改输出 XML 或影响现有 .classpath 文件的内容与 Gradle 构建信息合并的方式。传递给 whenMerged{} 和 beforeMerged{} 闭包的对象的类型为Classpath。
请参阅EclipseProject示例。