BoilerplateGeneration maven configuration

949 views
Skip to first unread message

Gabriel

unread,
Oct 10, 2010, 2:00:08 AM10/10/10
to GWTP
Hi, I'm new in the forum and my english is really bad, I hope I can
express myself well.

I started developing a small test application using GWTP and Maven.
One of the problems that I could not overcome is the annotation GWTP
settings (http://code.google.com/p/gwt-platform/wiki/
BoilerplateGeneration).

What is the correct way to setup a Maven project (pom.xml) to use
BoilerplateGeneration of GWTP?

Christian Goudreau

unread,
Oct 10, 2010, 10:35:12 AM10/10/10
to gwt-pl...@googlegroups.com
Unfortunatly, I can't help you with this one :( But a good start would be to use maven apt plugin. After that point... if you find aything, post it, we'll be glad to add it to the documentation !

Btw, me and philippe speaks french and your english seems to be better than mine ! lol

Cheers,
--
Christian Goudreau

Philippe Beaudoin

unread,
Oct 10, 2010, 3:02:03 PM10/10/10
to gwt-pl...@googlegroups.com
Not sure, but with ant, the apt target was not required. It was used
with older versions of Java that did not have annotation processors
built-in.

Philippe

Harald Pehl

unread,
Oct 10, 2010, 4:29:05 PM10/10/10
to GWTP
Hi Gabriel,

I successfully setup a maven based project with GWTP and APT
processing. However initially I had problems with the APT plugin from
codehaus (http://mojo.codehaus.org/apt-maven-plugin/), so I switched
to the maven-annotation-plugin (http://code.google.com/p/maven-
annotation-plugin/). You can take a look at my pom at
http://code.google.com/p/tire-d8/source/browse/trunk/app/pom.xml.

- Harald

On 10 Okt., 21:02, Philippe Beaudoin <philippe.beaud...@gmail.com>
wrote:

Gabriel

unread,
Oct 10, 2010, 6:20:46 PM10/10/10
to GWTP
Hi Harald, thanks for the reply.

To generate the code I need to run a Maven command? like generate-
sources?
I use Eclipse, when I run maven in generate-sources mode I get god
results.

On Oct 10, 5:29 pm, Harald Pehl <harald.p...@googlemail.com> wrote:
> Hi Gabriel,
>
> I successfully setup a maven based project with GWTP and APT
> processing. However initially I had problems with the APT plugin from
> codehaus (http://mojo.codehaus.org/apt-maven-plugin/), so I switched
> to the maven-annotation-plugin (http://code.google.com/p/maven-
> annotation-plugin/). You can take a look at my pom athttp://code.google.com/p/tire-d8/source/browse/trunk/app/pom.xml.

Harald Pehl

unread,
Oct 11, 2010, 3:23:25 PM10/11/10
to GWTP
That's right the plugin binds by default to the generate-sources
phase.

- Harald

Sydney

unread,
Feb 8, 2011, 9:37:52 PM2/8/11
to gwt-pl...@googlegroups.com
I think using maven-compiler-plugin 2.2 that handles APT is easier. At least my project compiles. Can a maven expert confirm?

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<includes>
<include>${project.build.directory}/generated-sources/annotations/**</include>
</includes>
</configuration>
</plugin>

Warren Tang

unread,
Sep 16, 2011, 12:14:37 PM9/16/11
to gwt-pl...@googlegroups.com
I've tried a lot but failed to make the "mvn gwt:compile" to run. It cannot find the source code for the generated actions and results. 

Has anyone made it work? My pom.xml file is attached.
pom.xml

Philippe Beaudoin

unread,
Sep 16, 2011, 3:25:21 PM9/16/11
to gwt-pl...@googlegroups.com
Some of the GWTP samples do it, maybe you can use them as inspiration?

Rob Ferguson

unread,
Sep 16, 2011, 8:08:08 PM9/16/11
to gwt-pl...@googlegroups.com
Hi Warren,

Phillipe is right, the best way to work out what your pom.xml is missing is to compare it with other POMs.

For example, gwt-cx bundles the "generated sources" (e.g. actions and results) with the gwtcx-core-shared.jar.

The pom.xml:

->

  ...

  <artifactId>gwtcx-core-shared</artifactId>
  <packaging>jar</packaging>
  <name>GWTCX Core - Shared</name>

  <properties>
    <generated-sources>target/generated-sources/apt</generated-sources>
  </properties>

  <build>
    <resources>

      ...

      <!-- bundle generated sources with the jar, so they are visible to GWT's compiler -->
      <resource>
        <directory>${generated-sources}</directory>
        <includes>
          <include>**/*.java</include>
        </includes>
      </resource>
     
      ...

    </resources>

    <plugins>

      <!-- Maven Eclipse Plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <useProjectReferences>true</useProjectReferences>
          <additionalConfig>
            <file>
              <name>.factorypath</name>
              <content><![CDATA[
                <factorypath>
                  <factorypathentry kind="VARJAR" id="M2_REPO/com/gwtplatform/gwtp-processors/${gwt.version}/gwtp-processors-${gwt.version}.jar" enabled="true" runInBatchMode="false" />
                </factorypath>
              ]]></content>
            </file>
            <file>
              <name>.settings/org.eclipse.jdt.apt.core.prefs</name>
              <content><![CDATA[
                eclipse.preferences.version=1
                org.eclipse.jdt.apt.aptEnabled=true
                org.eclipse.jdt.apt.genSrcDir=${generated-sources}
                org.eclipse.jdt.apt.reconcileEnabled=true
              ]]></content>
            </file>
          </additionalConfig>
        </configuration>
      </plugin>

      <!-- Disable annotation processors during normal compilation -->

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <proc>none</proc>
        </configuration>
      </plugin>

      <!-- Run annotation processors on src/main/java sources -->
      <plugin>
        <groupId>org.bsc.maven</groupId>
        <artifactId>maven-processor-plugin</artifactId>
        <executions>
          <execution>
            <id>process</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <outputDirectory>${generated-sources}</outputDirectory>
              <processors>
                <processor>com.gwtplatform.dispatch.annotation.processor.GenDispatchProcessor</processor>
              </processors>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Add new directory (target/generated) to the classpath -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.3</version>
        <configuration>
          <sources>
            <source>${generated-sources}</source>
          </sources>
        </configuration>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>

  </build>

->

Cheers
Rob

Warren Tang

unread,
Sep 17, 2011, 11:54:20 AM9/17/11
to gwt-pl...@googlegroups.com
Hi, Rob

Thanks for the sample pom.xml file. The <build><resources><resource> tag makes a difference. It is not included in the gwtp-samples so "mvn gwt:compile" won't pass on them.

Still there are some confusions I've been trying to figure out:

1. "maven-eclipse-plugin" and "m2eclipse" are not related at all, are they? Because executing "mvn eclipse:eclipse" and "Project > Maven > Update Project Configuration" produce discrepancies. Currently I'm avoiding both commands.
2. As I'm typing in the editor, the annotations are not processed on the fly, right? I'm using java 1.6 and the eclipse doc says so, and it is the same as what I observed. So I have to manually invoke generate-resources directly or indirectly, which is incontinent, especially when debugging.

Based on these observations, I've simplified pom.xml as follows:

1. I removed maven-eclipse-plugin configurations all together. Because I'm not planning to use "mvn eclipse:eclipse" so this command is useless.
2. I removed build-helper-maven-plugin. After the initial "Eclipse > File > Import > Maven > Existing maven project", I add "apt" folder to classpath manually, and I won't invoke "Update Project Configuration" again.

The modified pom.xml is attached (with removed plugins commented out). I do want to keep the pom.xml simple and thus avoid introducing uncanny problems.

As this is the first time I use maven and gwtp, please do correct me if I'm wrong.

Regards,
Warren Tang
pom.xml

Warren Tang

unread,
Sep 17, 2011, 12:00:21 PM9/17/11
to gwt-pl...@googlegroups.com
The gwtp samples are the best references for me!  However they do not support "mvn gwt:comple" as said in my reply to Rob. Adding <build><resources><resource> tag correct it.

Rob Ferguson

unread,
Sep 17, 2011, 7:36:43 PM9/17/11
to gwt-pl...@googlegroups.com
Hi,

As previously mentioned, the best way to work out what your pom.xml requires is to compare it with other POMs.

If you can't find what you need in the gwtp samples then make sure you take a look at gwtp's POMs (or the gwt-cx POMs).

1. They are to separate plugins with two different objectives. The gwt-maven-plugin (or m2eclipse) from codehaus.org provides a bridge/link between Maven (a command line tool) and the Eclipse IDE.

The maven-eclipse-plugin is used to generate the artifacts (*.classpath, *.wtpmodules and the .settings folder) required by the Eclipse IDE. It is useful when you are migrating projects from another environment to Eclipse or to configure Eclipse from your project's POM.

2. Annotation processing can be enabled within Eclipse (check the gwtp wiki) and enabled in a POM (see previous post). The annotation processors are invoked during a build. So if you modify a file in the Eclipse IDE and you have the project setup to "Project -> Build Automatically" then the generated-sources will be updated.

Don't be too worried about getting your POMs perfect first time. As you learn more about Maven, GWT, GWTP, gin, guice, etc. you will keep revisiting them as your project evolves.

Cheers
Rob

Pierre-Henry Perret

unread,
Oct 6, 2011, 10:51:36 AM10/6/11
to gwt-pl...@googlegroups.com

Harald

I have succesfully installed your project in Eclipse, but needed to modify Java Build Path to get rid of IDE compiler complaining it cant find ui resources - even if apprently IS in the classpath - 
I had to add the WEB-INF/classes path and remove src/main/resources  which seems to ignored.

Also , the gwtp dispatch lib seems to ignored as well.

Then it leaves an DefaultProxyFailureHandler and ProxyFailureHandler.

Thanks,
Pierre

Carlos Alexandro Becker

unread,
Apr 24, 2012, 4:07:56 PM4/24/12
to gwt-pl...@googlegroups.com

Hi Rob,

I see your post is a little old... this still configuration working?
Another thing, it work with a multi-module project?

Cheers

Rob Ferguson

unread,
Apr 24, 2012, 8:14:57 PM4/24/12
to gwt-pl...@googlegroups.com
Hi,

Both GWTP and gwt-cx use Maven multi-module projects.

You can check out the source and build them from the command line (e.g. mvn clean install) or from within Eclipse.

These posts may help:

-> http://uptick.com.au/content/getting-started-gwt-maven-and-eclipse

-> http://uptick.com.au/content/gwt-cx-maven-multimodule-enterprise-project

-> http://www.sonatype.com/books/mvnex-book/reference/multimodule.html

Cheers
Rob

http://code.google.com/p/gwt-cx/
Reply all
Reply to author
Forward
0 new messages