
在一个工程中我想使用 maven-jar-plugin 的<includes>标签只打包我想要放出的 api 接口, 用于打包注释的 maven-source-plugin 也一样.
但是 springboot 一键打包是个 repackage 过程, 只会根据 maven-jar-plugin 打好的包重新进行打包, 这样就导致部署的时候内容缺失.
我想问下怎么才能使 maven-jar-plugin 的<includes>标签和 springboot 一键打包共存呢, 谢谢.
以下是 pom 的样例:
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <excludes> <exclude>**/*.properties</exclude> </excludes> <includes> <include>service/api/**</include> </includes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.4</version> <configuration> <excludes> <exclude>**/*.properties</exclude> </excludes> <includes> <include>service/api/**</include> </includes> </configuration> <executions> <execution> <id>attach-sources</id> <phase>verify</phase><!-- 要绑定到的生命周期的阶段 在 verify 之后, install 之前执行下面指定的 goal --> <goals> <goal>jar-no-fork</goal><!-- 类似执行 mvn source:jar --> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>ServiceClass</mainClass> <layout>ZIP</layout> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> 1 zhaoace 2016-08-18 09:46:02 +08:00 你是需要一次调用全部做掉么? 如果不是的话我记得 maven 可以分开写两个 Profile 。 写起来会麻烦点。 大体上就是 profile1 只用来打包 plugin, profile2 只用来做 spring-boot. 思路上不是配置两个 plugin 之间怎么互相包含或者不包含,而是区分 profile ,不同 profile 的 plugin 进行不同的设置。 可以参考 http://maven.apache.org/guides/introduction/introduction-to-profiles.html http://haohaoxuexi.iteye.com/blog/1900568 Sorry maven 不用很久了,没法直接上 code 了。 :) |
2 flamhaze5946 OP @zhaoace 非常感谢, 我之后就是用了两个 Profile |