diff --git a/.idea/misc.xml b/.idea/misc.xml
index 2fe7c50..e465ffe 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,6 +3,8 @@
+
+
diff --git a/README.md b/README.md
index 578833e..b950afd 100644
--- a/README.md
+++ b/README.md
@@ -8,22 +8,22 @@ Be sure to have the GraalVM `native-image` utility in your path, or set its loca
```console
./bld compile
```
-## Create a Java archive
+## Create the Java archive
```console
./bld jar
```
-## Create the native application
+## Create the native application from the Java archive
```console
-./bld native-exec
+./bld native-jar
```
-## Combine the commands
+## Create the native application from the main class
```console
-./bld compile jar native-exec
+./bld compile native-class
```
## Launch the application
diff --git a/src/bld/java/com/example/GraalNativeBuild.java b/src/bld/java/com/example/GraalNativeBuild.java
index 886adcd..a12619c 100644
--- a/src/bld/java/com/example/GraalNativeBuild.java
+++ b/src/bld/java/com/example/GraalNativeBuild.java
@@ -4,7 +4,7 @@ import rife.bld.BuildCommand;
import rife.bld.Project;
import rife.bld.extension.ExecOperation;
-import java.nio.file.Paths;
+import java.io.File;
import java.util.List;
import java.util.jar.Attributes;
@@ -44,8 +44,22 @@ public class GraalNativeBuild extends Project {
new GraalNativeBuild().start(args);
}
- @BuildCommand(value = "native-exec", summary = "Builds a native executable")
- public void nativeExec() throws Exception {
+ @BuildCommand(value = "native-class", summary = "Builds a native executable")
+ public void nativeClass() throws Exception {
+ new ExecOperation()
+ .fromProject(this)
+ .timeout(120)
+ .workDir(buildMainDirectory().getAbsolutePath())
+ // The native image options documentation can be found at:
+ // https://www.graalvm.org/22.0/reference-manual/native-image/Options/
+ .command("native-image", // use its absolute path if not found
+ mainClass(),
+ new File(workDirectory(), "hello").getAbsolutePath())
+ .execute();
+ }
+
+ @BuildCommand(value = "native-jar", summary = "Builds a native executable from the JAR")
+ public void nativeJar() throws Exception {
new ExecOperation()
.fromProject(this)
.timeout(120)
@@ -53,7 +67,7 @@ public class GraalNativeBuild extends Project {
// https://www.graalvm.org/22.0/reference-manual/native-image/Options/
.command("native-image", // use its absolute path if not found
"-jar",
- Paths.get(buildDistDirectory().getAbsolutePath(), jarFileName()).toString(),
+ new File(buildDistDirectory(), jarFileName()).toString(),
"hello")
.execute();
}
diff --git a/src/main/java/com/example/GraalNativeMain.java b/src/main/java/com/example/GraalNativeMain.java
index 42d74a3..a2621f9 100644
--- a/src/main/java/com/example/GraalNativeMain.java
+++ b/src/main/java/com/example/GraalNativeMain.java
@@ -1,11 +1,11 @@
package com.example;
public class GraalNativeMain {
- public String getMessage() {
- return "Hello World!";
- }
-
public static void main(String[] args) {
System.out.println(new GraalNativeMain().getMessage());
}
+
+ public String getMessage() {
+ return "Hello World!";
+ }
}
\ No newline at end of file
diff --git a/src/test/java/com/example/GraalNativeTest.java b/src/test/java/com/example/GraalNativeTest.java
index 06cfff9..057c04e 100644
--- a/src/test/java/com/example/GraalNativeTest.java
+++ b/src/test/java/com/example/GraalNativeTest.java
@@ -2,7 +2,7 @@ package com.example;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class GraalNativeTest {
@Test