Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nativecompile #693

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,44 @@ concurrency:
cancel-in-progress: true

jobs:
nativeimage:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 21.0.2
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
- run: ./gradlew nativeCompile
- name: Upload to GitHub workflow artifacts store
uses: actions/upload-artifact@v4
with:
name: JabRef-native-image-${{ matrix.os }}
path: build/native/nativeCompile
compression-level: 0 # no compression
- name: Check image (win)
if: (matrix.os == 'windows-latest')
run: |
cd build/native/nativeCompile
./JabRef.exe --help
- name: Check image (linux, macOS)
if: (matrix.os != 'windows-latest')
run: |
cd build/native/nativeCompile
./JabRef --help
build:
strategy:
fail-fast: false
Expand Down
43 changes: 42 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ plugins {
id 'idea'

id 'org.openrewrite.rewrite' version '6.16.4'

id 'org.graalvm.buildtools.native' version '0.10.2'
}

// Enable following for debugging
Expand All @@ -56,7 +58,7 @@ java {
// - .github/workflows/deployment-jdk-ea.yml#L53
languageVersion = JavaLanguageVersion.of(21)
// See https://docs.gradle.org/current/javadoc/org/gradle/jvm/toolchain/JvmVendorSpec.html for a full list
// vendor = JvmVendorSpec.AMAZON
vendor = JvmVendorSpec.GRAAL_VM
}
}

Expand Down Expand Up @@ -856,3 +858,42 @@ jmh {
iterations = 10
fork = 2
}

// Source: https://github.com/tinylog-org/tinylog/issues/145#issuecomment-603430594
task generateConfiguration(type: Exec) {
group = "graal"
description = "Run application to generate the configuration for native image"
dependsOn assemble
commandLine project.gradle.gradleUserHomeDir.toPath().resolve("jdks/graalvm_community-21-amd64-windows/graalvm-community-openjdk-21.0.2+13.1/bin/java"), "-agentlib:native-image-agent=config-output-dir=" + project.buildDir.toPath().resolve("resources/main/META-INF/native-image"), "-cp", sourceSets.main.runtimeClasspath.getAsPath(), 'org.jabref.Launcher'

doFirst {
mkdir project.buildDir.toPath().resolve("resources/main/META-INF/native-image")
}
}


graalvmNative {
// toolchainDetection = true
binaries {
main {
imageName = "JabRef"
mainClass = "org.jabref.Launcher"
buildArgs.add("-O4")
}
test {
buildArgs.add("-O0")
}
}
binaries.configureEach {
buildArgs.add("-H:+AddAllCharsets")
// buildArgs.add("-H:IncludeResources=*.bst|*.xml|*.csl|*.jks)
buildArgs.add("--allow-incomplete-classpath")
buildArgs.add("--verbose")
buildArgs.add("--initialize-at-run-time=org.tinylog,org.slf4j")
resources.autodetect()
javaLauncher.set(javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
vendor = JvmVendorSpec.GRAAL_VM
})
}
}
Loading