How to change webAppDir to point to /web instead of src/main/webapp
我正在尝试将webAppDir更改为WebContent(eclipse中的动态Web应用程序结构)。
我正在使用gradle 1.7。 当我试图做与论坛中提到的相同的事情时,它给了我错误:
Creating properties on demand (a.k.a. dynamic properties) has been deprecated
and is scheduled to be removed in Gradle 2.0.
Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html
for information on the replacement for dynamic properties.
Deprecated dynamic property: "webAppDirName" on "root project 'xxxxxxxxxx", value: "WebContent".
输出WAR包含两个文件夹“WEB-INF”和“META-INF”
更新
build.gradle
webAppDirName='WebContent'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'eclipse-wtp'
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
}
configurations { moreLibs }
repositories {
flatDir { dirs "WebContent/WEB-INF/lib" }
mavenCentral()
}
dependencies {
compile fileTree(dir: "WebContent/WEB-INF/lib", include: '*.jar')
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
runtime 'javax.servlet:jstl:1.2'
}
/* Change context path (base url). otherwise defaults to name of project */
jettyRunWar.contextPath = ''
请帮忙。
另一个问题:
WEB-INF文件夹也在WebContent下。 WebContent的副本是否替换classes文件夹。
答案 0 :(得分:9)
终于解决了。
答案是
project.webAppDirName = 'WebContent'
Build.gradle文件:
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'eclipse-wtp'
project.webAppDirName = 'WebContent'
sourceSets {
main {
java { srcDir 'src' }
resources { srcDir 'src' }
}
}
configurations { moreLibs }
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: "WebContent/WEB-INF/lib", include: '*.jar')
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
runtime 'javax.servlet:jstl:1.2'
}
war {
exclude 'WEB-INF/lib/**'
exclude 'WEB-INF/classes/**'
}
/* Change context path (base url). otherwise defaults to name of project */
jettyRunWar.contextPath = ''