[jOOQ/jOOQ#8779] Tentative example for native image compilation
This commit is contained in:
parent
7e88f67c7c
commit
affc154e40
100
jOOQ-examples/jOOQ-picocli-native-image-example/pom.xml
Normal file
100
jOOQ-examples/jOOQ-picocli-native-image-example/pom.xml
Normal file
@ -0,0 +1,100 @@
|
||||
<?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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-examples</artifactId>
|
||||
<version>3.18.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jooq-picocli-native-image</artifactId>
|
||||
<name>jOOQ PicoCLI native image Example</name>
|
||||
|
||||
<properties>
|
||||
<mainClass>org.jooq.example.picocli.Main</mainClass>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
|
||||
<release>17</release>
|
||||
|
||||
|
||||
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>info.picocli</groupId>
|
||||
<artifactId>picocli-codegen</artifactId>
|
||||
<version>4.1.4</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<compilerArgs>
|
||||
<arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.graalvm.nativeimage</groupId>
|
||||
<artifactId>native-image-maven-plugin</artifactId>
|
||||
<version>20.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>native-image</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<imageName>${project.name}</imageName>
|
||||
<mainClass>${mainClass}</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>${mainClass}</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>info.picocli</groupId>
|
||||
<artifactId>picocli</artifactId>
|
||||
<version>4.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.graalvm.nativeimage</groupId>
|
||||
<artifactId>svm</artifactId>
|
||||
<version>22.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -0,0 +1,23 @@
|
||||
package org.jooq.example.picocli;
|
||||
|
||||
import org.jooq.CloseableDSLContext;
|
||||
import org.jooq.impl.DSL;
|
||||
import picocli.CommandLine;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Command
|
||||
public class Main implements Runnable {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new CommandLine(new Main()).execute(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try (CloseableDSLContext ctx = DSL.using("jdbc:h2:mem:jooq-example-picocli", "sa", "")) {
|
||||
System.out.println(ctx.fetch("select 1"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user