简体   繁体   中英

Gradle WAR with compiled classes under WEB-INF/classes

I'm trying to port a legacy Java webapp project into gradle.

This is a snippet of my build.gradle

def customBuildPath = 'build/classes'

war {
    from(customBuildPath) {
        into 'WEB-INF/classes'
    }

    from('WebContent') {
        include 'Web/**/*'
        into ''
    }
}

dependencies {
  
    compile fileTree(dir: 'projectlibs/lib', include:'*.jar')
    compile fileTree(dir: 'build/classes', include:'**')
}

To maintain the custom structure I want to put all my *.class files under WEB-INF/classes and it works, but I find also the same *.class files under WEB-INF/lib .

My goal it to keep jars and classes in separated war folder.

Any thoughts?

Edit: Added dependencies{} to the build.gradle snippet.

Problem get solved with commenting out builded classes from the dependencies:

def customBuildPath = 'build/classes'

war {
    from(customBuildPath) {
        into 'WEB-INF/classes'
    }

    from('WebContent') {
        include 'Web/**/*'
        into ''
    }
}

dependencies {
  
    compile fileTree(dir: 'projectlibs/lib', include:'*.jar')
//    compile fileTree(dir: 'build/classes', include:'**')
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM