apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'eclipse-wtp' apply plugin: 'war' apply plugin: 'jetty' 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.3.1' compile 'org.apache.commons:commons-collections4:4.0' compile 'commons-io:commons-io:2.4' compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.7' 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.5' compile "org.hibernate:hibernate-core:4.3.6.Final" compile "org.hibernate:hibernate-entitymanager:4.3.6.Final" compile "mysql:mysql-connector-java:5.1.33" 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##", project.tomcatVersion); filename = filename.replaceAll("##VERSION##", project.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##", project.tomcatVersion); inputs.file filename String targetDir = project.buildDir.toString() + "/tomcat-##VERSION##"; targetDir = targetDir.replaceAll("##VERSION##", project.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##", project.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##", project.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##", project.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##", project.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##", project.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##", project.tomcatVersion); String archive = "apache-tomcat-##VERSION##-pdf-as-web-##PVERSION##.zip"; archive = archive.replaceAll("##VERSION##", project.tomcatVersion); archive = archive.replaceAll("##PVERSION##", project.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##", project.tomcatVersion); String archive = "apache-tomcat-##VERSION##-pdf-as-web-##PVERSION##.tar"; archive = archive.replaceAll("##VERSION##", project.tomcatVersion); archive = archive.replaceAll("##PVERSION##", project.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##", project.tomcatVersion); archive = archive.replaceAll("##PVERSION##", project.version); String tararchive = project.buildDir.toString() + "/apache-tomcat-##VERSION##-pdf-as-web-##PVERSION##.tar"; tararchive = tararchive.replaceAll("##VERSION##", project.tomcatVersion); tararchive = tararchive.replaceAll("##PVERSION##", project.version); from war.outputs from archive from tararchive into rootDir.toString() + "/releases" } releases.dependsOn buildTomcatTar