需要在要发布的pom项目里的pom.xml里添加如下内容:
<project>
<build>
<plugins>
<!-- 要将源码放上去,需要加入这个插件 -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>releases</id>
<name>Search Book Replace Plugin</name>
<url>http://mvnrepo.xxxx.com/mvn/releases</url>
</repository>
<!--use the following if you ARE using a snapshot version. -->
<snapshotRepository>
<id>snapshots</id>
<name>Search Book Replace Plugin</name>
<url>http://mvnrepo.xxxx.com/mvn/snapshots</url>
</snapshotRepository>
</distributionManagement>
</project>
然后执行 mvn deploy 即可.
如单独的打源码包可执行 mvn source:jar
本文介绍如何在Maven项目中配置源码包的发布。通过在pom.xml文件中添加特定插件和配置,可以实现源码包的自动打包,并指定发布到私有仓库的路径。适用于希望在Maven仓库中分享源码的开发者。
1484

被折叠的 条评论
为什么被折叠?



