Skip to content

Commit

Permalink
[sre] Create a CLI launcher for Janus.
Browse files Browse the repository at this point in the history
see #439
see #513

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Oct 11, 2016
1 parent e1069d5 commit a18cd8c
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
141 changes: 141 additions & 0 deletions sre/io.janusproject/io.janusproject.kernel/pom.xml
Expand Up @@ -11,6 +11,11 @@
<artifactId>io.janusproject.kernel</artifactId>
<name>Janus Platform for Maven</name>
<version>2.0.5.0-SNAPSHOT</version>

<properties>
<cliRunnerName>janus</cliRunnerName>
<cliRunnerMainClass>io.janusproject.Boot</cliRunnerMainClass>
</properties>

<dependencies>
<dependency>
Expand Down Expand Up @@ -75,6 +80,11 @@
<descriptors>
<descriptor>with-dependencies.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>${cliRunnerMainClass}</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
Expand All @@ -86,6 +96,137 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-janus-win</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<outfile>${project.build.directory}/${cliRunnerName}.exe</outfile>
<jar>${project.build.directory}/${project.build.finalName}-with-dependencies.jar</jar>
<icon>${project.basedir}/icons/janus.ico</icon>
<classPath>
<mainClass>${cliRunnerMainClass}</mainClass>
<addDependencies>false</addDependencies>
</classPath>
<jre>
<minVersion>${compiler.level}.0</minVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
<versionInfo>
<fileVersion>${janus.release_version}</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>${cliRunnerName}</fileDescription>
<copyright>${copyrighters}</copyright>
<productVersion>${janus.release_version}</productVersion>
<txtProductVersion>${project.version}</txtProductVersion>
<productName>${cliRunnerName}</productName>
<internalName>${cliRunnerName}</internalName>
<originalFilename>${cliRunnerName}.exe</originalFilename>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-janus-linux</id>
<phase>package</phase>
<configuration>
<target>
<property name="janus.linux.input"
value="${project.basedir}/src-templates/janus.sh" />
<property name="janus.linux.output" value="${project.build.directory}/janus.tmp" />
<property name="janus.linux.output.full" value="${project.build.directory}/janus" />
<copy overwrite="true" file="${janus.linux.input}" tofile="${janus.linux.output}" />
<replace file="${janus.linux.output}" token="{cliRunnerMainClass}"
value="${cliRunnerMainClass}" />
<replace file="${janus.linux.output}" token="{project.build.finalName}"
value="${project.build.finalName}" />
<concat dest="${janus.linux.output.full}" binary="yes">
<fileset file="${janus.linux.output}" />
<fileset
file="${project.build.directory}/${project.build.finalName}-with-dependencies.jar" />
</concat>
<chmod perm="ugo+x">
<fileset file="${janus.linux.output.full}" />
</chmod>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>sh.tak.appbundler</groupId>
<artifactId>appbundle-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-janus-osx</id>
<goals>
<goal>bundle</goal>
</goals>
<configuration>
<mainClass>${cliRunnerMainClass}</mainClass>
<iconFile>/icons/janus.icns</iconFile>
<generateDiskImageFile>true</generateDiskImageFile>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>remove-default-project-artifact</id>
<phase>verify</phase>
<goals>
<goal>remove-project-artifact</goal>
</goals>
<configuration>
<removeAll>true</removeAll>
</configuration>
</execution>
<execution>
<id>add-native-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${cliRunnerName}.exe</file>
<type>exe</type>
<classifier></classifier>
</artifact>
<artifact>
<file>${project.build.directory}/${cliRunnerName}</file>
<type>sh</type>
<classifier></classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>

</plugins>

</build>
Expand Down
17 changes: 17 additions & 0 deletions sre/io.janusproject/io.janusproject.kernel/src-templates/janus.sh
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

MYSELF=`readlink -f "$0"`
CDIR=`dirname "$MYSELF"`

JAVA=java
if [ -n "$JAVA_HOME" ]; then
JAVA="$JAVA_HOME/bin/java"
fi

if ( which $JAVA 2>&1 > /dev/null ); then
exec $JAVA -jar "$MYSELF" "{cliRunnerMainClass}" --nologo "$@"
else
echo "Cannot find Java, please set your JAVA_HOME"
fi

exit 255

0 comments on commit a18cd8c

Please sign in to comment.