0

I am using JavaPoet to generate code, here is the core part of my code snippet:

...
TypeSpec typeSpec = createTypeSpec();
JavaFile javaFile = JavaFile.builder(myPackage, typeSpec).build();

// write to file
javaFile.writeTo(filer);

// I want to call this doTask() only after the java file is written on hard disk. How to guarantee that?
doTask();

It works fine. The java file is generated on hard disk. Now I have a new requirement, I need to do some work after java file is generated on hard disk, that's call the doTask() in above code snippet. But how can I guarantee the java file is generated then start the doTask()?

Please note, when generating the java file, the corresponding packages are also created at run time. So, the directory under which the java file is located is not created at compile time.

user842225
  • 4,171
  • 6
  • 42
  • 74

0 Answers0