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