Skip to content

Commit

Permalink
use GraalVM for JDK 17 & 21
Browse files Browse the repository at this point in the history
  • Loading branch information
chirontt committed Nov 1, 2023
1 parent 44ebf10 commit a477bbe
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 129 deletions.
63 changes: 50 additions & 13 deletions .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
java-version: [11, 17]
graalvm-version: ['22.3.2']
java-version: [17, 21]
graalvm-distribution: ['graalvm-community']
fail-fast: false

Expand All @@ -34,33 +33,50 @@ jobs:
- name: Download Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Linux)
if: runner.os == 'Linux' && matrix.java-version == 17
run: |
download_url="https://download.bell-sw.com/vm/23.0.0/bellsoft-liberica-vm-core-openjdk17.0.7+7-23.0.0+1-linux-amd64.tar.gz"
download_url="https://download.bell-sw.com/vm/23.0.2/bellsoft-liberica-vm-core-openjdk17.0.9+11-23.0.2+1-linux-amd64.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- name: Download Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Linux)
if: runner.os == 'Linux' && matrix.java-version == 21
run: |
download_url="https://download.bell-sw.com/vm/23.1.1/bellsoft-liberica-vm-core-openjdk21.0.1+12-23.1.1+1-linux-amd64.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- name: Download Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Windows)
if: runner.os == 'Windows' && matrix.java-version == 21
shell: cmd
run: |
set download_url="https://download.bell-sw.com/vm/23.1.1/bellsoft-liberica-vm-core-openjdk21.0.1+12-23.1.1+1-windows-amd64.zip"
C:\msys64\usr\bin\wget.exe -O %RUNNER_TEMP%\java_package.zip %download_url%
- name: Set up Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Linux)
if: runner.os == 'Linux' && matrix.java-version == 17
if: runner.os == 'Linux'
uses: actions/setup-java@v3
with:
distribution: jdkfile
java-version: ${{ matrix.java-version }}
jdkFile: ${{ runner.temp }}/java_package.tar.gz
architecture: x64

- name: Set up GraalVM ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }}
if: runner.os != 'Linux' && matrix.java-version == 17
uses: graalvm/setup-graalvm@v1
- name: Set up Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Windows)
if: runner.os == 'Windows' && matrix.java-version == 21
uses: actions/setup-java@v3
with:
distribution: jdkfile
java-version: ${{ matrix.java-version }}
distribution: ${{ matrix.graalvm-distribution }}
components: 'native-image'
jdkFile: ${{ runner.temp }}/java_package.zip
architecture: x64

- name: Set up a Developer Command Prompt for Microsoft Visual C++ (Windows)
if: runner.os == 'Windows' && matrix.java-version == 21
uses: ilammy/msvc-dev-cmd@v1

- name: Set up GraalVM ${{ matrix.graalvm-version }} for Java 11
if: matrix.java-version == 11
- name: Set up GraalVM ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }}
if: runner.os == 'Windows' && matrix.java-version == 17
uses: graalvm/setup-graalvm@v1
with:
java-version: ${{ matrix.java-version }}
version: ${{ matrix.graalvm-version }}
components: 'native-image'
distribution: ${{ matrix.graalvm-distribution }}

- name: Report Java version
run: |
Expand All @@ -83,3 +99,24 @@ jobs:
.\gradlew.bat --no-daemon --info nativeCompile
if: runner.os == 'Windows'

- name: Package Linux artifacts
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: SwingSet3 ${{ runner.os }} native image with SubstrateVM for Java ${{ matrix.java-version }}
path: |
trunk/SwingSet3/build/native/nativeCompile/
!trunk/SwingSet3/build/native/nativeCompile/reports
!trunk/SwingSet3/build/native/nativeCompile/sources
- name: Package Windows artifacts
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: SwingSet3 ${{ runner.os }} native image with SubstrateVM for Java ${{ matrix.java-version }}
path: |
trunk/SwingSet3/build/native/nativeCompile/
!trunk/SwingSet3/build/native/nativeCompile/native-image-*.args
!trunk/SwingSet3/build/native/nativeCompile/reports
!trunk/SwingSet3/build/native/nativeCompile/sources
56 changes: 29 additions & 27 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
java-version: [11, 17]
graalvm-version: ['22.3.2']
java-version: [17, 21]
graalvm-distribution: ['graalvm-community']
fail-fast: false

Expand All @@ -24,33 +23,50 @@ jobs:
- name: Download Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Linux)
if: runner.os == 'Linux' && matrix.java-version == 17
run: |
download_url="https://download.bell-sw.com/vm/23.0.0/bellsoft-liberica-vm-core-openjdk17.0.7+7-23.0.0+1-linux-amd64.tar.gz"
download_url="https://download.bell-sw.com/vm/23.0.2/bellsoft-liberica-vm-core-openjdk17.0.9+11-23.0.2+1-linux-amd64.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- name: Download Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Linux)
if: runner.os == 'Linux' && matrix.java-version == 21
run: |
download_url="https://download.bell-sw.com/vm/23.1.1/bellsoft-liberica-vm-core-openjdk21.0.1+12-23.1.1+1-linux-amd64.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- name: Download Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Windows)
if: runner.os == 'Windows' && matrix.java-version == 21
shell: cmd
run: |
set download_url="https://download.bell-sw.com/vm/23.1.1/bellsoft-liberica-vm-core-openjdk21.0.1+12-23.1.1+1-windows-amd64.zip"
C:\msys64\usr\bin\wget.exe -O %RUNNER_TEMP%\java_package.zip %download_url%
- name: Set up Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Linux)
if: runner.os == 'Linux' && matrix.java-version == 17
if: runner.os == 'Linux'
uses: actions/setup-java@v3
with:
distribution: jdkfile
java-version: ${{ matrix.java-version }}
jdkFile: ${{ runner.temp }}/java_package.tar.gz
architecture: x64

- name: Set up GraalVM ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }}
if: runner.os != 'Linux' && matrix.java-version == 17
uses: graalvm/setup-graalvm@v1
- name: Set up Liberica NIK ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }} (Windows)
if: runner.os == 'Windows' && matrix.java-version == 21
uses: actions/setup-java@v3
with:
distribution: jdkfile
java-version: ${{ matrix.java-version }}
distribution: ${{ matrix.graalvm-distribution }}
components: 'native-image'
jdkFile: ${{ runner.temp }}/java_package.zip
architecture: x64

- name: Set up a Developer Command Prompt for Microsoft Visual C++ (Windows)
if: runner.os == 'Windows' && matrix.java-version == 21
uses: ilammy/msvc-dev-cmd@v1

- name: Set up GraalVM ${{ matrix.graalvm-version }} for Java 11
if: matrix.java-version == 11
- name: Set up GraalVM ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }}
if: runner.os == 'Windows' && matrix.java-version == 17
uses: graalvm/setup-graalvm@v1
with:
java-version: ${{ matrix.java-version }}
version: ${{ matrix.graalvm-version }}
components: 'native-image'
distribution: ${{ matrix.graalvm-distribution }}

- name: Report Java version
run: |
Expand All @@ -73,17 +89,3 @@ jobs:
.\mvnw.cmd -V -B package
if: runner.os == 'Windows'

- name: Package Linux artifact
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: SwingSet3 ${{ runner.os }} native image with SubstrateVM for Java ${{ matrix.java-version }}
path: trunk/SwingSet3/target/native-image-linux/SwingSet3**

- name: Package Windows artifacts
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: SwingSet3 ${{ runner.os }} native image with SubstrateVM for Java ${{ matrix.java-version }}
path: trunk/SwingSet3/target/native-image-windows/

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
.vscode
bin
build
dependency-reduced-pom.xml
dist
target
2 changes: 1 addition & 1 deletion trunk/SwingSet3/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
42 changes: 6 additions & 36 deletions trunk/SwingSet3/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'application'
id 'org.graalvm.buildtools.native' version '0.9.23'
id 'org.graalvm.buildtools.native' version '0.9.28'
}

tasks.wrapper {
gradleVersion = '8.1.1'
gradleVersion = '8.4'
distributionType = Wrapper.DistributionType.ALL
}

Expand All @@ -16,7 +16,7 @@ ext {
mainClassName = 'com.github.chirontt.graalvm.swingset3.NativeSwingSet3'
splashImage = 'com/sun/swingset3/resources/images/splash.png'
currentPlatform = getCurrentPlatform()
nativeImageDirName = "native-image-$currentPlatform"
nativeImageDirName = "native/nativeCompile"
}

//detect the OS (assuming 64-bit, on Intel/AMD hardware)
Expand Down Expand Up @@ -123,34 +123,6 @@ task markWindowsGui(type: Exec) {
commandLine 'editbin.exe', '/subsystem:windows', file("$buildDir/$nativeImageDirName/${project.name}.exe").path
}

//remove unneeded .dll/.txt/.pdb files
task removeUnneededDllFiles {
doLast {
if (file("$buildDir/$nativeImageDirName").exists()) {
ant.move(todir: "$buildDir/tmp/$nativeImageDirName") {
fileset(dir: "$buildDir/$nativeImageDirName") {
include name: '*.dll'
include name: '*.pdb'
include name: '*.txt'
//keep the shim DLLs and some
exclude name: 'awt.dll'
exclude name: 'fontmanager.dll'
exclude name: 'java.dll'
exclude name: 'jvm.dll'
}
}
}
if (file("$buildDir/$nativeImageDirName/reports").exists()) {
ant.move(file: "$buildDir/$nativeImageDirName/reports",
tofile: "$buildDir/tmp/$nativeImageDirName/reports")
}
if (file("$buildDir/$nativeImageDirName/sources").exists()) {
ant.move(file: "$buildDir/$nativeImageDirName/sources",
tofile: "$buildDir/tmp/$nativeImageDirName/sources")
}
}
}

javadoc {
options.encoding = 'UTF-8'
//turn off doclint errors/warnings output (but some warnings are still in the output)
Expand All @@ -171,15 +143,14 @@ graalvmNative {
verbose = true
fallback = false

if (currentPlatform == 'linux') {
//if (currentPlatform == 'linux') {
systemProperties = ['java.awt.headless': 'false']
}
//}

buildArgs.add('--enable-url-protocols=http,https')
buildArgs.add('--report-unsupported-elements-at-runtime')
buildArgs.add('--native-image-info')
buildArgs.add("-H:Path=$buildDir/$nativeImageDirName")
buildArgs.add("-H:TempDirectory=$buildDir/tmp/$nativeImageDirName")
buildArgs.add('-march=compatibility') //only available in GraalVM for JDK 17+
buildArgs.add('-H:+TraceNativeToolUsage')

useFatJar = false
Expand All @@ -194,6 +165,5 @@ tasks.named("nativeCompile") {
if (currentPlatform == 'windows') {
finalizedBy copyFontConfigFiles, markWindowsGui
}
finalizedBy removeUnneededDllFiles
}

Binary file modified trunk/SwingSet3/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion trunk/SwingSet3/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 10 additions & 5 deletions trunk/SwingSet3/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down Expand Up @@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Loading

0 comments on commit a477bbe

Please sign in to comment.