apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'eclipse-wtp' apply plugin: 'war' apply plugin: 'org.gretty' buildscript { repositories { gradlePluginPortal() // enable this to use snapshot versions of Gretty: // maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' } maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath 'org.gretty:gretty:3.0.7' } } configurations { providedCompile pdfbox2 } jar { manifest { attributes 'Implementation-Title': 'PDF-AS-WEB' } } repositories { mavenLocal() mavenCentral() maven { url "https://repo.spring.io/milestone/" } } sourceSets.main.compileClasspath += configurations.providedCompile sourceSets.test.compileClasspath += configurations.providedCompile sourceSets.test.runtimeClasspath += configurations.providedCompile dependencies { api project (':pdf-as-common') api project (':pdf-as-lib') api project (':pdf-as-moa') api project (':signature-standards:sigs-pkcs7detached') api project (':signature-standards:sigs-pades') api project (':pdf-as-web-status') api project (':pdf-as-web-statistic-api') api project (':pdf-as-pdfbox-2') api group: 'commons-fileupload', name: 'commons-fileupload', version: '1.5' api group: 'commons-io', name: 'commons-io', version: '2.15.1' api group: 'opensymphony', name: 'sitemesh', version: '2.4.2' api group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' api group: 'javax.xml.ws', name: 'jaxws-api', version: '2.3.1' api group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.3' api "commons-codec:commons-codec:1.15" api 'org.apache.commons:commons-lang3:3.14.0' api group: 'org.apache.commons', name: 'commons-collections4', version: '4.4' api 'org.apache.cxf:cxf-rt-transports-http:3.5.7' api 'org.apache.cxf:cxf-rt-frontend-jaxws:3.5.7' api 'com.thetransactioncompany:cors-filter:2.10' api 'ch.qos.logback:logback-classic:1.2.13' api 'ch.qos.logback:logback-core:1.2.13' api 'org.json:json:20231013' api group: 'javax.jws', name: 'javax.jws-api', version: '1.1' compileOnly 'javax.servlet:javax.servlet-api:3.0.1' testImplementation 'org.springframework:spring-test:5.3.31' } gretty { // supported values: // 'jetty7', 'jetty8', 'jetty9', 'jetty9.3', 'jetty9.4', 'tomcat85', 'tomcat9' servletContainer = 'tomcat85' jvmArgs = [ '-Dpdf-as-web.conf=' + System.getProperty("user.home") + '/.pdfas/pdf-as-web.properties' ] } test { systemProperties 'pdf-as-web.conf': System.getProperty("user.home") + '/.pdfas/pdf-as-web.properties' } task downloadTomcat { doLast { if(!project.buildDir.exists()){ project.buildDir.mkdirs() } String url = "https://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 } def deployVersions=[''] task copyTomcat(dependsOn: extractTomcat) { doLast { deployVersions.each{ String targetDir = project.buildDir.toString() + "/tomcat-##VERSION##"+it; targetDir = targetDir.replaceAll("##VERSION##", project.tomcatVersion); println "copiing to "+targetDir copy{ with extractTomcat into targetDir } } } } task cleanWebAppsInTomcat(dependsOn: copyTomcat) { doLast { deployVersions.each{ String targetDir = project.buildDir.toString() + "/tomcat-##VERSION##"+it+"/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) { doLast { deployVersions.each{ String source = project.projectDir.toString() + "/"; String targetDir = "build/tomcat-##VERSION##"+it+"/apache-tomcat-##VERSION##"; targetDir = targetDir.replaceAll("##VERSION##", project.tomcatVersion); copy{ from "src/main/assembly/tomcat" into targetDir } } } } task putConfigIntoTomcat(dependsOn: putTemplateIntoTomcat) { doLast { deployVersions.each{ String source = "../pdf-as-lib/build/resources/main/config/config.zip"; String targetDir = "build/tomcat-##VERSION##"+it+"/apache-tomcat-##VERSION##/conf/pdf-as"; targetDir = targetDir.replaceAll("##VERSION##", project.tomcatVersion); copy{ from zipTree(source) into targetDir } } } } task putWebConfigIntoTomcat(dependsOn: putConfigIntoTomcat) { doLast { deployVersions.each{ String targetDir = "build/tomcat-##VERSION##"+it+"/apache-tomcat-##VERSION##/conf/pdf-as"; targetDir = targetDir.replaceAll("##VERSION##", project.tomcatVersion); copy{ 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' } injectPdfAsWebApp.dependsOn 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 releaseConfig(type: Copy) { from 'src/main/configuration/pdf-as-web.properties' into rootDir.toString() + "/releases/" + version + "/cfg" } war{ doFirst{ sourceSets.main.compileClasspath += configurations.pdfbox2 sourceSets.test.compileClasspath += configurations.pdfbox2 classpath+=sourceSets.main.compileClasspath } } 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 from archive from tararchive into rootDir.toString() + "/releases/" + version } releases.dependsOn jar releases.dependsOn sourcesJar releases.dependsOn war releases.dependsOn releaseConfig releases.dependsOn buildTomcatTar