configurations { warArtifact jarArtifact } apply plugin : 'war' dependencies { providedCompile(project(':core')) { transitive = false } compile fileTree("../i2pjars") { include '*.jar' } } war { from 'src/main/css' from ('src/main/images', { into "images" }) from ('src/main/js', { into "js" }) webInf { from "$buildDir/compiledJsps" into "classes" } excludes = new HashSet(['**/*.jsp', '**/*.jsi']) webXml = file("$buildDir/tmp_jsp/web.xml") } task precompileJsp { doLast { ant.taskdef (name : 'jasper', classname: 'org.apache.jasper.JspC', classpath: configurations.compile.asPath) def generated = new File("$buildDir/tmp_jsp") generated.mkdirs() ant.jasper(package: 'com.muwire.webui', classPath : sourceSets.main.runtimeClasspath.asPath, uriroot: webAppDir, outputDir: "$buildDir/tmp_jsp", compilerSourceVM: "1.8", compilerTargetVM: "1.8", webXmlFragment: "$buildDir/tmp_jsp/web.xml.jasper") def output = new File("$buildDir/compiledJsps") output.mkdirs() ant.javac(srcDir: 'build/tmp_jsp', classPath : sourceSets.main.runtimeClasspath.asPath, debug : true, destDir:file("$buildDir/compiledJsps")) } } task generateWebXML { doLast { def template = new File("$projectDir/templates/web.xml.template") def templateText = template.text def jasper = new File("$buildDir/tmp_jsp/web.xml.jasper") templateText = templateText.replaceAll("__JASPER__", jasper.text) templateText = templateText.replaceAll("__VERSION__", project.version) def webXml = new File("$buildDir/tmp_jsp/web.xml") webXml.text = templateText } } precompileJsp.dependsOn compileJava generateWebXML.dependsOn precompileJsp war.dependsOn generateWebXML artifacts { warArtifact war jarArtifact jar }