Create a gist now

Instantly share code, notes, and snippets.

@mekya /build.gradle
Last active Jul 30, 2017

What would you like to do?
Export War file from Eclipse Web Project with Gradle -- hope it saves some time for gradle newbies like me
//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')
}

hi iam creating a mesaging app can i get an assistance from you pliz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment