插件首页:http://maven.apache.org/plugins/maven-source-plugin/
项目pom文件build下添加配置:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>
2.2
.
1
</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork<span></span></goal>
</goals>
</execution>
</executions>
</plugin>
|
execution下可配置phase属性, 意思是在什么阶段打包源文件。如<phase>package</phase>
- 执行 mvn install,maven会自动将source install到repository 。
- 执行 mvn deploy,maven会自动将source deploy到remote-repository 。
- 执行 mvn source:jar,单独打包源码。