Skip to content

Commit

Permalink
[misc] Add native image plugin (GraalVM) (#481)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Larsén <slarse@slar.se>
  • Loading branch information
wetneb and slarse committed Jan 29, 2024
1 parent c63df9d commit 5597cd6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,12 @@ Unless otherwise stated, files in Spork are under the [MIT license](LICENSE).
file is composed of code from
[gumtree-spoon-ast-diff](https://github.com/spoon/gumtree-spoon-ast-diff) and
is therefore individually licensed under Apache License 2.0.

## Experimental: compile as a native image

Spork can be compiled to a native executable file using [GraalVM](https://www.graalvm.org/).
To do so, you need to first install GraalVM's JDK for Java 17 (Spork does not support Java 21 yet, see [#479](https://github.com/ASSERT-KTH/spork/issues/479)).
Running `mvn package -P native` will then generate a native image in `target/spork`.

**Note:** the native image is known to behave differently to the `.jar` file, producing different conflict resolution results. Help to debug this would be welcome.

37 changes: 37 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<kotlin.version>1.7.10</kotlin.version>
<native.maven.plugin.version>0.9.12</native.maven.plugin.version>
</properties>

<repositories>
Expand Down Expand Up @@ -277,4 +278,40 @@
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native.maven.plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<fallback>false</fallback>
<buildArgs>
<arg>-H:DashboardDump=fortune -H:+DashboardAll</arg>
</buildArgs>
<agent>
<enabled>true</enabled>
<options>
<option>experimental-class-loader-support</option>
</options>
</agent>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 5597cd6

Please sign in to comment.