1.針對多模塊工程,多個jar還有war,如何實現只發jar,不發war
解決方案:可以在項目根目錄直接執行mvn deploy進行發佈,也可以通過切換到子模塊目錄下執行mvn deploy,根據自身情況。
只發jar,不發war可以通過在war模塊的pom.xml中增加下面代碼來實現:
<
plugin
>
<
groupId
>org.apache.maven.plugins</
groupId
>
<
artifactId
>maven-deploy-plugin</
artifactId
>
<
version
>2.7</
version
>
<
configuration
>
<
skip
>true</
skip
>
</
configuration
>
</
plugin
>
2.無需修改pom.xml中的版本實現發佈的靈活性------maven會判斷版本後面是否帶了-SNAPSHOT,如果帶了就發佈到snapshots倉庫,否則發佈到release倉庫。
<groupId>com.test</groupId>
<artifactId>my-test</artifactId>
<packaging>jar</packaging>
<version>${project.release.version}</version>
<properties>
<java.version>1.8</java.version>
<project.release.version>1.0-SNAPSHOT</project.release.version>
</properties>
<profiles>
<profile>
<id>product</id>
<properties>
<project.release.version>1.0</project.release.version>
</properties>
</profile>
</profiles>
說明:通過佔位符${project.release.version}來控制需要發佈的版本,用命令mvn
deploy -P product,發佈my-test的1.0版本到releases庫。如果使用命令mvn deploy,則默認使用 1.0-SNAPSHOT版本號,將發佈my-test的1.0-SNAPSHOT版本到snapshots庫。nexus oss 3.*不能像2.*可以通過登錄web界面進行jar包的上傳操作,可以通過下面的方式來上傳第三方jar包:
。通過傳統方式mvn deploy來上傳;(缺點就是如果是要上傳到第三方庫或用來存放安卓,ios的構建產物的話需要額外安裝配置maven,如pom.xml與setting.xml)
。針對上面的問題其實官方提供了一個好的上傳方式----------通過API接口
格式:curl -v -u admin:admin123 --upload-file utils-1.0.jar http://ip/repository/thirdparty/org/foo/utils/1.0/utils-1.0.jar
上傳個圖片試試:curl -v --user ’admin:admin123’ --upload-file ./test.png http://ip/repository/AppReleases/test.png
參考:https://www.cnblogs.com/yucongblog/p/6857318.html