Ant configuration file (Google App Engine + GWT + JPA)

Source: Internet
Author: User
The project needs to be handed over today. As Google App Engine's JPA implementation requires enhancer, the default Eclipse plug-in will enhance compile all the classes, which is an error;
You can manually set the enhancer parameters and then manually compile the enhancer. The other method is to compile the ant or Maven plug-in provided by the official website.

After a long time, I fixed some problems and finally ran the project to the release. Here I recorded it and hoped to help it workers with the same problems.

1. The ant default compiler has used enumeration compilation errors in annotation.
/**
*
* Define annotation for bespokereference
*
* @ Author ZX
*
*/
@ Retention (retentionpolicy. runtime)
@ Target (elementtype. Method)
Public @ interface breference {

/**
*
* @ Return
*/
Referencetype type () default referencetype. customtablemodel;

/**
* Expressions like "system. username", string of modelname
* @ Return
*/
@ Suppresswarnings ("rawtypes ")
Class model ();
}

This may be only one of the errors of the default Java compiler (there will be other types of mismatched exceptions in the Project)
The solution is to directly use the jdt compiler of Eclipse.

A. Find jdtcompileradapter. JarAnd Org. Eclipse. jdt. core_3.5.2.v_9820.r35x.jar (Search Org. Eclipse. jdt. Core in eclipse directory)

B. Then put them$ {Ant_home}/lib

C.Add configuration <property name = "build. compiler" value = "org. Eclipse. jdt. Core. jdtcompileradapter"/>In builder. xml

2. the client package of GWT is compiled to the classes directory by default, but it is not required during release (a gwt project may compile more than 1000 classes, from a large number of handler anonymous classes)
The limit of Gae is exceeded during release, so before deploy, you can use ant to delete

3. JPA's enhanced compilation configuration. The official datanucleus instance is based on JDO. However, our project is based on JPA and the configuration is slightly different.

<Path id = "datanucleus. Path">
<Pathelement location = "War/WEB-INF/classes"/>

<Fileset dir = "War/WEB-INF/lib">
<Include name = "*. Jar"/>
</Fileset>

<Fileset dir = "War/WEB-INF/classes">
<Include name = "com/eyuntong/bespoke/shared/datatypes/bespokedomain. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/bespokemodel. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/bespoketable. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/bespokefield. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/bespoketype. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/rowconstraint. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/backreferences. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/bespokereference. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/bespokeoptions. Class"/>

<Include name = "com/eyuntong/bespoke/shared/datatypes/langproperties. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/langcodes. Class"/>
<Include name = "com/eyuntong/bespoke/shared/datatypes/bespokerowfile. Class"/>

<Include name = "com/eyuntong/bespoke/Server/CORE/storage/googlefile. Class"/>
<Include name = "com/eyuntong/bespoke/shared/entities/conditionsetting. Class"/>
</Fileset>

</Path>

<! -- Google App Engine targets -->
<Target name = "Enhance" depends = "javac" Description = "performs enhancement on compiled data classes.">
<Taskdef name = "datanucleusenhancer" classpathref = "datanucleus. Path" classname = "org. datanucleus. enhancer. Tools. enhancertask"/>
<Datanucleusenhancer
Classpathref = "datanucleus. path"
Failonerror = "false"
API = "JPA"
Enhancername = "ASM"
Persistenceunit = "gaejpa">
</Datanucleusenhancer>
</Target>

Manually specify the JPA entities to be compiled.

 

4. Ant support provided by Google App Engine

Dev_appserver target has a problem: Once the command window is opened, it cannot be stopped by default (from the command line, startserver, and stopserver, it is a bit strange)
There was a trick on the Gae forum, I cited it.

<Macrodef name = "dev_appserver2" Description = "runs the App Engine Development app server">
<Attribute name = "war" Description = "the exploded war directory containing the application"/>
<Attribute name = "Port" default = "8080" Description = "the port the server starts on"/>
<Attribute name = "Address" default = "localhost" Description = "the interface the server binds to"/>
<Element name = "options" Optional = "true" Description = "additional options for dev_appserver"/>
<Element name = "ARGs" Optional = "true" Description = "additional arguments for the Java task"/>
<Sequential>
<Java classname = "com. Google. appengine. Tools. Development. devappservermain" classpath = "$ {appengine. Tools. classpath}" fork = "true" failonerror = "true">
<Jvmarg value = "-dlog4j. Configuration = log4j. Props"/>
<Jvmarg value = "-javaagent: $ {appengine. SDK. Home}/lib/agent/appengine-agent.jar"/>
<Arg value = "-- Address =@{ address}"/>
<Arg value = "-- Port =@{ port}"/>
<Arg value = "@ {war}"/>
<ARGs/>
</Java>
</Sequential>
</Macrodef>

<Target name = "runserver" depends = "Enhance" Description = "starts the development server.">
<Dev_appserver2 war = "war" Port = "80"/>
</Target>

Finally, the complete builder. xml/files/herist/build. XML is provided.

By now, you may not be engaged in Gae + GWT project development any more. Use this builder to summarize it!

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.