Generate code with Groovy Template

Source: Internet
Author: User
Tags version

This is my colleague, in the case of extremely poor documentation, to pay tribute to what stones out.

1.Groovy Current development status groovy has been released as scheduled the last one is a version of the classic parser-beta10, the future version will be based on the JSR standard parser, is expected to send three JSR version, one per month, in the year may have a formal version out.

The plug-ins for Eclipse and idea are also being developed, and not all of them are very selective, for example, idea can only run on the IEDA5.0 EAP version.

2.Groovy template and built-in XML syntax the links on the official website: Groovy Templates, Gpath Groovy template like JSP, but with all the advantages of dynamic languages. "Groovy: Using Groovy template for MVC programming" at IBM Chinese station

Gpath is a built-in XML access syntax, very simple, two typical ways to use are as follows: characters = Book.characterfor (c in characters) {println c[' @name ']} and character = book.character.find {it[' @id '] = = ' 2 '}

3. Invoke Groovy in Ant

Call template with groovy file in IBM's article. The code for calling this groovy file in Java is as follows: Binding Binding = new Binding (); Groovyshell shell = new Groovyshell (binding); Script script = Shell.parse (new File ("Groovy/gpath.groovy")); Script.run ();

If you pursue speed, you can complie the groovy file into a class file with Groovyc

4. Insufficient: According to colleagues, 1. Templates cannot use Import statements and must write full path 2 of the class. <% > No escape characters 3.xml syntax, nodes can only get children (), can not get parent ()

is not a difficult thing, I believe that the successor version will improve.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.