Skip to content

Commit

Permalink
Merge pull request #225 from semuxgo/pack-jvm
Browse files Browse the repository at this point in the history
Pack pre-built OpenJDK binaries
  • Loading branch information
semuxgo authored Jul 18, 2019
2 parents 07a0094 + d3a30ee commit 6c09567
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 142 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ More info can be found at our [Documentation page](./docs/README.md).

## Get started

1. Download and install [OpenJDK Runtime Environment](https://adoptopenjdk.net/) (**x64 required**)
2. *(Windows user) Download and install [Microsoft Visual C++ 2012 Redistributable Package](https://www.microsoft.com/en-us/download/details.aspx?id=30679) (**x64 required**)*
3. Download the [Latest Release](https://github.com/semuxproject/semux-core/releases) and unpack to a desired directory.
4. Run ``semux.exe`` if you're on Windows; run ``./semux-gui.sh`` or ``./semux-cli.sh`` if you're on Linux or macOS.
1. Download the [Latest Release](https://github.com/semuxproject/semux-core/releases) and unpack it to a desired directory.
2. Run `semux-gui.bat` if you're on Windows, or `./semux-gui.sh` if you're on Linux or macOS.
3. *(Windows user) You may need to download and install [Microsoft Visual C++ 2012 Redistributable Package](https://www.microsoft.com/en-us/download/details.aspx?id=30679) (**x64 required**)*


## Build from source
Expand Down
75 changes: 15 additions & 60 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
<Implementation-Version>${git.commit.id.abbrev}</Implementation-Version>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
</transformers>
Expand Down Expand Up @@ -252,62 +253,6 @@
</configuration>
</plugin>

<!-- build windows executable (currently GUI mode only) -->
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.25</version>
<executions>
<execution>
<id>semux</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<jar>${project.build.directory}/${project.artifactId}-${project.version}-shaded.jar</jar>
<outfile>${project.build.directory}/semux.exe</outfile>
<downloadUrl>http://www.oracle.com/technetwork/java/javase/downloads/index.html</downloadUrl>
<classPath>
<mainClass>org.semux.gui.SemuxGui</mainClass>
<preCp>anything</preCp>
</classPath>
<icon>src/main/resources/org/semux/gui/logo.ico</icon>
<splash>
<!-- this file must be a 24-bit BMP -->
<file>misc/design/splash.bmp</file>
<waitForWindow>true</waitForWindow>
<timeout>600</timeout>
<timeoutErr>true</timeoutErr>
</splash>
<jre>
<minVersion>1.8.0</minVersion>
<jdkPreference>preferJre</jdkPreference>
<maxHeapPercent>80</maxHeapPercent>
<opts>
<opt>-Dfile.encoding=UTF-8</opt>
</opts>
</jre>
<versionInfo>
<fileVersion>${dist.windowsExecutableVersion}</fileVersion>
<fileDescription>${project.description}</fileDescription>
<txtFileVersion>${project.version}</txtFileVersion>
<copyright>MIT</copyright>
<productVersion>${dist.windowsExecutableVersion}</productVersion>
<txtProductVersion>${project.version}</txtProductVersion>
<productName>semux</productName>
<internalName>semux</internalName>
<originalFilename>semux.exe</originalFilename>
</versionInfo>
<singleInstance>
<mutexName>semux</mutexName>
</singleInstance>
</configuration>
</execution>
</executions>
</plugin>

<!-- prepare distribution -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -345,20 +290,24 @@
<phase>${dist.phase}</phase>
<configuration>
<target>
<mkdir dir="${dist.base}/cache" />

<!-- windows build -->
<copy todir="${dist.base}/windows">
<fileset dir="${project.basedir}">
<include name="config/**" />
<include name="LICENSE*" />
</fileset>
<fileset dir="${project.basedir}/target">
<include name="semux.exe" />
</fileset>
</copy>
<copy file="${project.basedir}/misc/launch4j/semux.l4j.ini" tofile="${dist.base}/windows/semux.l4j.ini" />
<copy file="${project.basedir}/src/main/resources/org/semux/gui/splash.png" todir="${dist.base}/windows/resources" />
<copy file="${project.basedir}/target/semux-${project.version}-shaded.jar" tofile="${dist.base}/windows/semux.jar" />
<copy file="${project.basedir}/scripts/semux-cli.bat" tofile="${dist.base}/windows/semux-cli.bat" />
<copy file="${project.basedir}/scripts/semux-gui.bat" tofile="${dist.base}/windows/semux-gui.bat" />
<fixcrlf srcdir="${dist.base}/windows" includes="**/*.ini" eol="dos" eof="asis" />
<fixcrlf srcdir="${dist.base}/windows" includes="config/*" eol="dos" eof="asis" />
<fixcrlf srcdir="${dist.base}/windows" includes="LICENSE*" eol="dos" eof="asis" />
<get skipexisting="true" src="https://github.com/semuxproject/jvm/releases/download/v1.1.0/jvm-11-windows.zip" dest="${dist.base}/cache" />
<unzip src="${dist.base}/cache/jvm-11-windows.zip" dest="${dist.base}/windows" />

<!-- linux build (executable jar) -->
<copy todir="${dist.base}/linux">
Expand All @@ -375,6 +324,9 @@
<chmod file="${dist.base}/linux/semux*.sh" perm="755" />
<chmod dir="${dist.base}/linux/config" perm="700" />
<chmod file="${dist.base}/linux/config/*" perm="600" />
<get skipexisting="true" src="https://github.com/semuxproject/jvm/releases/download/v1.1.0/jvm-11-linux.tar.gz" dest="${dist.base}/cache" />
<untar compression="gzip" src="${dist.base}/cache/jvm-11-linux.tar.gz" dest="${dist.base}/linux" />
<chmod file="${dist.base}/linux/jvm/bin/*" perm="755" />

<!-- macos build -->
<copy todir="${dist.base}/macos">
Expand All @@ -391,6 +343,9 @@
<chmod file="${dist.base}/macos/semux*.sh" perm="755" />
<chmod dir="${dist.base}/macos/config" perm="700" />
<chmod file="${dist.base}/macos/config/*" perm="600" />
<get skipexisting="true" src="https://github.com/semuxproject/jvm/releases/download/v1.1.0/jvm-11-macos.tar.gz" dest="${dist.base}/cache" />
<untar compression="gzip" src="${dist.base}/cache/jvm-11-macos.tar.gz" dest="${dist.base}/macos" />
<chmod file="${dist.base}/macos/jvm/bin/*" perm="755" />
</target>
</configuration>
<goals>
Expand Down
9 changes: 3 additions & 6 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,21 @@ WINDIST=${name}-windows-${version}
WINBALL=${WINDIST}.zip
mv windows ${WINDIST}
zip -r ${WINBALL} ${WINDIST} || exit
sha256sum ${WINBALL} > ${WINDIST}.sha256
sha256sum --check ${WINDIST}.sha256

# Linux
LINUXDIST=${name}-linux-${version}
LINUXBALL=${name}-linux-${version}.tar.gz
mv linux ${LINUXDIST}
tar -czvf ${LINUXBALL} ${LINUXDIST} || exit
sha256sum ${LINUXBALL} > ${LINUXDIST}.sha256
sha256sum --check ${LINUXDIST}.sha256

# macOS
MACDIST=${name}-macos-${version}
MACBALL=${name}-macos-${version}.tar.gz
mv macos ${MACDIST}
tar -czvf ${MACBALL} ${MACDIST} || exit
sha256sum ${MACBALL} > ${MACDIST}.sha256
sha256sum --check ${MACDIST}.sha256

# Checksum
sha256sum *.tar.gz *.zip > sha256.txt

# clean
rm -r ${name}-windows-${version}
Expand Down
8 changes: 8 additions & 0 deletions scripts/semux-cli.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off

set java_bin=.\jvm\bin\java

%java_bin% -cp semux.jar org.semux.JvmOptions --cli > jvm_options.txt
set /p jvm_options=<jvm_options.txt

%java_bin% %jvm_options% -cp semux.jar org.semux.Main --cli %*
7 changes: 5 additions & 2 deletions scripts/semux-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
# change work directory
cd "$(dirname "$0")"

# Java binary
java_bin=./jvm/bin/java

# default JVM options
jvm_options=`java -cp semux.jar org.semux.JvmOptions --cli`
jvm_options=`${java_bin} -cp semux.jar org.semux.JvmOptions --cli`

# start kernel
java ${jvm_options} -cp semux.jar org.semux.Main --cli "$@"
${java_bin} ${jvm_options} -cp semux.jar org.semux.Main --cli "$@"
8 changes: 8 additions & 0 deletions scripts/semux-gui.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off

set java_bin=.\jvm\bin\java

%java_bin% -cp semux.jar org.semux.JvmOptions --gui > jvm_options.txt
set /p jvm_options=<jvm_options.txt

%java_bin% %jvm_options% -cp semux.jar org.semux.Main --gui %*
8 changes: 6 additions & 2 deletions scripts/semux-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
# change work directory
cd "$(dirname "$0")"

# Java binary
java_bin=./jvm/bin/java

# default JVM options
jvm_options=`java -cp semux.jar org.semux.JvmOptions --gui`
jvm_options=`${java_bin} -cp semux.jar org.semux.JvmOptions --gui`

# start kernel
java ${jvm_options} -cp semux.jar org.semux.Main --gui "$@"
${java_bin} ${jvm_options} -cp semux.jar org.semux.Main --gui "$@"

56 changes: 0 additions & 56 deletions src/test/java/org/semux/windows/Launch4jWrapperIT.java

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/java/org/semux/windows/WindowsIntegrationTest.java

This file was deleted.

0 comments on commit 6c09567

Please sign in to comment.