[英]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.