build(gateway, infra, system): 优化项目构建配置

- 修改 .gitignore 文件,添加 lib目录到忽略列表
- 更新 yudao-gateway、yudao-module-infra-biz 和 yudao-module-system-biz 模块的 pom.xml 文件
  - 添加 maven-jar-plugin 配置,排除资源文件打包 - 添加 maven-resources-plugin 配置,复制资源文件到指定目录
  - 注释掉 maven-dependency-plugin 配置
pull/178/head
ethan 2025-04-02 17:18:07 +08:00
parent ace3401693
commit b7a8a25c5d
4 changed files with 193 additions and 4 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
# 查看更多 .gitignore 配置 -> https://help.github.com/articles/ignoring-files/
target/
lib/
!.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml

View File

@ -94,6 +94,50 @@
</execution>
</executions>
</plugin>
<!--不打包资源文件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>*.**</exclude>
<exclude>*/*.xml</exclude>
</excludes>
<archive>
<manifestEntries>
<Class-Path>./resources/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!--
复制配置文件、以及拷贝第三方依赖文件到指定目录
当依赖包有变化时需使用下面配置,重新生成最新的依赖包
-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.**</include>
</includes>
</resource>
</resources>
<outputDirectory>${project.build.directory}/resources</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -152,19 +152,91 @@
<!-- 设置构建的 jar 包名 -->
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- 打包 -->
<!-- 打包时去除依赖包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>non-exists</groupId>
<artifactId>non-exists</artifactId>
</include>
</includes>
</configuration>
</plugin>
<!--不打包资源文件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>*.**</exclude>
<exclude>*/*.xml</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<useUniqueVersions>false</useUniqueVersions>
<mainClass>cn.iocoder.yudao.module.infra.InfraServerApplication</mainClass>
</manifest>
<manifestEntries>
<Class-Path>./resources/</Class-Path>
</manifestEntries>
</archive>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</plugin>
<!--
复制配置文件、以及拷贝第三方依赖文件到指定目录
当依赖包有变化时需使用下面配置,重新生成最新的依赖包
-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.**</include>
</includes>
</resource>
</resources>
<outputDirectory>${project.build.directory}/resources</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>-->
</plugins>
</build>

View File

@ -153,19 +153,91 @@
<!-- 设置构建的 jar 包名 -->
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- 打包 -->
<!-- 打包时去除依赖包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>non-exists</groupId>
<artifactId>non-exists</artifactId>
</include>
</includes>
</configuration>
</plugin>
<!--不打包资源文件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>*.**</exclude>
<exclude>*/*.xml</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<useUniqueVersions>false</useUniqueVersions>
<mainClass>cn.iocoder.yudao.module.system.SystemServerApplication</mainClass>
</manifest>
<manifestEntries>
<Class-Path>./resources/</Class-Path>
</manifestEntries>
</archive>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</plugin>
<!--
复制配置文件、以及拷贝第三方依赖文件到指定目录
当依赖包有变化时需使用下面配置,重新生成最新的依赖包
-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.**</include>
</includes>
</resource>
</resources>
<outputDirectory>${project.build.directory}/resources</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>-->
</plugins>
</build>