Files
maven-mvnd/client/pom.xml
James Z.M. Gao 6f28a189b6 Try native image then fallback to pure java version (#717)
* Add script mvnd-auto to auto select native or pure java mvnd

* Move fallback logic into main entry script

1. rename native binary to 'mvnd-native-<os>-<arch>'
2. add environment switch MVND_ENTRY_FALLBACK, default 'true' enables
   the fallback logic, set to 'false' to force execute the native mvnd.
3. rename mvnd.sh to mvnd

* change entry name on windows

* Add script mvnd-persist-native for moving the native image to the default entry path

* improve platform detect

* fix error on dash

* rollback default entry to the native image

* use MVND_CLIENT switch to control the selection of mvnd client

* improve comment docs as suggestion
2023-01-24 10:51:56 +01:00

240 lines
7.2 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2019 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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.apache.maven.daemon</groupId>
<artifactId>mvnd</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>mvnd-client</artifactId>
<packaging>jar</packaging>
<name>Maven Daemon - Client</name>
<properties>
<maven.compiler.release>11</maven.compiler.release>
<graalvm-native-static-opt />
<graalvm-native-glibc-opt />
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven.daemon</groupId>
<artifactId>mvnd-common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-bytecode-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>${maven.compiler.release}</maxJdkVersion>
<excludes>
<exclude>org.graalvm.nativeimage:svm</exclude>
</excludes>
</enforceBytecodeVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<configuration>
<locale>en_US</locale>
</configuration>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>fallback-main</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>${maven-dist.required.jdk}</release>
<compileSourceRoots>
<root>${project.basedir}/src/main/java-fallback</root>
</compileSourceRoots>
</configuration>
</execution>
<execution>
<id>mvnd-main</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<multiReleaseOutput>true</multiReleaseOutput>
<compileSourceRoots>
<root>${project.basedir}/src/main/java-mvnd</root>
</compileSourceRoots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<project.basedir>${project.basedir}</project.basedir>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>enable-partial-static-native</id>
<activation>
<os>
<family>!mac</family>
</os>
</activation>
<properties>
<graalvm-native-static-opt>-H:+StaticExecutableWithDynamicLibC</graalvm-native-static-opt>
</properties>
</profile>
<profile>
<id>linux-image-only-require-glibc-2.12</id>
<activation>
<os>
<family>linux</family>
</os>
<file>
<exists>target/graalvm-libs-for-glibc-2.12</exists>
</file>
</activation>
<properties>
<graalvm-native-glibc-opt>-H:CLibraryPath=${project.build.directory}/graalvm-libs-for-glibc-2.12</graalvm-native-glibc-opt>
</properties>
</profile>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
<mainClass>org.mvndaemon.mvnd.client.DefaultClient</mainClass>
<imageName>mvnd</imageName>
<buildArgs>--no-server
--no-fallback
--allow-incomplete-classpath
${graalvm-native-static-opt}
${graalvm-native-glibc-opt}
-H:IncludeResources=org/mvndaemon/mvnd/.*
-H:IncludeResources=mvnd-bash-completion.bash
-H:-ParseRuntimeOptions
-H:+AddAllCharsets
-H:+ReportExceptionStackTraces
-ea</buildArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>