Skip to content

Commit

Permalink
gradle: add native-image plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pjonsson committed Sep 12, 2023
1 parent 1678d19 commit e0ebff4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 23 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// sudo apt install libfreetype-dev
plugins {
id 'application'
id 'application'
id 'org.graalvm.buildtools.native' version '0.9.26'
}

group = 'org.contikios.cooja'
Expand Down Expand Up @@ -70,6 +72,26 @@ application {
'--enable-preview', '--enable-native-access', 'ALL-UNNAMED']
}

graalvmNative {
binaries {
main {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(javaVersion)
vendor = JvmVendorSpec.matching("Oracle Corporation")
}
fallback = true
useFatJar = true
buildArgs.add('--enable-preview')
buildArgs.add('--report-unsupported-elements-at-runtime')
}
}
}

tasks.named("nativeCompile") {
dependsOn fullJar
classpathJar = layout.buildDirectory.file("libs/cooja-full.jar")
}

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['--enable-preview',
"-Aproject=${project.group}/${project.name}"]
Expand Down
6 changes: 6 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}
Expand Down

0 comments on commit e0ebff4

Please sign in to comment.