apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'eclipse-wtp' apply plugin: 'war' apply plugin: 'jetty' sourceCompatibility = 1.5 jar { manifest { attributes 'Implementation-Title': 'PDF-AS-WEB' } } repositories { mavenLocal() mavenCentral() } dependencies { compile project (':pdf-as-lib') compile project (':signature-standards:sigs-pkcs7detached') compile project (':signature-standards:sigs-pades') compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.2' compile group: 'commons-collections', name: 'commons-collections', version: '3.2' compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2' compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.5' compile group: 'opensymphony', name: 'sitemesh', version: '2.4.2' compile 'javax.xml.ws:jaxws-api:2.2.11' compile "commons-codec:commons-codec:1.9" compile 'com.sun.xml.ws:jaxws-rt:2.2.8' compile 'com.sun.xml.bind:jaxb-impl:2.2.7' compile 'org.apache.commons:commons-lang3:3.3.2' compile 'org.apache.httpcomponents:httpclient:4.3.4' compile "org.hibernate:hibernate-core:4.3.5.Final" compile "org.hibernate:hibernate-entitymanager:4.3.5.Final" compile "mysql:mysql-connector-java:5.1.28" compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '1.8.5' providedCompile "javax.servlet:servlet-api:2.5" testCompile group: 'junit', name: 'junit', version: '4.+' } test { systemProperties 'property': 'value' } task downloadTomcat << { String url = "http://repo1.maven.org/maven2/org/apache/tomcat/tomcat/##VERSION##/tomcat-##VERSION##.zip" String filename = project.buildDir.toString() + "/tomcat-##VERSION##.zip"; url = url.replaceAll("##VERSION##", tomcatVersion); filename = filename.replaceAll("##VERSION##", tomcatVersion); println "Tomcat Version: " + url println "Tomcat file: " + filename def f = new File(filename) if (!f.exists()) { println "Downloading Tomcat ..." new URL(url).withInputStream{ i -> f.withOutputStream{ it << i }} } } task extractTomcat(dependsOn: downloadTomcat, type: Copy) { String filename = project.buildDir.toString() + "/tomcat-##VERSION##.zip"; filename = filename.replaceAll("##VERSION##", tomcatVersion); inputs.file filename String targetDir = project.buildDir.toString() + "/tomcat-##VERSION##"; targetDir = targetDir.replaceAll("##VERSION##", tomcatVersion); def zipFile = file(filename) def outputDir = file(targetDir) from zipTree(zipFile) into outputDir } task cleanWebAppsInTomcat(dependsOn: extractTomcat) << { String targetDir = project.buildDir.toString() + "/tomcat-##VERSION##/apache-tomcat-##VERSION##/webapps/"; targetDir = targetDir.replaceAll("##VERSION##", tomcatVersion); def webappDir = new File(targetDir); println "Removing: " + webappDir.toString() def result = webappDir.deleteDir() // Returns true if all goes well, false otherwise. println result.toString() assert result webappDir.mkdirs() } task putTemplateIntoTomcat(dependsOn: cleanWebAppsInTomcat, type: Copy) { String source = project.projectDir.toString() + "/"; String targetDir = "build/tomcat-##VERSION##/apache-tomcat-##VERSION##"; targetDir = targetDir.replaceAll("##VERSION##", tomcatVersion); from 'src/main/assembly/tomcat' into targetDir } task putConfigIntoTomcat(dependsOn: putTemplateIntoTomcat, type: Copy) { String source = "../pdf-as-lib/build/resources/main/config/config.zip"; String targetDir = "build/tomcat-##VERSION##/apache-tomcat-##VERSION##/conf/pdf-as"; targetDir = targetDir.replaceAll("##VERSION##", tomcatVersion); from zipTree(source) into targetDir } task putWebConfigIntoTomcat(dependsOn: putConfigIntoTomcat, type: Copy) { String targetDir = "build/tomcat-##VERSION##/apache-tomcat-##VERSION##/conf/pdf-as"; targetDir = targetDir.replaceAll("##VERSION##", tomcatVersion); from 'src/main/configuration/' into targetDir } task injectPdfAsWebApp(dependsOn: putWebConfigIntoTomcat, type: Copy) { war.execute(); String targetDir = project.buildDir.toString() + "/tomcat-##VERSION##/apache-tomcat-##VERSION##/webapps/"; targetDir = targetDir.replaceAll("##VERSION##", tomcatVersion); from war.outputs into targetDir rename '.*.war', 'pdf-as-web.war' } task buildTomcat(dependsOn: injectPdfAsWebApp, type: Zip) { String targetDir = project.buildDir.toString() + "/tomcat-##VERSION##/apache-tomcat-##VERSION##"; targetDir = targetDir.replaceAll("##VERSION##", tomcatVersion); String archive = "apache-tomcat-##VERSION##-pdf-as-web-##PVERSION##.zip"; archive = archive.replaceAll("##VERSION##", tomcatVersion); archive = archive.replaceAll("##PVERSION##", version); from targetDir archiveName archive destinationDir project.buildDir } task buildTomcatTar(dependsOn: injectPdfAsWebApp, type: Tar) { String targetDir = project.buildDir.toString() + "/tomcat-##VERSION##/apache-tomcat-##VERSION##"; targetDir = targetDir.replaceAll("##VERSION##", tomcatVersion); String archive = "apache-tomcat-##VERSION##-pdf-as-web-##PVERSION##.tar"; archive = archive.replaceAll("##VERSION##", tomcatVersion); archive = archive.replaceAll("##PVERSION##", version); from targetDir archiveName archive destinationDir project.buildDir } task releases(dependsOn: buildTomcat, type: Copy) { String archive = project.buildDir.toString() + "/apache-tomcat-##VERSION##-pdf-as-web-##PVERSION##.zip"; archive = archive.replaceAll("##VERSION##", tomcatVersion); archive = archive.replaceAll("##PVERSION##", version); String tararchive = project.buildDir.toString() + "/apache-tomcat-##VERSION##-pdf-as-web-##PVERSION##.tar"; tararchive = tararchive.replaceAll("##VERSION##", tomcatVersion); tararchive = tararchive.replaceAll("##PVERSION##", version); from war.outputs from archive from tararchive into rootDir.toString() + "/releases" } releases.dependsOn buildTomcatTar