docs: 增加maven文档
This commit is contained in:
parent
72d187ab76
commit
a66442b0bc
49
pom.xml
49
pom.xml
@ -19,24 +19,41 @@
|
|||||||
|
|
||||||
<!-- 通用编译 & 打包插件 -->
|
<!-- 通用编译 & 打包插件 -->
|
||||||
<build>
|
<build>
|
||||||
|
<!-- 资源文件目录及占位符替换(resource filtering) -->
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
<!-- 指定资源文件所在目录 -->
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
|
<!-- 开启资源文件中的占位符(如 ${project.version})替换 -->
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- Java 编译插件 -->
|
<!--
|
||||||
|
Java 编译插件:
|
||||||
|
- 使用 Maven 自带的 maven-compiler-plugin 进行源码编译
|
||||||
|
- <fork>true</fork> 表示在单独的进程中执行 javac,提高兼容性
|
||||||
|
-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.12.1</version>
|
<version>3.12.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<!-- 在新的 JVM 进程中调用编译器 -->
|
||||||
<fork>true</fork>
|
<fork>true</fork>
|
||||||
|
<!-- 可以根据需要指定编译器版本,如:
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
-->
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Jar 打包插件 -->
|
|
||||||
|
<!--
|
||||||
|
Jar 打包插件:
|
||||||
|
- 使用 maven-jar-plugin 将编译产物打包成可执行 JAR
|
||||||
|
- 在 MANIFEST 中指定主类,支持命令行直接 java -jar 调用
|
||||||
|
-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
@ -44,8 +61,11 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
|
<!-- 指定程序入口类,运行 java -jar 时会执行此类的 main 方法 -->
|
||||||
<mainClass>org.jcnc.snow.cli.SnowCLI</mainClass>
|
<mainClass>org.jcnc.snow.cli.SnowCLI</mainClass>
|
||||||
|
<!-- 将项目类路径添加到 MANIFEST Class-Path 中 -->
|
||||||
<addClasspath>true</addClasspath>
|
<addClasspath>true</addClasspath>
|
||||||
|
<!-- 在 MANIFEST 中添加实现版本、实现供应商等默认条目 -->
|
||||||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
@ -55,6 +75,11 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
<!--
|
||||||
|
原生镜像构建:Linux 平台
|
||||||
|
- 使用 GraalVM 的 native-image 工具,生成静态链接的可执行文件
|
||||||
|
- 依赖 musl libc,需提前安装并配置 musl-gcc 工具链
|
||||||
|
-->
|
||||||
<profile>
|
<profile>
|
||||||
<id>native-linux</id>
|
<id>native-linux</id>
|
||||||
<activation>
|
<activation>
|
||||||
@ -68,15 +93,19 @@
|
|||||||
<groupId>org.graalvm.buildtools</groupId>
|
<groupId>org.graalvm.buildtools</groupId>
|
||||||
<artifactId>native-maven-plugin</artifactId>
|
<artifactId>native-maven-plugin</artifactId>
|
||||||
<version>${native.maven.plugin.version}</version>
|
<version>${native.maven.plugin.version}</version>
|
||||||
|
<!-- 启用插件扩展,允许在 build 生命周期中无须额外配置 -->
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<executions>
|
<executions>
|
||||||
|
<!-- 打包阶段生成原生可执行文件 -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>build-native</id>
|
<id>build-native</id>
|
||||||
<goals>
|
<goals>
|
||||||
|
<!-- compile-no-fork 在当前 JVM 进程中执行 native-image -->
|
||||||
<goal>compile-no-fork</goal>
|
<goal>compile-no-fork</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
</execution>
|
</execution>
|
||||||
|
<!-- 测试阶段运行原生镜像的测试 -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>test-native</id>
|
<id>test-native</id>
|
||||||
<goals>
|
<goals>
|
||||||
@ -87,13 +116,17 @@
|
|||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<buildArgs>
|
<buildArgs>
|
||||||
|
<!-- 静态链接 -->
|
||||||
<buildArg>--static</buildArg>
|
<buildArg>--static</buildArg>
|
||||||
|
<!-- 指定 musl libc -->
|
||||||
<buildArg>--libc=musl</buildArg>
|
<buildArg>--libc=musl</buildArg>
|
||||||
|
<!-- 输出构建报告 -->
|
||||||
<buildArg>--emit build-report</buildArg>
|
<buildArg>--emit build-report</buildArg>
|
||||||
|
<!-- 优化级别 O2 -->
|
||||||
<buildArg>-O2</buildArg>
|
<buildArg>-O2</buildArg>
|
||||||
</buildArgs>
|
</buildArgs>
|
||||||
<environment>
|
<environment>
|
||||||
<!-- 指定 musl-gcc 工具链 -->
|
<!-- 指定使用 musl 工具链 -->
|
||||||
<PATH>/opt/musl-1.2.5/bin:${env.PATH}</PATH>
|
<PATH>/opt/musl-1.2.5/bin:${env.PATH}</PATH>
|
||||||
<C_INCLUDE_PATH>/opt/musl-1.2.5/include</C_INCLUDE_PATH>
|
<C_INCLUDE_PATH>/opt/musl-1.2.5/include</C_INCLUDE_PATH>
|
||||||
<LIBRARY_PATH>/opt/musl-1.2.5/lib</LIBRARY_PATH>
|
<LIBRARY_PATH>/opt/musl-1.2.5/lib</LIBRARY_PATH>
|
||||||
@ -104,6 +137,11 @@
|
|||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
原生镜像构建:Windows 平台
|
||||||
|
- 使用 GraalVM 的 native-image 工具,生成 Windows 可执行文件
|
||||||
|
- Windows 上不使用 musl,因此不配置静态链接
|
||||||
|
-->
|
||||||
<profile>
|
<profile>
|
||||||
<id>native-windows</id>
|
<id>native-windows</id>
|
||||||
<activation>
|
<activation>
|
||||||
@ -119,6 +157,7 @@
|
|||||||
<version>${native.maven.plugin.version}</version>
|
<version>${native.maven.plugin.version}</version>
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<executions>
|
<executions>
|
||||||
|
<!-- 打包阶段生成 Windows 可执行文件 -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>build-native</id>
|
<id>build-native</id>
|
||||||
<goals>
|
<goals>
|
||||||
@ -126,6 +165,7 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
</execution>
|
</execution>
|
||||||
|
<!-- 测试阶段运行原生镜像测试 -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>test-native</id>
|
<id>test-native</id>
|
||||||
<goals>
|
<goals>
|
||||||
@ -136,7 +176,9 @@
|
|||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<buildArgs>
|
<buildArgs>
|
||||||
|
<!-- 输出构建报告 -->
|
||||||
<buildArg>--emit build-report</buildArg>
|
<buildArg>--emit build-report</buildArg>
|
||||||
|
<!-- 优化级别 O2 -->
|
||||||
<buildArg>-O2</buildArg>
|
<buildArg>-O2</buildArg>
|
||||||
</buildArgs>
|
</buildArgs>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -145,4 +187,5 @@
|
|||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user