feat():测试
parent
82ef32e43c
commit
ed6e6805e2
|
@ -31,7 +31,6 @@ public class OSSFileLoad {
|
|||
// OSS文件路径
|
||||
private static final String filePath = "build/version/rule/";
|
||||
public static Result<Object> streamingDownload(String fileName) throws IOException {
|
||||
String source = null;
|
||||
// 创建 OSSClient 实例
|
||||
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||
// 判断 bucket 是否存在
|
||||
|
@ -46,11 +45,7 @@ public class OSSFileLoad {
|
|||
return Result.error("预下载文件不存在");
|
||||
}
|
||||
// 本地文件下载路径
|
||||
String localPath = "home/"+fileName;
|
||||
// ObjectMetadata object = ossClient.getObject(new GetObjectRequest(bucketName, filePath + fileName), new File(localPath));
|
||||
// System.out.println(object);
|
||||
//
|
||||
// ossClient.shutdown();
|
||||
String localPath = "C:\\Users\\13636\\Desktop\\test\\"+fileName;
|
||||
try {
|
||||
// 从OSS下载文件
|
||||
InputStream inputStream = ossClient.getObject(bucketName, filePath+fileName).getObjectContent();
|
||||
|
@ -77,9 +72,9 @@ public class OSSFileLoad {
|
|||
|
||||
//对路径里的.java文件进行编译
|
||||
System.out.println("第一步");
|
||||
SourceCodeCompiler.javaCompilerPath("home/");
|
||||
SourceCodeCompiler.javaCompilerPath("C:\\Users\\13636\\Desktop\\test\\");
|
||||
System.out.println("第二步");
|
||||
File outputDir = new File("home/com/muyu/generate"); // 或者是你指定的其他输出目录
|
||||
File outputDir = new File("C:\\Users\\13636\\Desktop\\test\\com\\muyu\\generate\\"); // 或者是你指定的其他输出目录
|
||||
System.out.println("第三步");
|
||||
File[] classFiles = outputDir.listFiles(); // 获取输出目录中的所有文件
|
||||
if (classFiles != null) {
|
||||
|
@ -92,19 +87,7 @@ public class OSSFileLoad {
|
|||
}else {
|
||||
System.out.println("没有找到文件");
|
||||
}
|
||||
return Result.success(source);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// OSSObject ossObject = ossClient.getObject(bucketName, fileName);
|
||||
// BufferedReader reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent()));
|
||||
// while(true){
|
||||
// String line = reader.readLine();
|
||||
// source += line;
|
||||
// if (line == null) break;
|
||||
// }
|
||||
// System.out.println(source);
|
||||
// System.out.println("读取成功");
|
||||
// reader.close();
|
||||
// Map<String, byte[]> compile = OSSFileCompile.compile(fileName, source, "target/");
|
||||
|
|
|
@ -61,7 +61,7 @@ public class SourceCodeCompiler {
|
|||
//通过源文件获取到想要编译的java类源代码迭代器,包括所有的内部类,其中每一个类都是一个JavaFileObjects,也被称为一个汇编单元
|
||||
Iterable<? extends JavaFileObject> javaFileObjects = fileManager.getJavaFileObjects(file);
|
||||
//生成编译任务
|
||||
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, null, Arrays.asList("-d","home/"), null, javaFileObjects);
|
||||
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, null, Arrays.asList("-d","C:\\Users\\13636\\Desktop\\test\\"), null, javaFileObjects);
|
||||
//执行编译任务
|
||||
task.call();
|
||||
}catch (Exception e){
|
||||
|
|
Loading…
Reference in New Issue