[PATCH 6 of 6] Mavenize importer packaging and allow packaging for specific versions and database systems

Wald Commits scm-commit at wald.intevation.org
Thu Apr 9 17:31:08 CEST 2015


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1428593385 -7200
# Node ID ae3df0f96e15ae5205e714da0e48c8ec7614f798
# Parent  44ba71b0b75adf118d74830865765f51eb472519
Mavenize importer packaging and allow packaging for specific versions and database systems.

diff -r 44ba71b0b75a -r ae3df0f96e15 backend/contrib/import_river.sh
--- a/backend/contrib/import_river.sh	Thu Apr 09 17:08:51 2015 +0200
+++ b/backend/contrib/import_river.sh	Thu Apr 09 17:29:45 2015 +0200
@@ -30,7 +30,7 @@
 DEFAULT_PASS=flys_dami
 DEFAULT_LOG=$PWD/logs
 DEFAULT_BACKEND_NAME="XE"
-JAR="hydr_morph/importer.jar"
+JAR="bin/river-backend-1.0-SNAPSHOT*.jar"
 IMPORTER_DRY_RUN=false
 IMPORTER_MAINVALUE_TYPES=QWTD-
 IMPORTER_ANNOTATION_TYPES="conf/annotation-types.xml"
diff -r 44ba71b0b75a -r ae3df0f96e15 backend/contrib/run_hydr_morph.sh
--- a/backend/contrib/run_hydr_morph.sh	Thu Apr 09 17:08:51 2015 +0200
+++ b/backend/contrib/run_hydr_morph.sh	Thu Apr 09 17:29:45 2015 +0200
@@ -7,7 +7,7 @@
 BACKEND_PORT="1521"
 BACKEND_NAME="XE"
 LOG4J_CONFIG="conf/log4j.properties"
-JAR="hydr_morph/importer.jar"
+JAR="bin/river-backend-1.0-SNAPSHOT*.jar"
 #####################################################################
 
 
diff -r 44ba71b0b75a -r ae3df0f96e15 backend/doc/documentation/de/importer-manual.tex
--- a/backend/doc/documentation/de/importer-manual.tex	Thu Apr 09 17:08:51 2015 +0200
+++ b/backend/doc/documentation/de/importer-manual.tex	Thu Apr 09 17:29:45 2015 +0200
@@ -28,7 +28,7 @@
 
 \newcommand{\documentdate}{\today}
 \newcommand{\documentversion}{1.2}
-\newcommand{\documentrevision}{rev6811}
+\newcommand{\documentrevision}{rev8673:25f9ab25affd}
 \newcommand{\documentID}{importer-manual.tex}
 %----------------------------------------------
 
diff -r 44ba71b0b75a -r ae3df0f96e15 backend/pom-oracle.xml
--- a/backend/pom-oracle.xml	Thu Apr 09 17:08:51 2015 +0200
+++ b/backend/pom-oracle.xml	Thu Apr 09 17:29:45 2015 +0200
@@ -38,16 +38,31 @@
         </configuration>
       </plugin>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>2.3</version>
+        <configuration>
+          <transformers>
+            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+              <mainClass>org.dive4elements.river.importer.Importer</mainClass>
+            </transformer>
+          </transformers>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
         <configuration>
-          <archive>
-            <manifest>
-              <mainClass>org.dive4elements.river.importer.Importer</mainClass>
-            </manifest>
-          </archive>
-          <descriptorRefs>
-            <descriptorRef>jar-with-dependencies</descriptorRef>
-          </descriptorRefs>
+          <descriptors>
+            <descriptor>src/assembly/assembly.xml</descriptor>
+          </descriptors>
         </configuration>
       </plugin>
     </plugins>
diff -r 44ba71b0b75a -r ae3df0f96e15 backend/pom.xml
--- a/backend/pom.xml	Thu Apr 09 17:08:51 2015 +0200
+++ b/backend/pom.xml	Thu Apr 09 17:29:45 2015 +0200
@@ -38,16 +38,31 @@
         </configuration>
       </plugin>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>2.3</version>
+        <configuration>
+          <transformers>
+            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+              <mainClass>org.dive4elements.river.importer.Importer</mainClass>
+            </transformer>
+          </transformers>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
         <configuration>
-          <archive>
-            <manifest>
-              <mainClass>org.dive4elements.river.importer.Importer</mainClass>
-            </manifest>
-          </archive>
-          <descriptorRefs>
-            <descriptorRef>jar-with-dependencies</descriptorRef>
-          </descriptorRefs>
+          <descriptors>
+            <descriptor>src/assembly/assembly.xml</descriptor>
+          </descriptors>
         </configuration>
       </plugin>
     </plugins>
diff -r 44ba71b0b75a -r ae3df0f96e15 backend/src/assembly/assembly.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backend/src/assembly/assembly.xml	Thu Apr 09 17:29:45 2015 +0200
@@ -0,0 +1,45 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+  <id>flys-importer</id>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <formats>
+     <format>tar</format>
+  </formats>
+  <fileSets>
+    <fileSet>
+      <directory>${project.build.directory}</directory>
+      <outputDirectory>/flys-importer/bin</outputDirectory>
+      <includes>
+        <include>*.jar</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>${project.basedir}/contrib</directory>
+      <outputDirectory>/flys-importer</outputDirectory>
+      <excludes>
+        <exclude>shpimporter/*.pyc</exclude>
+      </excludes>
+    </fileSet>
+    <fileSet>
+      <directory>${project.basedir}/doc/conf</directory>
+      <outputDirectory>/flys-importer/conf</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>${project.basedir}/doc/schema</directory>
+      <outputDirectory>/flys-importer/doc/schema</outputDirectory>
+      <includes>
+        <include>*.sql</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+  <files>
+    <!-- Include PDF-manual if existant -->
+    <file>
+      <source>
+        ${project.basedir}/doc/documentation/de/importer-manual.pdf
+      </source>
+      <outputDirectory>/flys-importer/doc/</outputDirectory>
+    </file>
+  </files>
+</assembly>
diff -r 44ba71b0b75a -r ae3df0f96e15 contrib/make_flys_release/bin/make-importer-package.sh
--- a/contrib/make_flys_release/bin/make-importer-package.sh	Thu Apr 09 17:08:51 2015 +0200
+++ b/contrib/make_flys_release/bin/make-importer-package.sh	Thu Apr 09 17:29:45 2015 +0200
@@ -1,56 +1,113 @@
 #!/bin/bash
+# Packaging-script for Dive4Elements River-Importer
+#
+# Copyright (C) 2011 - 2014 by Bundesanstalt für Gewässerkunde
+# Software engineering by Intevation GmbH
+#
+# This file is Free Software under the GNU AGPL (>=v3)
+# and comes with ABSOLUTELY NO WARRANTY! Check out the
+# documentation coming with Dive4Elements River for details.
+
 set -e
 
-# See README for more information
+# See ../README for more information
+# The working directory. Resulting tarball will be placed here.
+PKG_DIR=/tmp/flys-importer
+# Path to the flys checkout
+SOURCE_DIR=$(readlink -f `dirname $0`)/../../..
 
-# The working directory. Resulting tarball will be placed in the directory above.
-PKG_DIR=~/tmp/flys-importer
-# Path to the flys checkout
-FLYS_DIR=~/flys/river/
-# Tarball that will be extracted into flys-importer/opt
-EXTRAS=$1
+usage(){
+    cat << EOF
 
-rm -fr $PKG_DIR
-mkdir -p $PKG_DIR/hydr_morph
-mkdir -p $PKG_DIR/geodaesie
-mkdir -p $PKG_DIR/opt/lib64
-mkdir -p $PKG_DIR/schema
+usage: $0 [options] VERSION [EXTRAS]
 
-cd ${FLYS_DIR}/backend
-mvn -f pom-oracle.xml clean compile assembly:single
-cp target/backend-1.0-SNAPSHOT-jar-with-dependencies.jar \
-    $PKG_DIR/hydr_morph/importer.jar
-mvn -f pom.xml clean compile assembly:single
-cp target/river-backend-1.0-SNAPSHOT-jar-with-dependencies.jar \
-    $PKG_DIR/hydr_morph/importer_psql.jar
-cp ${FLYS_DIR}/backend/contrib/shpimporter/*.py $PKG_DIR/geodaesie
-cp ${FLYS_DIR}/backend/contrib/run_geo.sh \
-    ${FLYS_DIR}/backend/contrib/run_hydr_morph.sh \
-    ${FLYS_DIR}/backend/contrib/import_river.sh \
-    $PKG_DIR
-cp -r ${FLYS_DIR}/backend/doc/conf $PKG_DIR/
-if [ -f "$EXTRAS" ]; then
-    cd $PKG_DIR
-    tar -xzf "$EXTRAS"
+Create a D4E River Importer-package
+
+OPTIONS:
+   -?, --help          Show this message
+   -o, --oracle        Package is for Oracle.
+                       Suitable jar-file for JDBC driver has to be given with
+                       the environment variable ORACLE_JDBC
+   VERSION must specify a tag (usually MAYOR.MINOR.PATCH) or a branch name.
+   With EXTRAS, a tarball with dependencies can be given.
+EOF
+exit 0
+}
+
+OPTS=`getopt -o ?,o -l help,oracle -n $0 -- "$@"`
+
+if [ $? != 0 ] ; then usage; fi
+eval set -- "$OPTS"
+while true ; do
+  case "$1" in
+    "-?"|"--help")
+      usage;;
+    "--")
+      shift
+      break;;
+    "-o"|"--oracle")
+      BUILD_ORACLE="TRUE"
+      shift;;
+    *)
+      echo "Unknown Option $1"
+      usage;;
+  esac
+done
+
+if [ $# != 1 ]; then
+    usage
 fi
 
-cp ${FLYS_DIR}/backend/doc/schema/*.sql $PKG_DIR/schema
+VERSION=$1
+EXTRAS=$2
+
+# Update to VERSION
+echo "WARNING: any local changes in $SOURCE_DIR will be packaged."
+cd ${SOURCE_DIR}
+if [ -z "`hg tags | sed -n "/$VERSION/p"`" -a -z "`hg branches | sed -n "/$VERSION/p"`" ]
+then
+    echo "WARNING: $VERSION not found in $repo! Updating to default."
+    hg up default
+else
+    hg up "$VERSION"
+fi
 
 # create PDF of manual
 REV=`hg parent | sed -n '1s/[[:alnum:]]*: *\([0-9]*:.*\)/\1/;1p'`
-cd ${FLYS_DIR}/backend/doc/documentation/de/
+cd ${SOURCE_DIR}/backend/doc/documentation/de/
 sed -i "s/documentrevision..rev.*/documentrevision}{rev$REV}/" \
     importer-manual.tex
 # run pdflatex three times to get references and page numbering right
 pdflatex importer-manual.tex
 pdflatex importer-manual.tex
 pdflatex importer-manual.tex
-cp importer-manual.pdf $PKG_DIR
 
-sed -i 's/shpimporter\/shp/geodaesie\/shp/' $PKG_DIR/run_geo.sh
+# package importer
+if [ "$BUILD_ORACLE" = "TRUE" ]; then
+    if [ ! -f $ORACLE_JDBC ]; then
+        echo "Could not find oracle jdbc in $ORACLE_JDBC"
+        echo "Please make sure that the ORACLE_JDBC variable is set correctly"
+        exit 1
+    fi
+    mvn install:install-file -DgroupId=ojdbc -DartifactId=ojdbc \
+       -Dversion=0 -Dpackaging=jar -Dfile=$ORACLE_JDBC -DgeneratePom=true
+    mvn -f $SOURCE_DIR/backend/pom-oracle.xml clean package assembly:single
+else
+    mvn -f $SOURCE_DIR/backend/pom.xml clean package assembly:single
+fi
 
-cd $PKG_DIR/..
-DATE=$(date +%Y%m%d%H%M)
-tar -czf flys-importer_${DATE}.tar.gz flys-importer
-sha1sum flys-importer_${DATE}.tar.gz > flys-importer_${DATE}.tar.gz.sha1
-echo Package is at: `readlink -f flys-importer_${DATE}.tar.gz`
+echo "INFO: create tarball"
+rm -fr $PKG_DIR
+mkdir $PKG_DIR
+cd $PKG_DIR
+
+mv $SOURCE_DIR/backend/target/river-backend-1.0-SNAPSHOT*-flys-importer.tar \
+    flys-importer-$VERSION.tar
+if [ -f "$EXTRAS" ]; then
+    tar -xzf "$EXTRAS"
+    tar -rf flys-importer-$VERSION.tar opt
+fi
+
+gzip flys-importer-$VERSION.tar
+sha1sum flys-importer-$VERSION.tar.gz > flys-importer-$VERSION.tar.gz.sha1
+echo Package is at: `readlink -f flys-importer-$VERSION.tar.gz`


More information about the Dive4Elements-commits mailing list