Initial commit
This commit is contained in:
commit
6ff767b04e
25 changed files with 595 additions and 0 deletions
51
src/bld/java/com/example/GraalNativeBuild.java
Normal file
51
src/bld/java/com/example/GraalNativeBuild.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package com.example;
|
||||
|
||||
import rife.bld.BuildCommand;
|
||||
import rife.bld.Project;
|
||||
import rife.bld.extension.ExecOperation;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.jar.Attributes;
|
||||
|
||||
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
|
||||
import static rife.bld.dependencies.Repository.RIFE2_RELEASES;
|
||||
import static rife.bld.dependencies.Scope.test;
|
||||
|
||||
public class GraalNativeBuild extends Project {
|
||||
public GraalNativeBuild() {
|
||||
pkg = "com.example";
|
||||
name = "GraalNative";
|
||||
mainClass = "com.example.GraalNativeMain";
|
||||
version = version(0, 1, 0);
|
||||
|
||||
javaRelease = 17;
|
||||
|
||||
downloadSources = true;
|
||||
autoDownloadPurge = true;
|
||||
|
||||
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||
scope(test)
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)));
|
||||
|
||||
jarOperation().manifestAttribute(Attributes.Name.MAIN_CLASS, mainClass());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new GraalNativeBuild().start(args);
|
||||
}
|
||||
|
||||
@BuildCommand(value = "native-exec", summary = "Build a native executable")
|
||||
public void nativeExec() throws Exception {
|
||||
new ExecOperation()
|
||||
.fromProject(this)
|
||||
.timeout(120)
|
||||
.command("native-image", // use its absolute path if not found
|
||||
"-jar",
|
||||
Paths.get(buildDistDirectory().getAbsolutePath(), jarFileName()).toString(),
|
||||
"hello")
|
||||
.execute();
|
||||
|
||||
}
|
||||
}
|
11
src/main/java/com/example/GraalNativeMain.java
Normal file
11
src/main/java/com/example/GraalNativeMain.java
Normal file
|
@ -0,0 +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());
|
||||
}
|
||||
}
|
12
src/test/java/com/example/GraalNativeTest.java
Normal file
12
src/test/java/com/example/GraalNativeTest.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package com.example;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class GraalNativeTest {
|
||||
@Test
|
||||
void verifyHello() {
|
||||
assertEquals("Hello World!", new GraalNativeMain().getMessage());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue