Reputation: 2185
I am trying to create a java file from scratch using AST but it is painstakingly taking me longer to finish. What I have in mind is create the java file, then create the project and package and then copy that file to that package. Is there a way to do this?
Thanks.
Upvotes: 0
Views: 979
Reputation: 7402
IFile#setContents(InputStream ...)
would seem like a good candidate.
You can also use the ImportOperation
to import files from anywhere (incl. the filesystem outside of the workspace) into a project.
Upvotes: 0
Reputation: 4406
You can use JBoss forge to generate java classes problematically. it has api to write scaffolding plugins. it uses Apache Velocity templates to do that.
Also Spring Roo can be another choice, if you are a Spring guy ;)
Upvotes: 0
Reputation: 5327
I use Apache Velocity, in order to create Java classes from templates. In my case, i had to create from (velocity) templates some classes (and maven pom) using Eclipse Wizards. But if you want to modify these classes, then the best choice would be AST/JDT.
http://sdqweb.ipd.kit.edu/wiki/JDT_Tutorial:_Creating_Eclipse_Java_Projects_Programmatically
shows how to create a java project using JDT and configure your classpaths subsequently.
Upvotes: 1