[英]Gradle sourceDir not adding defaultRootSource for Eclipse
我尝试配置eclipse-wtp以使用旧的Ant项目。 我的网络项目在/app
。 一切都差不多了。 唯一缺少的部分是<wb-resource deploy-path="/" source-path="/path/euro-gradle/app"/>
标签defaultRootSource
。 当我添加此标记(通过编辑org.eclipse.wst.common.component )时,应用程序通常在嵌入式Tomcat上启动。 没有这个Tomcat只是启动而不是部署应用程序。
我的gradle构建:
eclipse {
wtp {
facet{
facet name: 'jst.web', version: '2.5'
facet name: 'java', version: '1.7'
}
component {
contextPath = '/'
// resource deployPath: '/', sourcePath: '/app'
sourceDirs += file('/app')
}
}
}
您需要的是在项目上设置webAppDirName
(默认为src/main/webapp
)。 另见http://gradle.org/docs/current/userguide/war_plugin.html 。 eclipse-wtp
插件将使用此路径作为默认根源路径。
不幸的是,用于创建部署配置文件.settings / org.eclipse.wst.common.component的Gradle WbResource生成器似乎不支持除了部署路径和源路径之外的任何内容。
所以我们必须采用直接的xml操作:
eclipse.wtp.component.file.withXml { provider ->
def mainWebSourcePathNode = provider.asNode()['wb-module'][0].get('wb-resource').find {
it.attribute('source-path') == project.convention.plugins.war.webAppDirName
}
mainWebSourcePathNode['@tag'] = 'defaultRootSource'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.