Working native image

This commit is contained in:
Paul Schaub 2024-12-12 19:22:46 +01:00
parent cc4870219a
commit 0123b0e5fe
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
12 changed files with 254 additions and 41 deletions

View file

@ -10,14 +10,25 @@
</parent>
<artifactId>bcsop-cli</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<native.maven.plugin.version>0.10.4</native.maven.plugin.version>
<imageName>bcsop-cli-native</imageName>
<mainClass>org.pgpainless.BcSopCLI</mainClass>
<graal.version>21.0.0</graal.version>
</properties>
<dependencies>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<version>${graal.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.pgpainless</groupId>
<artifactId>bcsop</artifactId>
@ -43,11 +54,51 @@
<build>
<plugins>
<!-- Annotation Processor -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- annotationProcessorPaths requires maven-compiler-plugin version 3.5 or higher -->
<version>3.11.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>info.picocli</groupId>
<artifactId>picocli-codegen</artifactId>
<version>4.6.3</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<!-- Compile -->
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<annotationProcessorPaths>
<path>
<groupId>info.picocli</groupId>
<artifactId>picocli-codegen</artifactId>
<version>4.6.3</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
-->
<!-- Assembly -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
@ -58,7 +109,7 @@
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.pgpainless.BcSopCLI</mainClass>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
@ -72,6 +123,144 @@
</execution>
</executions>
</plugin>
<!-- GraalVM -->
<plugin>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>native-image-maven-plugin</artifactId>
<version>${graal.version}</version>
<configuration>
<imageName>${imageName}</imageName>
<mainClass>${mainClass}</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<!-- Reflections -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>generateGraalReflectionConfig</id>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<mainClass>picocli.codegen.aot.graalvm.ReflectionConfigGenerator</mainClass>
<arguments>
<argument>--output=bcsop-cli/target/classes/META-INF/native-image/${project.groupId}/${project.artifactId}/reflect-config.json</argument>
<!--<argument>org.pgpainless.BcSopCLI</argument>-->
<argument>sop.cli.picocli.SopCLI</argument>
<!--
<argument>sop.cli.picocli.commands.ArmorCmd</argument>
<argument>sop.cli.picocli.commands.ChangeKeyPasswordCmd</argument>
<argument>sop.cli.picocli.commands.DearmorCmd</argument>
<argument>sop.cli.picocli.commands.DecryptCmd</argument>
<argument>sop.cli.picocli.commands.EncryptCmd</argument>
<argument>sop.cli.picocli.commands.ExtractCertCmd</argument>
<argument>sop.cli.picocli.commands.GenerateKeyCmd</argument>
<argument>sop.cli.picocli.commands.InlineDetachCmd</argument>
<argument>sop.cli.picocli.commands.InlineSignCmd</argument>
<argument>sop.cli.picocli.commands.InlineVerifyCmd</argument>
<argument>sop.cli.picocli.commands.ListProfilesCmd</argument>
<argument>sop.cli.picocli.commands.RevokeKeyCmd</argument>
<argument>sop.cli.picocli.commands.SignCmd</argument>
<argument>sop.cli.picocli.commands.VerifyCmd</argument>
<argument>sop.cli.picocli.commands.VersionCmd</argument>
-->
</arguments>
</configuration>
</execution>
<execution>
<id>generateGraalDynamicProxyConfig</id>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<mainClass>picocli.codegen.aot.graalvm.DynamicProxyConfigGenerator</mainClass>
<arguments>
<argument>--output=bcsop-cli/target/classes/META-INF/native-image/${project.groupId}/${project.artifactId}/proxy-config.json</argument>
<!--<argument>org.pgpainless.BcSopCLI</argument>-->
<argument>sop.cli.picocli.SopCLI</argument>
<!--
<argument>sop.cli.picocli.commands.ArmorCmd</argument>
<argument>sop.cli.picocli.commands.ChangeKeyPasswordCmd</argument>
<argument>sop.cli.picocli.commands.DearmorCmd</argument>
<argument>sop.cli.picocli.commands.DecryptCmd</argument>
<argument>sop.cli.picocli.commands.EncryptCmd</argument>
<argument>sop.cli.picocli.commands.ExtractCertCmd</argument>
<argument>sop.cli.picocli.commands.GenerateKeyCmd</argument>
<argument>sop.cli.picocli.commands.InlineDetachCmd</argument>
<argument>sop.cli.picocli.commands.InlineSignCmd</argument>
<argument>sop.cli.picocli.commands.InlineVerifyCmd</argument>
<argument>sop.cli.picocli.commands.ListProfilesCmd</argument>
<argument>sop.cli.picocli.commands.RevokeKeyCmd</argument>
<argument>sop.cli.picocli.commands.SignCmd</argument>
<argument>sop.cli.picocli.commands.VerifyCmd</argument>
<argument>sop.cli.picocli.commands.VersionCmd</argument>
-->
</arguments>
</configuration>
</execution>
<execution>
<id>generateGraalResourceConfig</id>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<mainClass>picocli.codegen.aot.graalvm.ResourceConfigGenerator</mainClass>
<arguments>
<argument>--output=bcsop-cli/target/classes/META-INF/native-image/${project.groupId}/${project.artifactId}/resource-config.json</argument>
<!--<argument>org.pgpainless.BcSopCLI</argument>-->
<argument>sop.cli.picocli.SopCLI</argument>
<!--
<argument>sop.cli.picocli.commands.ArmorCmd</argument>
<argument>sop.cli.picocli.commands.ChangeKeyPasswordCmd</argument>
<argument>sop.cli.picocli.commands.DearmorCmd</argument>
<argument>sop.cli.picocli.commands.DecryptCmd</argument>
<argument>sop.cli.picocli.commands.EncryptCmd</argument>
<argument>sop.cli.picocli.commands.ExtractCertCmd</argument>
<argument>sop.cli.picocli.commands.GenerateKeyCmd</argument>
<argument>sop.cli.picocli.commands.InlineDetachCmd</argument>
<argument>sop.cli.picocli.commands.InlineSignCmd</argument>
<argument>sop.cli.picocli.commands.InlineVerifyCmd</argument>
<argument>sop.cli.picocli.commands.ListProfilesCmd</argument>
<argument>sop.cli.picocli.commands.RevokeKeyCmd</argument>
<argument>sop.cli.picocli.commands.SignCmd</argument>
<argument>sop.cli.picocli.commands.VerifyCmd</argument>
<argument>sop.cli.picocli.commands.VersionCmd</argument>
-->
</arguments>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli-codegen</artifactId>
<version>4.6.3</version>
<type>jar</type>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
</project>