Skip to content

Commit

Permalink
Merge pull request #41 from vlingo/graalvm_compatibility_builds
Browse files Browse the repository at this point in the history
GraalVM compatibility builds And Native Image
  • Loading branch information
VaughnVernon authored May 31, 2021
2 parents df1dbc0 + 35aef5e commit 21bfc42
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 3 deletions.
47 changes: 44 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>io.vlingo.xoom</groupId>
<artifactId>xoom-common</artifactId>
Expand Down Expand Up @@ -31,6 +33,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<graalvm.version>21.1.0</graalvm.version>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -111,18 +114,56 @@
<artifactId>argon2-jvm</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graalvm.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<repositories>
<repository>
<id>ossrh-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<profiles>
<profile>
<id>native-image</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>native-image-maven-plugin</artifactId>
<version>${graalvm.version}</version>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<imageName>${project.name}</imageName>
<buildArgs>
--shared
-H:DashboardDump=${project.name} -H:+DashboardAll
-H:+DashboardJson -H:+DashboardPretty
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>sign-artifacts</id>
<activation>
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/nativebuild/NativeBuildEntryPoint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package nativebuild;

import io.vlingo.xoom.common.identity.IdentityGenerator;
import io.vlingo.xoom.common.message.Message;
import io.vlingo.xoom.common.message.MessageExchangeReader;
import org.graalvm.nativeimage.c.function.CEntryPoint;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.c.type.CTypeConversion;

import java.util.Date;

public final class NativeBuildEntryPoint {
@CEntryPoint(name = "Java_io_vlingo_xoom_commonnative_Native_from")
public static int from(@CEntryPoint.IsolateThreadContext long isolateId, CCharPointer message) {
final String messageString = CTypeConversion.toJavaString(message);
MessageExchangeReader.from(new Message() {

@Override
public String id() {
// TODO Auto-generated method stub
return new IdentityGenerator.NameBasedIdentityGenerator().generate().toString();
}

@Override
public Date occurredOn() {
// TODO Auto-generated method stub
return null;
}

@Override
public String payload() {
// TODO Auto-generated method stub
return messageString;
}

@Override
public String type() {
// TODO Auto-generated method stub
return null;
}

@Override
public String version() {
// TODO Auto-generated method stub
return null;
}

});
return 0;
}
}

0 comments on commit 21bfc42

Please sign in to comment.