Springboot如何整合maven插口调用maven release plugin实现一键打包功能
发表于:2024-10-01 作者:千家信息网编辑
千家信息网最后更新 2024年10月01日,小编给大家分享一下Springboot如何整合maven插口调用maven release plugin实现一键打包功能,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!maven re
千家信息网最后更新 2024年10月01日Springboot如何整合maven插口调用maven release plugin实现一键打包功能
小编给大家分享一下Springboot如何整合maven插口调用maven release plugin实现一键打包功能,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
maven release plugin配置
整合maven-invoker使程序去执行mvn命令
1.导包
org.apache.maven.shared maven-invoker 3.1.0
注意maven-invoker版本。版本过低可能导致不兼容。
2.测试程序
public class MavenTest { //直接执行mvn release:prepare -X 为交互式执行,无法在程序进行时输入版本参数。 //而执行mvn -B release:prepare -X 则可以通过程序直接执行。但是若要自定义版本信息则需要配置pom release plugin的参数,或采用如下命令 //实际执行的mvn命令. //mvn -B release:prepare -X -Dtag=VersionControlDemo-"0.4.0" -DreleaseVersion="0.4.0" -DdevelopmentVersion="0.4.1-SNAPSHOT" //mvn release:perform -X public static void main(String[] args) throws MavenInvocationException { InvocationRequest request = new DefaultInvocationRequest(); //获取pom文件地址 String relativelyPath=System.getProperty("user.dir"); String pomPath = relativelyPath+"/pom.xml"; System.out.println(pomPath); request.setPomFile(new File(pomPath)); Invoker invoker = new DefaultInvoker(); //获取maven环境变量地址 String m2Path = System.getenv("MAVEN_HOME"); System.out.println("m2Path:"+m2Path); invoker.setMavenHome(new File(m2Path)); try { //该版本tag信息 String tag = "VersiongControlDemo-0.4.0"; //此次发布的版本号 String version = "0.4.0"; //下一次版本的快照版本号 String developmentVersion="0.4.1-SNAPSHOT"; Listgoals = new ArrayList<>(); goals.add("-B"); goals.add("release:prepare"); goals.add("-X"); goals.add("-Dtag=" + tag); goals.add("-DreleaseVersion=" + version); goals.add("-DdevelopmentVersion=" + developmentVersion); request.setGoals(goals); System.out.println("开始: " + request.getGoals()); invoker.execute(request); request.setGoals(Collections.singletonList("release:perform -X")); System.out.println("开始: " + request.getGoals()); invoker.execute(request); } catch (MavenInvocationException e) { e.printStackTrace(); return; } }}
运行测试demo。结果成功。(每次运行前都要注意版本参数,切勿冲突。)
同理可配置release:rollback
等相关回滚命令。
看完了这篇文章,相信你对"Springboot如何整合maven插口调用maven release plugin实现一键打包功能"有了一定的了解,如果想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!
版本
命令
程序
整合
参数
配置
功能
插口
一键
信息
地址
篇文章
测试
运行
成功
交互式
变量
可以通过
完了
实际
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
中金公司数据库开发面试
现教中心网络技术科
47岁还能做软件开发维护
地下城堡3华为服务器
云计算与网络安全的区别
上海福缔网络技术
服务器证书无效或过期
合肥的网络安全公司
太原科技大学互联网专业是学哪些
收获日2服务器在哪里
数据库的笛卡儿积
高桥北的服务器
我的世界服务器npc召唤不出来
广东企业云空间部署服务器
服务器能给固态硬盘加装吗
云服务器运行exe教程
数据库中 表中列称为
广东软件开发小程序
网络安全与执法近视
网络安全专科课堂总结
温州企业软件开发服务
vue 图表 存入数据库
网络技术年度述职
你知道什么是大数据库
创建数据库文件的sql语句
对日软件开发去日本
湖南大学网络安全研究生招生
网络安全知识50字左右
所有软件开发程序
cmd怎么连接数据库