怎么发布一个pom项目且打包maven源码,将源码包与jar包一同deploy到mavenserver

如何发布一个pom项目且打包maven源码,将源码包与jar包一同deploy到mavenserver

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