1. Write the code
package com.activiti.demo; import java.io.File; import java.util.Iterator; import java.util.LinkedList; /** * Function: Generate the statement of maven batch installation jar * @author pactera * */ public class MyTest { //The directory where the batch installation jar is located // public static String filePath = "D:/develop/apache-tomcat-8.0.9/apache-tomcat-8.0.9/webapps/activiti-rest/WEB-INF/lib"; public static String filePath = "E:/Development data/Workflow/activity/activiti-5.22.0/libs"; public static void main(String[] args) { LinkedList<File> linkedList = new LinkedList<>(); File f = new File(filePath); File[] file = f.listFiles(); for (int i = 0; i < file.length; i++) { linkedList.add(file[i]); } // printFile(linkedList); printFiles(linkedList); } /** * Function: batch install maven's local jar * @param args */ public static void printFile(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; } } } /** * Function: batch import maven pom * @param args */ public static void printFiles(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; } } } }
2. Enter cmd in the maven installation bin directory, then copy the console statement and press enter.