源码打包插件:maven-source-plugin

插件首页:http://maven.apache.org/plugins/maven-source-plugin/

项目pom文件build下添加配置:

				<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</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,单独打包源码。



你可能感兴趣的:(maven)