forked from JavaTX/JavaCompilerCore
[Bytecde] Generate new directory if given output path doesnt exist yet
This commit is contained in:
parent
af5b23e31a
commit
a3b4ea9b1c
@ -793,7 +793,9 @@ public class JavaTXCompiler {
|
|||||||
System.out.println("generating " + name + ".class file ...");
|
System.out.println("generating " + name + ".class file ...");
|
||||||
// output = new FileOutputStream(new File(System.getProperty("user.dir") +
|
// output = new FileOutputStream(new File(System.getProperty("user.dir") +
|
||||||
// "/testBytecode/generatedBC/" +name+".class"));
|
// "/testBytecode/generatedBC/" +name+".class"));
|
||||||
output = new FileOutputStream(new File(path + File.separator + name.getClassName() + ".class"));
|
File outputFile = new File(path + File.separator + name.getClassName() + ".class");
|
||||||
|
outputFile.getParentFile().mkdirs();
|
||||||
|
output = new FileOutputStream(outputFile);
|
||||||
output.write(bytecode);
|
output.write(bytecode);
|
||||||
output.close();
|
output.close();
|
||||||
System.out.println(name + ".class file generated");
|
System.out.println(name + ".class file generated");
|
||||||
|
@ -22,4 +22,17 @@ public class Bytecode extends TestCase {
|
|||||||
f = new File(rootDirectory + "TestClass.class");
|
f = new File(rootDirectory + "TestClass.class");
|
||||||
assertTrue(f.exists());
|
assertTrue(f.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetPackageNameInBytecodeAndOutputFolder() throws IOException, ClassNotFoundException {
|
||||||
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"packageNameTest.jav"));
|
||||||
|
compiler.typeInference();
|
||||||
|
File f = new File(rootDirectory + "output/de/test/TestClass.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
compiler.generateBytecode(rootDirectory + "output/");
|
||||||
|
f = new File(rootDirectory + "output/de/test/TestClass.class");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user