[PATCH 2 of 2] Improve backend build for different database backends

Wald Commits scm-commit at wald.intevation.org
Tue Feb 7 16:13:38 CET 2023


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1675782703 -3600
#      Tue Feb 07 16:11:43 2023 +0100
# Branch 3.2.x
# Node ID 3847836c60b54f34cc41663bfd860919df01029d
# Parent  b57b236c4f4e6a9c0c26b726fe2f84705db4d21a
Improve backend build for different database backends

Use profiles instead of multiple almost identical POMs.
Introduce build-time argument for Docker build.

diff -r b57b236c4f4e -r 3847836c60b5 artifacts/pom-oracle.xml
--- a/artifacts/pom-oracle.xml	Mon Feb 06 16:57:03 2023 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.dive4elements.river</groupId>
-  <artifactId>river-artifacts</artifactId>
-  <version>1.0-SNAPSHOT</version>
-  <packaging>jar</packaging>
-
-  <name>river-artifacts</name>
-  <url>http://maven.apache.org</url>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-
-  <build>
-    <plugins>
-      <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <version>2.0.2</version>
-          <configuration>
-              <source>1.7</source>
-              <target>1.7</target>
-              <encoding>UTF-8</encoding>
-          </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-        <version>2.8.1</version>
-        <configuration>
-          <show>private</show>
-          <nohelp>true</nohelp>
-        </configuration>
-      </plugin>
-      <plugin>
-        <artifactId>maven-assembly-plugin</artifactId>
-        <configuration>
-          <descriptors>
-            <descriptor>src/assembly/assembly.xml</descriptor>
-          </descriptors>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <version>3.0.0</version>
-        <configuration>
-          <configLocation>../checkstyle.xml</configLocation>
-          <encoding>UTF-8</encoding>
-        </configuration>
-        <executions>
-          <execution>
-            <id>validate</id>
-            <phase>validate</phase>
-            <configuration>
-              <consoleOutput>true</consoleOutput>
-              <failsOnError>true</failsOnError>
-            </configuration>
-            <goals>
-              <goal>check</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
-  <dependencies>
-    <dependency>
-      <groupId>net.sf.ehcache</groupId>
-      <artifactId>ehcache-core</artifactId>
-      <version>2.4.2</version>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.13</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>trove</groupId>
-      <artifactId>trove</artifactId>
-      <version>1.1-beta-5</version>
-    </dependency>
-    <dependency>
-      <groupId>net.sf.opencsv</groupId>
-      <artifactId>opencsv</artifactId>
-      <version>2.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.dive4elements</groupId>
-      <artifactId>artifact-database</artifactId>
-      <version>1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.dive4elements</groupId>
-      <artifactId>artifacts-common</artifactId>
-      <version>1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.dive4elements.river</groupId>
-      <artifactId>river-backend</artifactId>
-      <version>1.0-SNAPSHOT-ora</version>
-    </dependency>
-    <dependency>
-      <groupId>org.jfree</groupId>
-      <artifactId>jfreechart</artifactId>
-      <version>1.0.15</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.xmlgraphics</groupId>
-      <artifactId>batik-dom</artifactId>
-      <version>1.7</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.xmlgraphics</groupId>
-      <artifactId>batik-svggen</artifactId>
-      <version>1.7</version>
-    </dependency>
-    <dependency>
-      <groupId>com.lowagie</groupId>
-      <artifactId>itext</artifactId>
-      <version>2.1.7</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-math</artifactId>
-      <version>2.2</version>
-    </dependency>
-    <dependency>
-      <groupId>com.h2database</groupId>
-      <artifactId>h2</artifactId>
-      <version>1.3.158</version>
-    </dependency>
-    <dependency>
-        <groupId>commons-io</groupId>
-        <artifactId>commons-io</artifactId>
-        <version>2.4</version>
-    </dependency>
-    <dependency>
-      <groupId>org.geotools</groupId>
-      <artifactId>gt-shapefile</artifactId>
-      <version>2.7.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.geotools</groupId>
-      <artifactId>gt-epsg-wkt</artifactId>
-      <version>2.7.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.geotools</groupId>
-      <artifactId>gt-geojson</artifactId>
-      <version>2.7.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.geotools</groupId>
-      <artifactId>gt-swing</artifactId>
-      <version>2.7.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.hibernatespatial</groupId>
-      <artifactId>hibernate-spatial</artifactId>
-      <version>1.1.1</version>
-    </dependency>
-    <dependency>
-      <groupId>org.json</groupId>
-      <artifactId>json</artifactId>
-      <version>20090211</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>1.7</version>
-    </dependency>
-    <dependency>
-      <groupId>net.sf.jasperreports</groupId>
-      <artifactId>jasperreports</artifactId>
-      <version>4.5.0</version>
-      <exclusions>
-        <exclusion>
-          <groupId>jfree</groupId>
-          <artifactId>jfreechart</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.groovy</groupId>
-      <artifactId>groovy-all</artifactId>
-      <version>1.6.0</version>
-    </dependency>
-  </dependencies>
-  <repositories>
-    <repository>
-      <id>gt2.repo</id>
-      <name>GeoTools2 Repository including JTS</name>
-      <url>https://repo.osgeo.org/repository/release</url>
-    </repository>
-    <repository>
-      <id>Hibernate Spatial repo</id>
-      <url>http://www.hibernatespatial.org/repository</url>
-    </repository>
-  </repositories>
-</project>
diff -r b57b236c4f4e -r 3847836c60b5 backend/pom-oracle.xml
--- a/backend/pom-oracle.xml	Mon Feb 06 16:57:03 2023 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,183 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.dive4elements.river</groupId>
-  <artifactId>river-backend</artifactId>
-  <version>1.0-SNAPSHOT-ora</version>
-  <packaging>jar</packaging>
-
-  <name>river-backend</name>
-  <url>http://maven.apache.org</url>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>2.0.2</version>
-        <configuration>
-          <source>1.7</source>
-          <target>1.7</target>
-          <encoding>UTF-8</encoding>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-plugin</artifactId>
-        <version>2.10</version>
-        <executions>
-          <execution>
-            <id>analyze</id>
-            <goals>
-              <goal>analyze-only</goal>
-            </goals>
-            <configuration>
-              <failOnWarning>true</failOnWarning>
-              <ignoreNonCompile>true</ignoreNonCompile>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <version>2.4</version>
-        <configuration>
-          <archive>
-            <manifest>
-              <mainClass>org.dive4elements.river.importer.Importer</mainClass>
-              <packageName>org.dive4elements.river.importer</packageName>
-            </manifest>
-          </archive>
-        </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>
-          <descriptors>
-            <descriptor>src/assembly/assembly.xml</descriptor>
-          </descriptors>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <version>3.0.0</version>
-        <configuration>
-          <configLocation>../checkstyle.xml</configLocation>
-          <encoding>UTF-8</encoding>
-        </configuration>
-        <executions>
-          <execution>
-            <id>validate</id>
-            <phase>validate</phase>
-            <configuration>
-              <consoleOutput>true</consoleOutput>
-              <failsOnError>true</failsOnError>
-            </configuration>
-            <goals>
-              <goal>check</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.dive4elements</groupId>
-      <artifactId>artifacts-common</artifactId>
-      <version>1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <!-- Add less unsave version of transitive hibernate dependency -->
-      <groupId>commons-collections</groupId>
-      <artifactId>commons-collections</artifactId>
-      <version>3.2.2</version>
-      <scope>runtime</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.hibernate</groupId>
-      <artifactId>hibernate-core</artifactId>
-      <version>3.6.10.Final</version>
-      <exclusions>
-        <!-- exclude unsafe transitive dependency -->
-        <exclusion>
-          <groupId>commons-collections</groupId>
-          <artifactId>commons-collections</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.hibernate.javax.persistence</groupId>
-      <artifactId>hibernate-jpa-2.0-api</artifactId>
-      <version>1.0.1.Final</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-api</artifactId>
-      <version>2.17.1</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
-      <version>2.17.1</version>
-      <scope>runtime</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-dbcp2</artifactId>
-      <version>2.1.1</version>
-    </dependency>
-    <dependency>
-      <groupId>com.vividsolutions</groupId>
-      <artifactId>jts</artifactId>
-      <version>1.11</version>
-    </dependency>
-    <dependency>
-      <groupId>org.hibernatespatial</groupId>
-      <artifactId>hibernate-spatial-oracle</artifactId>
-      <version>1.1.1</version>
-      <scope>runtime</scope>
-    </dependency>
-    <dependency>
-      <groupId>com.oracle.database.jdbc</groupId>
-      <artifactId>ojdbc8</artifactId>
-      <version>[19,20)</version>
-      <scope>runtime</scope>
-    </dependency>
-  </dependencies>
-
-  <repositories>
-    <repository>
-        <id>Hibernate Spatial repo</id>
-        <url>http://www.hibernatespatial.org/repository</url>
-    </repository>
-  </repositories>
-</project>
diff -r b57b236c4f4e -r 3847836c60b5 backend/pom.xml
--- a/backend/pom.xml	Mon Feb 06 16:57:03 2023 +0100
+++ b/backend/pom.xml	Tue Feb 07 16:11:43 2023 +0100
@@ -185,32 +185,69 @@
       <artifactId>jts</artifactId>
       <version>1.11</version>
     </dependency>
-    <dependency>
-      <!-- overwrite dependency of postgis-jdbc -->
-      <groupId>org.postgresql</groupId>
-      <artifactId>postgresql</artifactId>
-      <version>42.0.0.jre7</version>
-      <scope>runtime</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.postgis</groupId>
-      <artifactId>postgis-jdbc</artifactId>
-      <version>1.3.3</version>
-      <scope>runtime</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>postgresql</groupId>
+  </dependencies>
+
+  <profiles>
+    <!-- Build with support for PostgreSQL/PostGIS by default -->
+    <profile>
+      <id>postgis</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <dependencies>
+        <dependency>
+          <!-- overwrite dependency of postgis-jdbc -->
+          <groupId>org.postgresql</groupId>
           <artifactId>postgresql</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.hibernatespatial</groupId>
-      <artifactId>hibernate-spatial-postgis</artifactId>
-      <version>1.1.1</version>
-      <scope>runtime</scope>
-    </dependency>
-  </dependencies>
+          <version>42.0.0.jre7</version>
+          <scope>runtime</scope>
+        </dependency>
+        <dependency>
+          <groupId>org.postgis</groupId>
+          <artifactId>postgis-jdbc</artifactId>
+          <version>1.3.3</version>
+          <scope>runtime</scope>
+          <exclusions>
+            <exclusion>
+              <groupId>postgresql</groupId>
+              <artifactId>postgresql</artifactId>
+            </exclusion>
+          </exclusions>
+        </dependency>
+        <dependency>
+          <groupId>org.hibernatespatial</groupId>
+          <artifactId>hibernate-spatial-postgis</artifactId>
+          <version>1.1.1</version>
+          <scope>runtime</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+
+    <!-- Build with Oracle support by setting environment variable ORACLE=true -->
+    <profile>
+      <id>oracle</id>
+      <activation>
+        <property>
+          <name>env.ORACLE</name>
+          <value>true</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.hibernatespatial</groupId>
+          <artifactId>hibernate-spatial-oracle</artifactId>
+          <version>1.1.1</version>
+          <scope>runtime</scope>
+        </dependency>
+        <dependency>
+          <groupId>com.oracle.database.jdbc</groupId>
+          <artifactId>ojdbc8</artifactId>
+          <version>[19,20)</version>
+          <scope>runtime</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
 
   <repositories>
     <repository>
diff -r b57b236c4f4e -r 3847836c60b5 contrib/make_flys_release/bin/make-importer-package.sh
--- a/contrib/make_flys_release/bin/make-importer-package.sh	Mon Feb 06 16:57:03 2023 +0100
+++ b/contrib/make_flys_release/bin/make-importer-package.sh	Tue Feb 07 16:11:43 2023 +0100
@@ -44,7 +44,7 @@
       shift
       break;;
     "-o"|"--oracle")
-      BUILD_ORACLE="TRUE"
+      ORACLE="true"
       shift;;
     *)
       echo "Unknown Option $1"
@@ -81,11 +81,8 @@
 pdflatex importer-manual.tex
 
 # package importer
-if [ "$BUILD_ORACLE" = "TRUE" ]; then
-    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
+# If ORACLE=true, the oracle profile in the POM is activated
+mvn -f $SOURCE_DIR/backend/pom.xml clean package assembly:single
 
 echo "INFO: create tarball"
 rm -fr $PKG_DIR
diff -r b57b236c4f4e -r 3847836c60b5 contrib/make_flys_release/make_release.sh
--- a/contrib/make_flys_release/make_release.sh	Mon Feb 06 16:57:03 2023 +0100
+++ b/contrib/make_flys_release/make_release.sh	Tue Feb 07 16:11:43 2023 +0100
@@ -73,7 +73,7 @@
       WORK_DIR=$2
       shift 2;;
     "-o"|"--oracle")
-      BUILD_ORACLE="TRUE"
+      ORACLE="true"
       shift;;
     "-t")
       DO_TAG=$2
@@ -186,7 +186,10 @@
 
 echo "INFO: compile sources"
 mvn -f $FLYS_SOURCE_DIR/framework/pom.xml clean compile install
+
+# If ORACLE=true, the oracle profile in the POM is activated
 mvn -f $FLYS_SOURCE_DIR/river/backend/pom.xml clean compile install
+
 mvn -f $FLYS_SOURCE_DIR/river/artifacts/pom.xml clean compile
 mvn -f $FLYS_SOURCE_DIR/http-client/pom.xml clean compile install
 # gwt-client has to be compiled later to allow custom CLIENT_CONF
@@ -274,13 +277,7 @@
 cp $WORK_DIR/wsplgen-linux-64bit-static \
     $FLYS_SOURCE_DIR/river/artifacts/bin/wsplgen
 
-if [ "$BUILD_ORACLE" = "TRUE" ]; then
-    mvn -f $FLYS_SOURCE_DIR/river/backend/pom-oracle.xml clean compile install
-    mvn -f $FLYS_SOURCE_DIR/river/artifacts/pom-oracle.xml \
-        package assembly:single
-else
-    mvn -f $FLYS_SOURCE_DIR/river/artifacts/pom.xml package assembly:single
-fi
+mvn -f $FLYS_SOURCE_DIR/river/artifacts/pom.xml package assembly:single
 mvn -f $FLYS_SOURCE_DIR/river/gwt-client/pom.xml clean compile package
 
 
diff -r b57b236c4f4e -r 3847836c60b5 docker/Dockerfile.artifacts
--- a/docker/Dockerfile.artifacts	Mon Feb 06 16:57:03 2023 +0100
+++ b/docker/Dockerfile.artifacts	Tue Feb 07 16:11:43 2023 +0100
@@ -32,6 +32,8 @@
 
 ADD . river
 
+# If ORACLE=true, the oracle profile in the POM is activated
+ARG ORACLE
 RUN mvn -q -DskipTests -f river/backend/pom.xml install
 
 WORKDIR river/artifacts
diff -r b57b236c4f4e -r 3847836c60b5 docker/README
--- a/docker/README	Mon Feb 06 16:57:03 2023 +0100
+++ b/docker/README	Tue Feb 07 16:11:43 2023 +0100
@@ -14,6 +14,10 @@
 port 8080 (e.g. http://your-host:8080).
 See docker/flys_user_file for credentials.
 
+In case an Oracle database should be used, the server service has to be
+build with a build-time argument:
+
+$ docker-compose build --build-arg ORACLE=true server
 
 Remote debugging:
 


More information about the Dive4Elements-commits mailing list