Skip to content

Documentation update #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rickgartner opened this issue May 9, 2025 · 1 comment
Open

Documentation update #9

rickgartner opened this issue May 9, 2025 · 1 comment

Comments

@rickgartner
Copy link

Documentation states for Linux "sdk install java 21.0.2-graal" but pom.xml has Java version 22. Compile fails. I resolved this by modifying pom.xml to Java version 21 or install java 22.0.1

Documentation needs updating to reflect the correct version of Java.

@EasyG0ing1
Copy link
Owner

EasyG0ing1 commented May 10, 2025

@rickgartner

If you're trying to compile the project itself, here is what I recommend:

  • Use SDKMan to manage your tools
  • Install latest Graal JDK sdk install java 25.ea.21-graal
  • Install latest Maven sdk install maven 4.0.0-rc-3

I've been modifying the code today and had some frustrations with Graal, so I decided to change the POM file to something much simpler, which comes from an IntelliJ template that I created. Here is the current POM file for this project:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.simtechdata</groupId>
    <artifactId>Migrate</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>
    <name>Migrate</name>
    <description>DHCP static mapping migration utility for OPNSense 24</description>

    <properties>
        <compatibility-arg/>
        <package.type/>
        <system-linker-arg/>
        <system-native-image-arg/>
        <mainClass>${groupId}.App</mainClass>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>22</maven.compiler.source>
        <maven.compiler.target>22</maven.compiler.target>
        <!--Dependencies-->
        <version-jackson-databind>2.19.0</version-jackson-databind>
        <version-jackson-dataformat-xml>2.19.0</version-jackson-dataformat-xml>
        <version-commons-io>2.19.0</version-commons-io>
        <!--Plugins-->
        <versions-maven-plugin>2.18.0</versions-maven-plugin>
        <version-maven-enforcer-plugin>3.5.0</version-maven-enforcer-plugin>
        <version-maven-assembly-plugin>3.7.1</version-maven-assembly-plugin>
        <version-native-maven-plugin>0.10.6</version-native-maven-plugin>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${version-jackson-databind}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>${version-jackson-dataformat-xml}</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${version-commons-io}</version>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>version.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>META-INF/native-image/${groupId}/${project.name}/*.*</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <!-- Maven Versions -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>${versions-maven-plugin}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>display-dependency-updates</goal>
                            <goal>display-plugin-updates</goal>
                            <goal>property-updates-report</goal>
                            <goal>dependency-updates-report</goal>
                            <goal>plugin-updates-report</goal>
                            <goal>update-properties</goal>
                            <goal>use-latest-versions</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--Maven Enforcer Plugin-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${version-maven-enforcer-plugin}</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>4.0.0-rc-2</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Maven Assembly Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${version-maven-assembly-plugin}</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>${mainClass}</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <finalName>${name}</finalName>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>maven_central</id>
            <name>Maven Central</name>
            <url>https://repo.maven.apache.org/maven2/</url>
        </repository>
    </repositories>

    <profiles>
        <!--native profile-->
        <profile>
            <id>native</id>
            <build>
                <plugins>
                    <!-- GraalVM Native Maven Plugin -->
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${version-native-maven-plugin}</version>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <id>build-native</id>
                            </execution>
                        </executions>
                        <configuration>
                            <target>${java.version}</target>
                            <imageName>${project.name}</imageName>
                            <mainClass>${mainClass}</mainClass>
                            <verbose>true</verbose>
                            <fallback>false</fallback>
                            <buildArgs>
                                <arg>-Djava.awt.headless=true</arg>
                                <arg>--no-fallback</arg>
                                <arg>--enable-preview</arg>
                                <arg>--enable-http</arg>
                                <arg>--enable-https</arg>
                                <arg>--initialize-at-build-time=org.sqlite.util.ProcessRunner</arg>
                                <arg>--enable-native-access=ALL-UNNAMED</arg>
                                <arg>-march=native</arg>
                                <arg>-H:+UnlockExperimentalVMOptions</arg>
                                <arg>-H:+ReportExceptionStackTraces</arg>
                                <arg>-H:ConfigurationFileDirectories=src/main/resources/META-INF/native-image/${groupId}/${project.name}}</arg>
                                <arg>-O3</arg>
                                <arg>-o ${basedir}/native-image/${project.name}</arg>
                            </buildArgs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

If you create a folder in the project root called something like compile then drop these files in there:

paths

P=~/JetBrainsProjects/IntelliJIdea/Migrate  #<-- Change that to the path where the githib clone is on your drive
T=$P/target
G=$P/src/main/resources/META-INF/native-image/com.simtechdata/Migrate

dograal.sh

#!/bin/bash
source paths

mvn -f $P/pom.xml clean package

java -agentlib:native-image-agent=config-output-dir=$G -jar $T/Migrate-jar-with-dependencies.jar -V
java -agentlib:native-image-agent=config-merge-dir=$G -jar $T/Migrate-jar-with-dependencies.jar -g
java -agentlib:native-image-agent=config-merge-dir=$G -jar $T/Migrate-jar-with-dependencies.jar

native.sh

#!/bin/bash

cur=$(pwd)
JP=$(dirname "$cur")

mvn -f $JP/pom.xml clean -Pnative native:compile

run

chmod +x *.sh

Then, make sure you have a config.xml file in the same folder as all this stuff...

./dograal.sh
./native.sh

And it should compile for you...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants