muyu-rule/muyu-rule-server/src/main/java/com/muyu/rule/compile/SourceCodeCompiler.java

86 lines
2.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//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<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjects(file);
// //生成编译任务
// JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, null, null, null, compilationUnits);
// //执行编译任务
// task.call();
// }
//
//
//}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//