zno2

一键修改pom 版本号

 

package cn.zno.version;

import java.io.File;
import java.nio.charset.Charset;

import cn.zno.ambi.bas.util.FileUtils;
import cn.zno.ambi.bas.xml.XmlUtils;

public class Main {

    public static void main(String[] args) {
        if (args.length == 0) {
            System.out.println("Please set version num");
            return;
        }
        System.out.println("新版本号:" + args[0]);
        String property = System.getProperty("user.dir");
        System.out.println("当前目录:" + property);
        File folder = new File(property);
        File[] search = FileUtils.search("pom\\.xml", folder);
        for (File file : search) {
            String qualified = FileUtils.qualified(file);
            System.out.println("next:" + qualified);
            String xxxx = XmlUtils.getElementText(file, Charset.forName("utf-8"), "project.version");
            if (!(xxxx == null) && !xxxx.equals(args[0])) {
                System.out.println("【project.version】【"+xxxx+"】---->【"+args[0]+"】");
                XmlUtils.setElementText(file, Charset.forName("utf-8"), "project.version", args[0]);
            }
            String yyyy = XmlUtils.getElementText(file, Charset.forName("utf-8"), "project.parent.version");
            if (!(yyyy == null)&& !yyyy.equals(args[0])) {
                System.out.println("【project.parent.version】【"+yyyy+"】---->【"+args[0]+"】");
                XmlUtils.setElementText(file, Charset.forName("utf-8"), "project.parent.version", args[0]);
            }
        }
    }

}

 

posted on 2023-06-06 12:42  zno2  阅读(75)  评论(0编辑  收藏  举报

导航