apply plugin: 'jetty' apply plugin: 'war' apply plugin: 'eclipse' apply plugin: 'checkstyle' apply plugin: 'findbugs' import org.apache.tools.ant.filters.ReplaceTokens task findbugs { findbugs { ignoreFailures = true } } task checkstyle { checkstyle { configFile = rootProject.file('gradle/perforce-checkstyle-config.xml'); ignoreFailures = true } } war.baseName = "p4-search" war.version = rootProject.version eclipse.project.name = "p4-search" eclipse.classpath.defaultOutputDir = new File("bin/WEB-INF/classes") eclipse.jdt.sourceCompatibility = 1.6 eclipse.jdt.targetCompatibility = 1.6 test { useTestNG() options { listeners << 'org.uncommons.reportng.HTMLReporter' listeners << 'org.uncommons.reportng.JUnitXMLReporter' listeners << 'org.testng.reporters.XMLReporter' } } // TODO: Not sure which of these will be necessary dependencies { compile files("./lib/p4java-2013.2.720310.jar") compile "org.apache.solr:solr-solrj:4.1.0" compile "javax.servlet:javax.servlet-api:3.0.1@jar" compile "jstl:jstl:1.2" compile "org.springframework:spring-webmvc:3.0.5.RELEASE" compile "org.codehaus.jackson:jackson-mapper-asl:1.8.2" compile "org.springframework.security:spring-security-core:3.1.3.RELEASE" compile "org.springframework.security:spring-security-config:3.1.3.RELEASE" compile "org.springframework.security:spring-security-web:3.1.3.RELEASE" compile "org.springframework:spring-context:3.1.3.RELEASE" compile "log4j:log4j:1.2.16" testCompile "org.testng:testng:6.1.1" runtime "log4j:log4j:1.2.16" testCompile("org.uncommons:reportng:1.1.2") { exclude group: "org.testng", module: "testng" } } task setManifestUsername { def whoamiProc = "whoami".execute() whoamiProc.waitFor() project.ext.manifestUsername = whoamiProc.in.text.trim() } task setManifestHostname { project.ext.manifestHostname = java.net.InetAddress.getLocalHost().getHostName(); } task prepareWarManifest(dependsOn: [setManifestUsername, setManifestHostname]) { war { manifest { attributes( "Perforce-version" : rootProject.version, "Perforce-User" : project.ext.manifestUsername, "Perforce-Hostname" : project.ext.manifestHostname ) } } } war.dependsOn( prepareWarManifest ) war { from('src/main/webapp/WEB-INF/jsp') { into('WEB-INF/jsp') filter(ReplaceTokens, tokens:["versionInfo": rootProject.version, "user": project.ext.manifestUsername.toString(), "hostname": project.ext.manifestHostname.toString() ]) } } // Exploded project setup. task copyExplodedLibs(type: Copy) { into "${buildDir}/exploded/WEB-INF/lib" from configurations.compile } task copyExplodedJsps(type: Copy, dependsOn: prepareWarManifest) { into "${buildDir}/exploded/WEB-INF/jsp" from("src/main/webapp/WEB-INF/jsp") { filter(ReplaceTokens, tokens:["versionInfo": rootProject.version, "user": project.ext.manifestUsername.toString(), "hostname": project.ext.manifestHostname.toString() ]) } } task copyExplodedResources(type: Copy, dependsOn: "processResources") { into "${buildDir}/exploded/WEB-INF/classes" from "${buildDir}/resources/main" } task copyExplodedClasses(type: Copy, dependsOn: "compileJava") { into "${buildDir}/exploded/WEB-INF/classes" from "${buildDir}/classes/main" } task prepareExploded(dependsOn: [copyExplodedLibs, copyExplodedClasses, copyExplodedResources, copyExplodedJsps])