//package com.muyu.rule.compile; // //import com.muyu.rule.scan.JavaCodeScan; //import io.jsonwebtoken.io.IOException; // //import javax.tools.JavaCompiler; //import javax.tools.JavaFileObject; //import javax.tools.StandardJavaFileManager; //import javax.tools.ToolProvider; //import java.io.File; //import java.io.FileNotFoundException; //import java.nio.file.Files; // ///** // * java源码编译工具 // */ //public class SourceCodeCompiler { // // // /** // * 1.获取系统java编译器 // */ // private static JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); // /** // * 获取JAVA文件管理器 // */ // private static StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); // // /** // * 输入编译的文件夹路径 // * // * @param path 文件夹路径 // */ // public static void javaCompilerPath(String path) { // File[] files = JavaCodeScan.javaSourceScanByPath(path); // //进行编译 // javaCompiler(files); // } // // /** // * 输入编译的文件夹路径 // * // * @param filePath // */ // public static void javaCompilerFile(String... filePath) { // int filesPathLength = filePath.length; // File[] files = new File[filesPathLength]; // //定义要编译的源文件 // for (int i = 0; i < filesPathLength; i++) { // files[i] = new File(filePath[i]); // } // } // /** // *可同时编译多个java源文件 // * @param file // */ // public static void javaCompiler(File... file) { // //通过源文件获取到要编译的java类源码迭代器,包括所有内部类,其中每个类都是一个 javaFileObject,也被称为一个汇编单元 // Iterable compilationUnits = fileManager.getJavaFileObjects(file); // //生成编译任务 // JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, null, null, null, compilationUnits); // //执行编译任务 // task.call(); // } // // //} // // // // // // // // // // // // // // // // // //