4

How to change webAppDir to point to /web instead of src/main/webapp

I am trying to change the webAppDir to WebContent (Dynamic Web Application Structure in eclipse).

I am using gradle 1.7. When i am trying to do the same thing as mention in Forum, it gives me error :

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".

The output WAR contains two folder "WEB-INF" and "META-INF"

UPDATE

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 = ''

Please help.

Another question:

WEB-INF folder is also under WebContent. Whether the Copy of WebContent replace the classes folder.

4

1 回答 1

11

终于解决了。

答案是 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 = ''
于 2013-08-21T08:10:14.200 回答