java 批量上傳mvn本地倉庫

我就是曹總發表於2020-02-23

importjava.io.File;
importjava.util.Iterator;
importjava.util.LinkedList;
 
 
/**
 * 功能:生成maven批量安裝jar的語句
 * [url=home.php?mod=space&uid=686208]@AuThor[/url] pactera
 *
 */
publicclassaddjarToMaven {
     
    //批量安裝jar所在目錄
//  public static String filePath = "D:/develop/apache-tomcat-8.0.9/apache-tomcat-8.0.9/webapps/activiti-rest/WEB-INF/lib";
    publicstaticString filePath ="E:/開發資料/工作流/activity/activiti-5.22.0/libs";
     
    publicstaticvoidmain(String[] args) {
        LinkedList<File> linkedList =newLinkedList<>();
        File f =newFile(filePath); 
        File[] file = f.listFiles();
        for(inti =0; i < file.length; i++) {
            linkedList.add(file[i]);
        }
//      printFile(linkedList);
        printFiles(linkedList);
    }
     
    /**
     * 功能:批量安裝maven的本地的jar
     * @param args
     */
    publicstaticvoidprintFile(LinkedList<File> linkedList) {
        String sb ="mvn install:install-file -Dfile="+filePath+"/AA.jar -DgroupId=com.activiti -DartifactId=com.activiti.AA -Dversion=1.0.0 -Dpackaging=jar";
        for(Iterator<File> iterator = linkedList.iterator(); iterator.hasNext();) {
            File file =  iterator.next();
            if(file.isFile()){
                String fileName = file.getName();
                System.out.println(sb.replace("AA",fileName.substring(0,fileName.lastIndexOf("."))));
                linkedList.remove(file);
                printFile(linkedList);
            }else{
                break;
            }
        }
    } 
     
     
    /**
     * 功能:批量引入maven的pom
     * @param args
     */
    publicstaticvoidprintFiles(LinkedList<File> linkedList) {
        String sb ="<dependency><groupId>com.activiti</groupId><artifactId>com.activiti.BBB</artifactId><version>1.0.0</version><type>jar</type></dependency>";
        for(Iterator<File> iterator = linkedList.iterator(); iterator.hasNext();) {
            File file =  iterator.next();
            if(file.isFile()){
                String fileName = file.getName();
                System.out.println(sb.replace("BBB",fileName.substring(0,fileName.lastIndexOf("."))));
                linkedList.remove(file);
                printFiles(linkedList);
            }else{
                break;
            }
        }
    }
}




內容均為作者獨立觀點,不代表八零IT人立場,如涉及侵權,請及時告知。

相關文章