Skip to content

Commit

Permalink
Issue #7: Add Maven assembly to create binary distribution for UCanAc…
Browse files Browse the repository at this point in the history
…cess console
  • Loading branch information
spannm committed Mar 18, 2024
1 parent b1a5145 commit 3b73047
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@

<developerId>spannm</developerId>

<ucanaccess.console.main>net.ucanaccess.console.Main</ucanaccess.console.main>

<dep.jackcess.artifcactId>jackcess</dep.jackcess.artifcactId>
<dep.jackcess.version>5.0.0-SNAPSHOT</dep.jackcess.version>

Expand Down Expand Up @@ -268,6 +270,29 @@
</plugins>
</pluginManagement>

<!-- mvn org.apache.maven.plugins:maven-assembly-plugin:single@distrib-zip-assembly -->
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/distrib-zip-assembly.xml</descriptor>
</descriptors>
<finalName>${project.artifactId}-${project.version}-bin</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>distrib-zip-assembly</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>

</build>

<profiles>
Expand Down
24 changes: 24 additions & 0 deletions src/main/assembly/console.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@ECHO OFF
SET PATH=%PATH%;.
SET BASE_DIR=%~f0

:CONT
SET RMVD=%BASE_DIR:~-1%
SET BASE_DIR=%BASE_DIR:~0,-1%
if NOT "%RMVD%"=="\" goto CONT

SET UCANACCESS_HOME=%BASE_DIR%
SET LOCAL_HOME_JAVA="%JAVA_HOME%"
IF EXIST %LOCAL_HOME_JAVA%\bin\java.exe (
SET LOCAL_JAVA=%LOCAL_HOME_JAVA%\bin\java.exe
) ELSE (
SET LOCAL_JAVA=java.exe
)

%LOCAL_JAVA% -version
@ECHO.

SET CLASSPATH="%UCANACCESS_HOME%\ucanaccess-${project.version}.jar;%UCANACCESS_HOME%\lib\hsqldb-${dep.hsqldb.version}.jar;%UCANACCESS_HOME%\lib\jackcess-${dep.jackcess.version}.jar"

%LOCAL_JAVA% -classpath %CLASSPATH% ${ucanaccess.console.main}
PAUSE
13 changes: 13 additions & 0 deletions src/main/assembly/console.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

UCANACCESS_HOME=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
echo $UCANACCESS_HOME

CLASSPATH="$UCANACCESS_HOME/ucanaccess-${project.version}.jar:$UCANACCESS_HOME/lib/hsqldb-${dep.hsqldb.version}.jar:$UCANACCESS_HOME/lib/jackcess-${dep.jackcess.version}.jar"

if [ -d "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
JAVACMD="$JAVA_HOME/bin/java"
else
JAVACMD=java
fi

"$JAVACMD" -cp $CLASSPATH ${ucanaccess.console.main}
42 changes: 42 additions & 0 deletions src/main/assembly/distrib-zip-assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 http://maven.apache.org/xsd/assembly-2.2.0.xsd">

<id>distrib-zip-assembly</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>${project.build.directory}/${project.artifactId}-${project.version}.jar</source>
<outputDirectory>/</outputDirectory>
</file>
<file>
<source>LICENSE.txt</source>
<outputDirectory>/</outputDirectory>
</file>
<file>
<source>src/main/assembly/console.bat</source>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
<fileMode>0755</fileMode>
</file>
<file>
<source>src/main/assembly/console.sh</source>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
<fileMode>0755</fileMode>
</file>
</files>

<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveDependencies>false</useTransitiveDependencies>
</dependencySet>
</dependencySets>

</assembly>

0 comments on commit 3b73047

Please sign in to comment.