分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

maven上传源码到私服

发布时间:2023-09-06 02:21责任编辑:彭小芳关键词:暂无标签

上传源码

项目中采用了分模块的方式构建,直接将maven-source-plugin写到父pom中,尝试了很多次发现源码一直不能上传到私服中,纠结了很长时间才发现原来多模块项目和普通一个项目的配置是有区别的,需要在每个需要上传源码的子模块中都配置maven-source-plugin才可以上传,于是乎有了一下的代码

1,非多模块项目

<plugins> ??<plugin> ?????<groupId>org.apache.maven.plugins</groupId> ?????<artifactId>maven-source-plugin</artifactId> ?????<version>3.0.1</version> ?????<configuration> ????????<attach>true</attach> ?????</configuration> ?????<executions> ????????<execution> ???????????<phase>compile</phase> ???????????<goals> ?????????????<goal>jar</goal> ???????????</goals> ?????????</execution> ?????</executions> ?</plugin></plugins>

2,多模块项目

在父pom中增加

<pluginManagement> ??<plugins> ?????<plugin> ?????????<groupId>org.apache.maven.plugins</groupId> ?????????<artifactId>maven-source-plugin</artifactId> ?????????<version>3.0.1</version> ?????????<configuration> ????????????<attach>true</attach> ?????????</configuration> ????????????<executions> ????????????????<execution> ????????????????????<phase>compile</phase> ????????????????????????<goals> ???????????????????????????<goal>jar</goal> ????????????????????????</goals> ????????????????</execution> ???????????</executions> ???????</plugin> ???</plugins></pluginManagement>

子项目中增加

 <build> ???<plugins> ?????<plugin> ???????<groupId>org.apache.maven.plugins</groupId> ???????<artifactId>maven-source-plugin</artifactId> ?????</plugin> ???</plugins> ?</build>

然后使用:mvn deploy 既可将源码上传到私服中

打包问题

封装过公共组件的同志们都知道,工具组件需要不断的维护升级,还好现在有maven来帮助我们管理各个版本的jar包,但是如何正确的使用maven来让团队使用我们jar呢,这就是我们接下来介绍的。

首先我们开发的版本都是 SNAPSHOT ,但是当被项目组使用的时候需要发布RELEASE版本来使用,这样不至于我们更改的代码影响团队的使用。因此在deploy项目的时候我们可以分为三部来操作

mvn versions:set -DnewVersion=1.0.0.RELEASEmvn deploymvn versions:set -DnewVersion=0.0.1-SNAPSHOT

第一步:我们设置当前项目的版本号为 1.0.0Release,这是maven会自动将多模块中所有模块的版本号都更改为当前我们设置的

第二步:继续使用deploy上传代码

第三步:我们要继续开发自己的功能,所以需要将项目中的版本号更改为SNAPSHOT

上面的1.0.0 和 0.0.1 需要根据项目来定,没有固定的要求

 pom中配置配置Nexus

<distributionManagement>
??<snapshotRepository>
?????<id>snapshots</id>
?????<name>Nexus Snapshot Repository</name>
?????<url>http://x.x.x.x:port/nexus/content/repositories/snapshots/</url>
??</snapshotRepository>
??<repository>
?????<id>releases</id>
?????<name>Nexus Release Repository</name>
?????<url>http://x.x.x.x:port/nexus/content/repositories/releases/</url>
??</repository>
</distributionManagement>

maven上传源码到私服

原文地址:https://www.cnblogs.com/blueskyli/p/9924678.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved