Create a tool for dynamically generating code in Java (in eclipse)

In visual studio, I was able to define a structure in the XSD file and add a special attribute to it, which will cause it to be dynamically compiled and available for IntelliSense in other c# files in the application I'm not sure the exact meaning of the word, maybe "dynamic code generation"

I'm trying to do the same in Java using the eclipse ide Basically, what I'm looking for is a tool that allows me to specify some templates in the "hot folder" and generate java code from them, which will allow me to complete the code in other static java files

Who knows this solution? I know it's possible in visual studio, but I can't seem to find anything for eclipse

OK, that's what I want to do

Step 1 I create a folder called templates. Step 2 I created a file called helloword Ibes file step 3 In my SRC folder HelloWorld Automatic code generation in Java

I hope I can do this easily during the eclipse

Solution

You can create an ant build file to generate source code for you Then you are free to use any code generator you like Ant support is part of the eclipse ide If you prefer maven, you can use a good eclipse (this is my actual source code generation based on JAXB, JavaCC and XDoclet...)

Technically, you just need to add another eclipse builder, which can be called whenever eclipse detects changes in the code base

If you've considered code generators, just "ask" if plug-ins are available on the Internet

edit

About how to install the Builder: This is done automatically For maven, you simply install the Maven plug-in (m2eclipse) and enable Maven dependencies for your project Then, if you look at the project properties page (builder section), you will find a second entry in the builder list

It is similar to ants and even easier because ants have integrated Enable ant for the project and add the builder to the list of builders for the project If it kills the performance or auto build switch, I can deselect it at any time (I don't know how to enable ant build for the project, but I remember that eclipse help has enough information)

All information about ants can be found here: Apache ant

Creating a new builder is difficult because it must be coded in Java and added to eclipse as a plug-in I bet you don't want to follow that track;)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>