提问者:小点点

如何在gradle中设置webAppDirName


如何将webAppDir更改为指向 /web而不是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”

更新

< code>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文件夹。


共1个答案

匿名用户

终于解决了。

答案是project.webAppDirName = 'WebContent'

建筑放坡文件:

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