Last active
July 30, 2017 10:07
-
-
Save mekya/87a28f6c2109928c7838 to your computer and use it in GitHub Desktop.
Export War file from Eclipse Web Project with Gradle -- hope it saves some time for gradle newbies like me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Export War file from Eclipse Web Project with Gradle | |
// we need to use war plugin | |
apply plugin: 'war' | |
//default webAppDirName in gradle is not "WebContent" but | |
// it is default in eclise so change it according to eclipse layout | |
// it encapsulates all files under webAppDirName | |
webAppDirName = 'WebContent' | |
// build directory of gradle, it is default "build" and | |
// we don't need to change it. I changed because I dont want eclipse | |
// and gradle build to be mixed. | |
buildDir = 'gradle_build' | |
// src is not default java source dir in gradle | |
// so change srcDir and resources srcDir | |
//according to eclipse project layout | |
sourceSets { | |
main { | |
java { | |
srcDir 'src' | |
} | |
resources { | |
srcDir 'src' | |
} | |
} | |
} | |
//I have just realized that we did not need repositories definiton below | |
//But it should be tested again after removing below lines | |
repositories { | |
flatDir { dirs "WebContent/WEB-INF/lib","libs"} | |
} | |
// In eclipse project, we generally add all dependecies under | |
//WEB-INF/lib for runtime. | |
// I also used libs directory for only compile time, | |
// we added two directory below to make gradle build successfully. | |
//It is defined as "providedCompile" which says gradle that do not | |
//add these libraries to | |
//war file explicitly because it will be available in runtime. | |
//btw, we already let gradle add all files to war under WebContent | |
dependencies { | |
providedCompile fileTree(dir:'WebContent/WEB-INF/lib', include:'*.jar') | |
providedCompile fileTree(dir:'libs', include:'*.jar') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi iam creating a mesaging app can i get an assistance from you pliz