最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Springboot?整合maven插口調(diào)用maven?release?plugin實(shí)現(xiàn)一鍵打包功能

 更新時(shí)間:2022年03月15日 10:42:04   作者:孤獨(dú)的帥哥  
這篇文章主要介紹了Springboot?整合maven插口調(diào)用maven?release?plugin實(shí)現(xiàn)一鍵打包功能,整合maven-invoker使程序去執(zhí)行mvn命令,結(jié)合示例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下

maven release plugin配置

參考 http://m.fzitv.net/article/240857.htm  配置好pom。

整合maven-invoker使程序去執(zhí)行mvn命令

1.導(dǎo)包

<dependency>
  <groupId>org.apache.maven.shared</groupId>
  <artifactId>maven-invoker</artifactId>
  <version>3.1.0</version>
</dependency>

注意maven-invoker版本。版本過低可能導(dǎo)致不兼容。

2.測(cè)試程序

public class MavenTest {
    //直接執(zhí)行mvn release:prepare -X 為交互式執(zhí)行,無法在程序進(jìn)行時(shí)輸入版本參數(shù)。
    //而執(zhí)行mvn -B release:prepare -X 則可以通過程序直接執(zhí)行。但是若要自定義版本信息則需要配置pom release plugin的參數(shù),或采用如下命令
    //實(shí)際執(zhí)行的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環(huán)境變量地址
        String m2Path = System.getenv("MAVEN_HOME");
        System.out.println("m2Path:"+m2Path);
        invoker.setMavenHome(new File(m2Path));
        try {
            //該版本tag信息
            String tag = "VersiongControlDemo-0.4.0";
            //此次發(fā)布的版本號(hào)
            String version = "0.4.0";
            //下一次版本的快照版本號(hào)
            String developmentVersion="0.4.1-SNAPSHOT";

            List<String> goals = 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;
        }
    }
}

運(yùn)行測(cè)試demo。結(jié)果成功。(每次運(yùn)行前都要注意版本參數(shù),切勿沖突。)

同理可配置release:rollback等相關(guān)回滾命令。

到此這篇關(guān)于Springboot 整合maven插口調(diào)用maven release plugin。實(shí)現(xiàn)一鍵打包功能。的文章就介紹到這了,更多相關(guān)Springboot 整合maven 一鍵打包內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

龙州县| 连州市| 东海县| 鄯善县| 平阴县| 松潘县| 财经| 全南县| 商河县| 蓬莱市| 且末县| 桦川县| 卫辉市| 郸城县| 岳普湖县| 蒙城县| 慈溪市| 民乐县| 广安市| 利川市| 清河县| 大关县| 万载县| 九龙城区| 巴林右旗| 玛纳斯县| 临海市| 平山县| 萨嘎县| 福州市| 牟定县| 吐鲁番市| 东港市| 沾益县| 皋兰县| 厦门市| 隆安县| 丹寨县| 商河县| 保康县| 晴隆县|