maven手动批量安装jar包到本地仓库_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > maven手动批量安装jar包到本地仓库

maven手动批量安装jar包到本地仓库

 2017/8/8 18:31:23  一眉道人77  程序员俱乐部  我要评论(0)
  • 摘要:1.编写代码packagecom.activiti.demo;importjava.io.File;importjava.util.Iterator;importjava.util.LinkedList;/***功能:生成maven批量安装jar的语句*@authorpactera**/publicclassMyTest{//批量安装jar所在目录//publicstaticStringfilePath="D:/develop/apache-tomcat-8.0.9/apache-tomcat
  • 标签:安装 Maven

1.编写代码

?

?

class="java">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>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.在maven的安装bin目录上输入cmd,然后拷贝控制台语句,按下enter键即可

发表评论
用户名: 匿名