通过Maven发布构建到NEXUS私服上
发布构建到私服 --- mvn deploy
POM中通过distributionManagement分发本地构建到NEXUS私服上
第一步,配置distributionManagement

<project>  
  
   ...  
    <distributionManagement>  
                          
               <!-- 配置快照版本发布的仓库-->  
        <snapshotRepository>  
            <id>nexus-snapshots</id>  
            <name>Nexus Snapshots Repository</name>  
            <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>  
        </snapshotRepository>  
                <!-- 配置release版本发布的仓库-->      
        <repository>  
            <id>nexus-releases</id>  
            <name>Nexus Releases Repository</name>  
            <url>http://localhost:8081/nexus/content/repositories/releases/</url>  
        </repository>  
    </distributionManagement>  
    
   ...  
  
</project> 
第二步,在settings文件中,配置上传构建时需要的账号(必须通过有效账号才能deploy)
注意: <id>属性指代的就是POM中配置Repository的id,必须一一对应。
    <settings>  
          
        ...  
      
      <servers>  
        <!-- 配置上传snapshot构建时使用的账户 -->  
        <server>  
          <id>nexus-snapshots</id>  
          <username>root</username>  
          <password>root</password>  
        </server>  
        <!-- 配置上传release构建时使用的账户 -->  
        <server>  
          <id>nexus-releases</id>  
          <username>root</username>  
          <password>root</password>  
        </server>  
      
        ...  
      
    </settings>  

现在,就可以通过Maven的deploy命令,将本地的Maven项目上传到私服上了,只要能够访问私服的,都能下载到这些构建。

 

补充:

为了上传jar同时上传源码.使用mvn deploy   即可.同时要保证 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>  

 

 

如单独的打源码包可执行   mvn source:jar

例如dubbo源码 :   mvn clean source:jar install -Dmaven.test.skip=true

 

posted on 2017-07-12 15:05  七月逆流  阅读(2197)  评论(0编辑  收藏  举报