| API 文档 | EclipseWtpComponent |
|---|
允许微调 Eclipse 插件的 wtp 组件详细信息
与所有可能属性混合使用的示例。请记住,通常您不必直接配置它们,因为 Gradle 会免费为您配置!
plugins {
id 'war' // or 'ear' or 'java'
id 'eclipse-wtp'
}
configurations {
someInterestingConfiguration
anotherConfiguration
}
eclipse {
//if you want parts of paths in resulting file(s) to be replaced by variables (files):
pathVariables 'GRADLE_HOME': file('/best/software/gradle'), 'TOMCAT_HOME': file('../tomcat')
wtp {
component {
//you can configure the context path:
contextPath = 'someContextPath'
//you can configure the deployName:
deployName = 'killerApp'
//you can alter the wb-resource elements.
//non-existing source dirs won't be added to the component file.
sourceDirs += file('someExtraFolder')
// dependencies to mark as deployable with lib folder deploy path
libConfigurations += [ configurations.someInterestingConfiguration ]
// dependencies to mark as deployable with root folder deploy path
rootConfigurations += [ configurations.someInterestingConfiguration ]
// dependencies to exclude from wtp deployment
minusConfigurations << configurations.anotherConfiguration
//you can add a wb-resource elements; mandatory keys: 'sourcePath', 'deployPath':
//if sourcePath points to non-existing folder it will *not* be added.
resource sourcePath: 'extra/resource', deployPath: 'deployment/resource'
//you can add a wb-property elements; mandatory keys: 'name', 'value':
property name: 'moodOfTheDay', value: ':-D'
}
}
}
为了解决边缘情况,用户可以对生成的 XML 文件执行高级配置。也可以通过 beforeMerged 和 whenMerged 闭包来影响 eclipse 插件合并现有配置的方式。
beforeMerged 和 whenMerged 闭包接收 WtpComponent 对象
高级配置示例
plugins {
id 'war'
id 'eclipse-wtp'
}
eclipse {
wtp {
component {
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 wtp component file content is loaded from existing file
//but before gradle build information is merged
beforeMerged { wtpComponent ->
//tinker with WtpComponent here
}
//closure executed after wtp component file content is loaded from existing file
//and after gradle build information is merged
whenMerged { wtpComponent ->
//you can tinker with the WtpComponent here
}
}
}
}
}
| 属性 | 描述 |
classesDeployPath | 类的部署路径。 |
contextPath | Web 应用程序的上下文路径 |
deployName | 要使用的部署名称。 |
file | |
libConfigurations | 其文件将被标记为以 |
libDeployPath | 库的部署路径。 |
minusConfigurations | 要从 wtp 部署中排除其文件的配置。 |
properties | 附加属性元素。 |
资源 | 附加 wb-resource 元素。 |
rootConfigurations | 其文件将被标记为以 '/' 部署路径部署的配置。 |
sourceDirs | 要转换为 wb-resource 元素的源目录。 |
| 块 | 描述 |
file | 启用高级配置,例如修改输出 XML 或影响现有 wtp 组件文件内容与 gradle 构建信息合并的方式 |
String classesDeployPath
类的部署路径。
有关示例,请参见 EclipseWtp 的文档
- 使用
eclipse和war插件时的默认值 /WEB-INF/classes- 使用
eclipse和ear插件时的默认值 /
String deployName
要使用的部署名称。
有关示例,请参见 EclipseWtp 的文档
- 使用
eclipse和war插件时的默认值 eclipse.project.name- 使用
eclipse和ear插件时的默认值 eclipse.project.name
Set<Configuration> libConfigurations
Set<Configuration>其文件将被标记为以 EclipseWtpComponent.getLibDeployPath() 的部署路径部署的配置。
有关示例,请参见 EclipseWtp 的文档
- 使用
eclipse和war插件时的默认值 [project.configurations.runtimeClasspath]- 使用
eclipse和ear插件时的默认值 [project.configurations.earlib]
String libDeployPath
库的部署路径。
有关示例,请参见 EclipseWtp 的文档
- 使用
eclipse和war插件时的默认值 /WEB-INF/lib- 使用
eclipse和ear插件时的默认值 /lib
Set<Configuration> minusConfigurations
Set<Configuration>要从 wtp 部署中排除其文件的配置。
有关示例,请参见 EclipseWtp 的文档
- 使用
eclipse和war插件时的默认值 [project.configurations.providedRuntime]- 使用
eclipse和ear插件时的默认值 []
List<WbProperty> properties
List<WbProperty>附加属性元素。
有关示例,请参见 EclipseWtp 的文档
- 使用
eclipse和war插件时的默认值 []- 使用
eclipse和ear插件时的默认值 []
List<WbResource> resources
List<WbResource>附加 wb-resource 元素。
有关示例,请参见 EclipseWtp 的文档
只有链接到现有目录的资源(WbResource.getSourcePath())才会添加到 wtp 组件文件。原因是,当项目导入到 Eclipse 时,不存在的资源目录声明会导致错误。
- 使用
eclipse和war插件时的默认值 [deployPath: '/', sourcePath: project.webAppDirName]- 使用
eclipse和ear插件时的默认值 []
Set<Configuration> rootConfigurations
Set<Configuration>其文件将被标记为以 '/' 部署路径部署的配置。
有关示例,请参见 EclipseWtp 的文档
- 使用
eclipse和war插件时的默认值 []- 使用
eclipse和ear插件时的默认值 [project.configurations.deploy]]
要转换为 wb-resource 元素的源目录。
有关示例,请参见 EclipseWtp 的文档
只有存在的源目录才会添加到 wtp 组件文件。不存在的资源目录声明会导致项目导入到 Eclipse 时出错。
- 使用
eclipse和war插件时的默认值 - 来自
project.sourceSets.main.allSource的源目录 - 使用
eclipse和ear插件时的默认值 - 除非未应用
java插件,否则相同:[project.appDirName]
void file(Action<? super XmlFileContentMerger> action)
Action<? super XmlFileContentMerger>启用高级配置,例如修改输出 XML 或影响现有 wtp 组件文件内容与 gradle 构建信息合并的方式。
有关示例,请参见 EclipseWtpComponent 的文档
启用高级配置,例如修改输出 XML 或影响现有 wtp 组件文件内容与 gradle 构建信息合并的方式
传递给 whenMerged{} 和 beforeMerged{} 闭包的对象类型为 WtpComponent
有关示例,请参见 EclipseWtpComponent 的文档
- 委托给
- 来自
file的XmlFileContentMerger