maven批量引入自己安装的本地jar

1.执行代码
package com.activiti.demo;

import java.io.File;
import java.util.Iterator;
import java.util.LinkedList;


/**
* 功能:生成maven批量安装jar的语句
* @author pactera
*
*/
public class MyTest {

//批量安装jar所在目录
// 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:/开发资料/工作流/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);
}

/**
* 功能:批量安装maven的本地的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;
}
}
}


/**
* 功能:批量引入maven的pom
* @param args
*/
public static void printFiles(LinkedList<File> linkedList) {
String sb = "<dependency><groupId>com.activiti</groupId><artifactId>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.安装完批量jar后,更新索引,然后把执行引入jar的内容粘贴至pom文件即可

说明:本案例仅供参考

猜你喜欢

转载自chuichuige.iteye.com/blog/2388701
今日推荐