使用插件Apache Maven Source Plugin
官网说明:https://maven.apache.org/plugins/maven-source-plugin/index.html
Goals Overview
source:jar 是默认的。
The Source Plugin has five goals:
- source:aggregate aggregrates sources for all modules in an aggregator project.
- source:jar is used to bundle the main sources of the project into a jar archive.
- source:test-jar on the other hand, is used to bundle the test sources of the project into a jar archive.
- source:jar-no-fork is similar to jar but does not fork the build lifecycle.
- source:test-jar-no-fork is similar to test-jar but does not fork the build lifecycle.
POM Demo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version><!--版本号查询官网最新版-->
<configuration>
<outputDirectory>/absolute/path/to/the/output/directory</outputDirectory>
<finalName>filename-of-generated-jar-file</finalName>
<attach>false</attach>
</configuration>
</plugin>
</plugins>
</build>
...
</project>快速使用
- 配置好发布的私服地址。
1 | <project> |