From a958e8c36bcc423a70a92dc4a3c562676fa66a37 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 22 Jul 2014 14:07:15 +0200 Subject: added buildTomcat task --- build.gradle | 3 + pdf-as-lib/src/configuration/cfg/log4j.properties | 26 +---- pdf-as-web/build.gradle | 106 +++++++++++++++++++-- pdf-as-web/src/main/assembly/tomcat/catalina.env | 11 +++ .../src/main/assembly/tomcat/setVariables.bat | 68 +++++++++++++ .../src/main/assembly/tomcat/startTomcat.bat | 5 + pdf-as-web/src/main/assembly/tomcat/startTomcat.sh | 9 ++ pdf-as-web/src/main/assembly/tomcat/stopTomcat.bat | 5 + pdf-as-web/src/main/assembly/tomcat/stopTomcat.sh | 7 ++ .../main/assembly/tomcat/webapps/ROOT/index.html | 14 +++ .../src/main/configuration/pdf-as-web.properties | 48 ++++++++++ 11 files changed, 273 insertions(+), 29 deletions(-) create mode 100644 pdf-as-web/src/main/assembly/tomcat/catalina.env create mode 100644 pdf-as-web/src/main/assembly/tomcat/setVariables.bat create mode 100644 pdf-as-web/src/main/assembly/tomcat/startTomcat.bat create mode 100755 pdf-as-web/src/main/assembly/tomcat/startTomcat.sh create mode 100644 pdf-as-web/src/main/assembly/tomcat/stopTomcat.bat create mode 100755 pdf-as-web/src/main/assembly/tomcat/stopTomcat.sh create mode 100644 pdf-as-web/src/main/assembly/tomcat/webapps/ROOT/index.html create mode 100644 pdf-as-web/src/main/configuration/pdf-as-web.properties diff --git a/build.gradle b/build.gradle index cf2db0c8..22740085 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,9 @@ subprojects { version = '4.0.0-RC8-SNAPSHOT' pdfasversion = version revision = getCheckedOutGitCommitHash() + //tomcatVersion = '7.0.54'; + tomcatVersion = '8.0.9'; + jar { manifest.attributes provider: 'EGIZ', 'Specification-Version': getCheckedOutGitCommitHash(), 'Implementation-Version': version } diff --git a/pdf-as-lib/src/configuration/cfg/log4j.properties b/pdf-as-lib/src/configuration/cfg/log4j.properties index b076ecb5..4a44d70d 100644 --- a/pdf-as-lib/src/configuration/cfg/log4j.properties +++ b/pdf-as-lib/src/configuration/cfg/log4j.properties @@ -1,13 +1,8 @@ -log4j.rootLogger = WARN, CONSOLE, ROLLINGFILE +log4j.rootLogger = INFO, CONSOLE, ROLLINGFILE # DETAIL LEVELS -log4j.logger.at.gv.egiz = DEBUG +log4j.logger.at.gv.egiz = INFO log4j.logger.at.knowcenter = INFO -log4j.logger.org.pdfbox = INFO -log4j.logger.at.knowcenter.wag.egov.egiz.ldap = DEBUG -log4j.logger.org.apache.commons.httpclient.HttpMethodBase = ERROR -log4j.logger.at.knowcenter.wag.egov.egiz.sig.connectors.MOASSRepsonseLogger = DEBUG, MOASS_FILE -log4j.additivity.at.knowcenter.wag.egov.egiz.sig.connectors.MOASSRepsonseLogger = false # Statistical logger #log4j.logger.statistic = INFO, STATISTIC @@ -20,23 +15,8 @@ log4j.appender.CONSOLE.Target = System.out # ROLLINGFILE log4j.appender.ROLLINGFILE = org.apache.log4j.RollingFileAppender -log4j.appender.ROLLINGFILE.File = ${pdf-as.work-dir}/logs/pdf-as.log +log4j.appender.ROLLINGFILE.File = ${catalina.base}/logs/pdf-as.log log4j.appender.ROLLINGFILE.MaxFileSize = 10240KB log4j.appender.ROLLINGFILE.MaxBackupIndex = 1 log4j.appender.ROLLINGFILE.layout = org.apache.log4j.PatternLayout log4j.appender.ROLLINGFILE.layout.ConversionPattern = [%-5p@%d{dd.MM.yyyy HH:mm:ss}] %c:%M:%L - %m%n - -# STATISTIC -log4j.appender.STATISTIC = org.apache.log4j.RollingFileAppender -log4j.appender.STATISTIC.File = ${pdf-as.work-dir}/logs/pdf-as-statistic.csv -log4j.appender.STATISTIC.MaxFileSize = 10240KB -log4j.appender.STATISTIC.MaxBackupIndex = 9 -log4j.appender.STATISTIC.layout = org.apache.log4j.PatternLayout -log4j.appender.STATISTIC.layout.ConversionPattern = %d{dd.MM.yyyy HH:mm:ss};%m%n - -# MOA-SS Response -log4j.appender.MOASS_FILE = org.apache.log4j.DailyRollingFileAppender -log4j.appender.MOASS_FILE.datePattern = '-'dd'.log' -log4j.appender.MOASS_FILE.File = ${pdf-as.work-dir}/logs/moa_ss_responses.log -log4j.appender.MOASS_FILE.layout = org.apache.log4j.PatternLayout -log4j.appender.MOASS_FILE.layout.ConversionPattern = %-6r %d{ISO8601} %-5p %40.40c %x - %m\n \ No newline at end of file diff --git a/pdf-as-web/build.gradle b/pdf-as-web/build.gradle index c92ac2b4..ccc29bec 100644 --- a/pdf-as-web/build.gradle +++ b/pdf-as-web/build.gradle @@ -44,10 +44,104 @@ test { systemProperties 'property': 'value' } -uploadArchives { - repositories { - flatDir { - dirs 'repos' - } - } +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 } + diff --git a/pdf-as-web/src/main/assembly/tomcat/catalina.env b/pdf-as-web/src/main/assembly/tomcat/catalina.env new file mode 100644 index 00000000..61e37593 --- /dev/null +++ b/pdf-as-web/src/main/assembly/tomcat/catalina.env @@ -0,0 +1,11 @@ +export CATALINA_HOME=`pwd` +export CATALINA_BASE=`pwd` +export CATALINA_OPTS="\ + -Djava.io.tmpdir=$CATALINA_BASE/temp \ + -Dpdf-as-web.conf=$CATALINA_BASE/conf/pdf-as/pdf-as-web.properties \ + -server \ + -Xss1024K \ + -Xms128M \ + -Xmx2048M \ + -XX:MaxPermSize=256m \ +" diff --git a/pdf-as-web/src/main/assembly/tomcat/setVariables.bat b/pdf-as-web/src/main/assembly/tomcat/setVariables.bat new file mode 100644 index 00000000..606f84e1 --- /dev/null +++ b/pdf-as-web/src/main/assembly/tomcat/setVariables.bat @@ -0,0 +1,68 @@ +@echo off + +set SERVICE_NAME=tomcatpdfas +set SERVICE_DESCRIPTION=ports: shutdown=8005, http=8080 +set SERVICE_DISPLAY_NAME=Apache Tomcat - PDF-AS-WEB +set TITLE=%SERVICE_DISPLAY_NAME% + +rem Set Tomcat installation folder, otherwise automatic detection will be performed. +set TOMCAT_DIR=%CD% + +rem Set Java installation folder, otherwise default JRE/JDK will be used. +rem set JAVA_HOME= + +@echo off +IF "%JAVA_HOME%" == "" ( + echo Enter path to JAVA_HOME: + set /p JAVA_HOME= +) ELSE ( + echo %JAVA_HOME% +) + +rem *** do not change settings beyond this point *** + +if exist %TOMCAT_DIR%\webapps\nul goto START +goto FIND_TOMCAT_DIR + +:FIND_TOMCAT_DIR +set TOMCAT_DIR= +if exist webapps\nul set TOMCAT_DIR=%CD% +if exist ..\webapps\nul set TOMCAT_DIR=%CD%\.. +if "%TOMCAT_DIR%"=="" goto TOMCAT_DIR_NOT_FOUND +goto START + +:TOMCAT_DIR_NOT_FOUND +echo. +echo Unable to find Tomcat installation folder. +goto END + +:START +set CATALINA_HOME=%TOMCAT_DIR% +set CATALINA_BASE=%TOMCAT_DIR% +set PDFAS_WORK_DIR=%CATALINA_BASE%\conf\pdf-as\pdf-as-web.properties + +rem PARAMETERS +set PDFAS_WORK_DIR_PARAM=-Dpdf-as-web.conf="%PDFAS_WORK_DIR%" + +rem MEMORY SETTINGS + +rem Thread stack size in KB +set JVM_XSS=1024 + +rem Initial memory pool size in MB +set JVM_XMS=128 + +rem Maximum memory pool size in MB +set JVM_XMX=2048 + +rem Maximum PermGenSize in M +set JVM_MAXPERMSIZE=256 + +rem COMMAND LINE OPTIONS +set JAVA_OPTS=-server -Xss%JVM_XSS%k -Xms%JVM_XMS%m -Xmx%JVM_XMX%m -XX:MaxPermSize=%JVM_MAXPERMSIZE%m +set CATALINA_OPTS=%PDFAS_WORK_DIR_PARAM% + +rem SERVICE OPTIONS +set SERVICE_OPTS=%PDFAS_WORK_DIR_PARAM%;-XX:MaxPermSize=%JVM_MAXPERMSIZE%m + +:END diff --git a/pdf-as-web/src/main/assembly/tomcat/startTomcat.bat b/pdf-as-web/src/main/assembly/tomcat/startTomcat.bat new file mode 100644 index 00000000..8db7b392 --- /dev/null +++ b/pdf-as-web/src/main/assembly/tomcat/startTomcat.bat @@ -0,0 +1,5 @@ +@echo off +call setVariables.bat +echo. +cd /d %CATALINA_HOME% +bin\catalina.bat start diff --git a/pdf-as-web/src/main/assembly/tomcat/startTomcat.sh b/pdf-as-web/src/main/assembly/tomcat/startTomcat.sh new file mode 100755 index 00000000..646f609b --- /dev/null +++ b/pdf-as-web/src/main/assembly/tomcat/startTomcat.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# +DEFAULT=`pwd`/catalina.env +. $DEFAULT + +chmod +x $CATALINA_HOME/bin/catalina.sh + +$CATALINA_HOME/bin/catalina.sh run + diff --git a/pdf-as-web/src/main/assembly/tomcat/stopTomcat.bat b/pdf-as-web/src/main/assembly/tomcat/stopTomcat.bat new file mode 100644 index 00000000..9c59fb50 --- /dev/null +++ b/pdf-as-web/src/main/assembly/tomcat/stopTomcat.bat @@ -0,0 +1,5 @@ +@echo off +call setVariables.bat +echo. +cd %CATALINA_HOME% +bin\catalina.bat stop diff --git a/pdf-as-web/src/main/assembly/tomcat/stopTomcat.sh b/pdf-as-web/src/main/assembly/tomcat/stopTomcat.sh new file mode 100755 index 00000000..c5943ebc --- /dev/null +++ b/pdf-as-web/src/main/assembly/tomcat/stopTomcat.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# +DEFAULT=`pwd`/catalina.env +. $DEFAULT + +$CATALINA_HOME/bin/catalina.sh stop + diff --git a/pdf-as-web/src/main/assembly/tomcat/webapps/ROOT/index.html b/pdf-as-web/src/main/assembly/tomcat/webapps/ROOT/index.html new file mode 100644 index 00000000..e607149c --- /dev/null +++ b/pdf-as-web/src/main/assembly/tomcat/webapps/ROOT/index.html @@ -0,0 +1,14 @@ + + + + + + Apache Tomcat - PDF-AS-WEB + + + +

Apache Tomcat - PDF-AS-WEB

+

PDF-AS

+ + + \ No newline at end of file diff --git a/pdf-as-web/src/main/configuration/pdf-as-web.properties b/pdf-as-web/src/main/configuration/pdf-as-web.properties new file mode 100644 index 00000000..2a779510 --- /dev/null +++ b/pdf-as-web/src/main/configuration/pdf-as-web.properties @@ -0,0 +1,48 @@ + +pdfas.dir=conf/pdf-as + +error.showdetails=false + +bku.local.url=http://127.0.0.1:3495/http-security-layer-request + +#bku.online.url=http://www.example.com/bkuonline/http-security-layer-request + +#bku.mobile.url= + +ks.enabled=false +ks.file=test.p12 +ks.type=PKCS12 +ks.pass=123456 +ks.key.alias=ecc_test +ks.key.pass=123456 + +#Enable SOAP Service +soap.sign.enabled=true + +whitelist.enabled=true +# Matches everything +whitelist.url.01=^.*$ + +public.url=http://localhost:8080/pdf-as-web + +#Request Store +# Default In Memory Store +request.store=at.gv.egiz.pdfas.web.store.InMemoryRequestStore +# DB Request Store for cluster +#request.store=at.gv.egiz.pdfas.web.store.DBRequestStore + +# seconds Requests are kept in Database (default 600) +#request.db.timeout=600 + +#Hibernate Properties for DB Store + +#hibernate.props.hibernate.dialect=org.hibernate.dialect.MySQLDialect +#hibernate.props.hibernate.connection.driver_class=com.mysql.jdbc.Driver +#hibernate.props.hibernate.connection.url=jdbc:mysql://localhost/pdfasweb +#hibernate.props.hibernate.connection.username=pdfasweb +#hibernate.props.hibernate.connection.password=pdfasweb +#hibernate.props.hibernate.connection.pool_size=5 +#hibernate.props.hibernate.connection.autocommit=false +#hibernate.props.hibernate.show_sql=true +#hibernate.props.hibernate.hbm2ddl.auto=update + -- cgit v1.2.3