需要在要发布的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