Move to Gradle Application plugin

Use the Gradle Application plugin to generate the distribution. This has
a number of advantages including much simpler Gradle configuration,
elimination of Plexus Classworlds bootstrap, more mature/tested launch
scripts.
There are some differences in the generated archives including
incorporation of a base path in all files names (probably a good thing),
elimination of /bin/extract* launch scripts (unlikely to be used any
more), and creation of a tar instead of tgz (not a major issue).
This commit is contained in:
Brett Henderson
2023-06-02 22:24:03 +10:00
parent 85bb5cc01c
commit cfb17a8e0e
37 changed files with 27 additions and 325 deletions

View File

@ -1 +1 @@
../../../package/script
../../../osmosis/src/dist/script

View File

@ -9,7 +9,7 @@ apply plugin: 'idea'
/* Build collections containing each type of project. These collections will
* be used to apply common configurations to projects of the same type.
*/
def packageProjects = allprojects.findAll { project -> project.path.equals(':package') }
def packageProjects = allprojects.findAll { project -> project.path.equals(':osmosis') }
def buildProjects = allprojects.findAll { project -> project.path.equals(':build-support') }
def dockerProjects = allprojects.findAll { project -> project.path.equals(':db-server') }
// Java projects are all those that aren't in the previous collections.

View File

@ -1,5 +1,3 @@
.project
.settings
/build
/lib

24
osmosis/build.gradle Normal file
View File

@ -0,0 +1,24 @@
plugins {
id 'application'
}
application {
mainClass = 'org.openstreetmap.osmosis.core.Osmosis'
}
dependencies {
implementation project(':osmosis-apidb')
implementation project(':osmosis-areafilter')
implementation project(':osmosis-core')
implementation project(':osmosis-dataset')
implementation project(':osmosis-extract')
implementation project(':osmosis-pbf')
implementation project(':osmosis-pbf2')
implementation project(':osmosis-pgsimple')
implementation project(':osmosis-pgsnapshot')
implementation project(':osmosis-replication')
implementation project(':osmosis-set')
implementation project(':osmosis-tagfilter')
implementation project(':osmosis-tagtransform')
implementation project(':osmosis-xml')
}

View File

@ -1,94 +0,0 @@
#!/bin/sh
# Config files can define several variables used throughout this script.
# JAVACMD - The java command to launch osmosis.
# JAVACMD_OPTIONS - The options to append to the java command, typically used to modify jvm settings such as max memory.
# OSMOSIS_OPTIONS - The options to apply to all osmosis invocations, typically used to add plugins or make quiet operation the default.
if [ -f /etc/osmosis ] ; then
. /etc/osmosis
fi
if [ -f "$HOME/.osmosis" ] ; then
. "$HOME/.osmosis"
fi
if [ -z "$JAVACMD" ] ; then
# No JAVACMD provided in osmosis config files, therefore default to java
JAVACMD=java
fi
## resolve links - $0 may be a link to application
PRG="$0"
# if started without absolute path, but from PATH environment
if [ ! -s "$PRG" ] ; then
PRG=`which $PRG`
fi
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
if [ "x$1x" = "xx" ] || echo "$@" | grep -q -e '--help' ; then
cat <<EOF
osmosis
Example Usage
Import a planet file into a local PostgreSQL database.
osmosis --read-xml file=~/osm/planbet/planet.osm --write-apidb host="x" database="x" user="x" password="x"
Export a planet file from a local PostgreSQL database.
osmosis --read-apidb host="x" database="x" user="x" password="x" --write-xml file="planet.osm"
Derive a change set between two planet files.
osmosis --read-xml file="planet2.osm" --read-xml file="planet1.osm" --derive-change --write-xml-change file="planetdiff-1-2.osc"
Derive a change set between a planet file and a database.
osmosis --read-mysql host="x" database="x" user="x" password="x" --read-xml file="planet1.osm" --derive-change --write-xml-change file="planetdiff-1-2.osc"
Apply a change set to a planet file.
osmosis --read-xml-change file="planetdiff-1-2.osc" --read-xml file="planet1.osm" --apply-change --write-xml file="planet2.osm"
Sort the contents of a planet file.
osmosis --read-xml file="data.osm" --sort type="TypeThenId" --write-xml file="data-sorted.osm"
The above examples make use of the default pipe connection feature, however a simple read and write planet file command line could be written in two ways. The first example uses default pipe connection, the second explicitly connects the two components using a pipe named "mypipe". The default pipe connection will always work so long as each task is specified in the correct order.
osmosis --read-xml file="planetin.osm" --write-xml file="planetout.osm"
osmosis --read-xml file="planetin.osm" outPipe.0="mypipe" --write-xml file="planetout.osm" inPipe.0="mypipe"
Full usage details are available at: http://wiki.openstreetmap.org/wiki/Osmosis/Detailed_Usage
EOF
exit 1
fi
# make it fully qualified
saveddir=`pwd`
MYAPP_HOME=`dirname "$PRG"`/..
MYAPP_HOME=`cd "$MYAPP_HOME" && pwd`
cd "$saveddir"
# Build up the classpath of required jar files via classworlds launcher.
MYAPP_CLASSPATH=$MYAPP_HOME/lib/default/plexus-classworlds-*.jar
MAINCLASS=org.codehaus.classworlds.Launcher
EXEC="$JAVACMD $JAVACMD_OPTIONS -cp $MYAPP_CLASSPATH -Dapp.home=$MYAPP_HOME -Dclassworlds.conf=$MYAPP_HOME/config/plexus.conf $MAINCLASS $OSMOSIS_OPTIONS"
exec $EXEC "$@"

View File

@ -1,54 +0,0 @@
#!/bin/sh
# Config files can define several variables used throughout this script.
# JAVACMD - The java command to launch osmosis.
# JAVACMD_OPTIONS - The options to append to the java command, typically used to modify jvm settings such as max memory.
if [ -f /etc/osmosis ] ; then
. /etc/osmosis
fi
if [ -f "$HOME/.osmosis" ] ; then
. "$HOME/.osmosis"
fi
if [ -z "$JAVACMD" ] ; then
# No JAVACMD provided in osmosis config files, therefore default to java
JAVACMD=java
fi
## resolve links - $0 may be a link to application
PRG="$0"
# if started without absolute path, but from PATH environment
if [ ! -s "$PRG" ] ; then
PRG=`which $PRG`
fi
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
# make it fully qualified
saveddir=`pwd`
MYAPP_HOME=`dirname "$PRG"`/..
MYAPP_HOME=`cd "$MYAPP_HOME" && pwd`
cd "$saveddir"
# Build up the classpath of required jar files.
MYAPP_CLASSPATH=$MYAPP_HOME/osmosis.jar:$OSMOSIS_CLASSPATH
for FILE in `ls $MYAPP_HOME/lib/default/`; do
MYAPP_CLASSPATH=$MYAPP_CLASSPATH:$MYAPP_HOME/lib/default/$FILE
done
MAINCLASS=org.openstreetmap.osmosis.extract.apidb.v0_6.OsmosisExtractApiDb
EXEC="$JAVACMD $JAVACMD_OPTIONS -cp $MYAPP_CLASSPATH $MAINCLASS $@"
exec $EXEC

View File

@ -1,54 +0,0 @@
#!/bin/sh
# Config files can define several variables used throughout this script.
# JAVACMD - The java command to launch osmosis.
# JAVACMD_OPTIONS - The options to append to the java command, typically used to modify jvm settings such as max memory.
if [ -f /etc/osmosis ] ; then
. /etc/osmosis
fi
if [ -f "$HOME/.osmosis" ] ; then
. "$HOME/.osmosis"
fi
if [ -z "$JAVACMD" ] ; then
# No JAVACMD provided in osmosis config files, therefore default to java
JAVACMD=java
fi
## resolve links - $0 may be a link to application
PRG="$0"
# if started without absolute path, but from PATH environment
if [ ! -s "$PRG" ] ; then
PRG=`which $PRG`
fi
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
# make it fully qualified
saveddir=`pwd`
MYAPP_HOME=`dirname "$PRG"`/..
MYAPP_HOME=`cd "$MYAPP_HOME" && pwd`
cd "$saveddir"
# Build up the classpath of required jar files.
MYAPP_CLASSPATH=$MYAPP_HOME/osmosis.jar:$OSMOSIS_CLASSPATH
for FILE in `ls $MYAPP_HOME/lib/default/`; do
MYAPP_CLASSPATH=$MYAPP_CLASSPATH:$MYAPP_HOME/lib/default/$FILE
done
MAINCLASS=org.openstreetmap.osmosis.extract.mysql.v0_6.OsmosisExtractMysql
EXEC="$JAVACMD $JAVACMD_OPTIONS -cp $MYAPP_CLASSPATH $MAINCLASS $@"
exec $EXEC

View File

@ -1,41 +0,0 @@
@ECHO OFF
REM This is an equivalent Windows batch file to complement the unix shell script
REM Corresponding lines from the shell script are printed before the matching batch file commands
REM # Config files can define several variables used throughout this script.
REM # JAVACMD - The java command to launch osmosis.
REM # JAVACMD_OPTIONS - The options to append to the java command, typically used to modify jvm settings such as max memory.
REM # OSMOSIS_OPTIONS - The options to apply to all osmosis invocations, typically used to add plugins or make quiet operation the default.
REM if [ -f /etc/osmosis ] ; then
REM . /etc/osmosis
REM fi
IF EXIST "%ALLUSERSPROFILE%\osmosis.bat" CALL "%ALLUSERSPROFILE%\osmosis.bat"
REM if [ -f "$HOME/.osmosis" ] ; then
REM . "$HOME/.osmosis"
REM fi
IF EXIST "%USERPROFILE%\osmosis.bat" CALL "%USERPROFILE%\osmosis.bat"
REM if [ -z "$JAVACMD" ] ; then
REM # No JAVACMD provided in osmosis config files, therefore default to java
REM JAVACMD=java
REM fi
IF "%JAVACMD%"=="" set JAVACMD=java
REM Set "SAVEDIR" to the current directory
set SAVEDIR=%CD%
set MYAPP_HOME=%~dp0..
REM Now make the MYAPP_HOME path absolute
cd /D %MYAPP_HOME%
set MYAPP_HOME=%CD%
REM Change back to the original directory
cd /D %SAVEDIR%
set MAINCLASS=org.codehaus.classworlds.Launcher
set PLEXUS_CP=%MYAPP_HOME%\lib\default\plexus-classworlds-2.5.2.jar
SET EXEC="%JAVACMD%" %JAVACMD_OPTIONS% -cp "%PLEXUS_CP%" -Dapp.home="%MYAPP_HOME%" -Dclassworlds.conf="%MYAPP_HOME%\config\plexus.conf" %MAINCLASS% %OSMOSIS_OPTIONS% %*
%EXEC%

View File

@ -1,72 +0,0 @@
configurations {
runtime
archives
}
dependencies {
runtime project(':osmosis-apidb')
runtime project(':osmosis-areafilter')
runtime project(':osmosis-core')
runtime project(':osmosis-dataset')
runtime project(':osmosis-extract')
runtime project(':osmosis-pbf')
runtime project(':osmosis-pbf2')
runtime project(':osmosis-pgsimple')
runtime project(':osmosis-pgsnapshot')
runtime project(':osmosis-replication')
runtime project(':osmosis-set')
runtime project(':osmosis-tagfilter')
runtime project(':osmosis-tagtransform')
runtime project(':osmosis-xml')
runtime group: 'org.codehaus.plexus', name: 'plexus-classworlds', version: dependencyVersionClassworlds
}
task syncLibs(type: Sync) {
into "lib/default"
from configurations.runtime
}
def artefactPrefix = 'osmosis-' + version
task distZip(type: Zip) {
description = 'Builds a zip file containing a self-contained distribution of the application.'
archiveFileName = artefactPrefix + '.zip'
destinationDirectory = new File(projectDir, 'build/distribution')
from('.') {
exclude 'build*'
exclude 'ivy.xml'
exclude '.*'
}
}
distZip.dependsOn syncLibs
task distTgz(type: Tar) {
description = 'Builds a tgz file containing a self-contained distribution of the application.'
archiveFileName = artefactPrefix + '.tgz'
destinationDirectory = new File(projectDir, 'build/distribution')
compression = Compression.GZIP
from('.') {
exclude 'build*'
exclude 'ivy.xml'
exclude '.*'
}
}
distTgz.dependsOn syncLibs
task assemble {
description = 'Generates a working application directory structure.'
}
assemble.dependsOn distZip, distTgz
task build {
description = 'Assembles and tests this project.'
}
build.dependsOn assemble
task clean(type: Delete) {
delete 'build'
}
artifacts {
archives distZip, distTgz
}

View File

@ -1,5 +0,0 @@
main is org.openstreetmap.osmosis.core.Osmosis from osmosis.core
[osmosis.core]
load ${app.home}/lib/default/*.jar
load ${app.home}/config

View File

@ -1,4 +1,5 @@
include 'build-support'
include 'osmosis'
include 'osmosis-areafilter'
include 'osmosis-apidb'
include 'osmosis-core'
@ -15,4 +16,3 @@ include 'osmosis-tagfilter'
include 'osmosis-tagtransform'
include 'osmosis-testutil'
include 'osmosis-xml'
include 'package'