Maven + Eclipse + RequestFactory validation tool: Duplicate class error

347 views
Skip to first unread message

Tiago Rinck Caveden

unread,
Oct 27, 2011, 9:38:06 AM10/27/11
to google-we...@googlegroups.com
Hello all,

I migrated to GWT 2.4.0 and one of the first errors I got concerned the RequestFactory validation tool that needed to be run before launching the server. As I'm using Maven, I followed the instructions available here: http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation#Maven_builds
I added the 2 plugins configurations. Didn't add the specific for Indingo as I'm using Eclipse 3.6.

That worked fine... in Eclispe.
Whenever I try to compile my project with maven through the command line, I get this:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project WEB-MODULE: Compilation failure: Compilation failure:
[ERROR] /workspace/PROJECT-ROOT/WEB-MODULE/target/generated-sources/annotations/PACKAGE_PATH/MY_REQUEST_FACTORYDeobfuscatorBuilder.java:[7,13] duplicate class: PACKAGE_PATH.MY_REQUEST_FACTORYDeobfuscatorBuilder
[ERROR] /workspace/PROJECT-ROOT/WEB-MODULE/target/generated-sources/annotations/PACKAGE_PATH/MY_REQUEST_FACTORYDeobfuscatorBuilder.java:[7,13] duplicate class: PACKAGE_PATH.MY_REQUEST_FACTORYDeobfuscatorBuilder

(I've substituted my project paths and names for the uppercase expressions above)

I've noted that this generated class is both under generated-sources/annotations and generated-sources/apt.

If I remove the plugins configuration, then I can compile with maven on the command line. But launching and using the application through Eclipse isn't possible without those plugins...

Anyone at least understand what's going on? Why this class is being generated twice and how to prevent if from happening while still launching the RF validation tool?

Thank you a lot for any help,
--
Tiago Rinck Caveden

Patrick Julien

unread,
Oct 27, 2011, 9:43:32 AM10/27/11
to google-we...@googlegroups.com
only include generated-sources/apt in your maven build using build-helper-maven-plugin

<!-- Google Plugin for Eclipse (GPE) won't see the source generated above by requestfactory-apt unless it is exposed as an additional source 
        dir -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/apt</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

For eclipse, make sure you have the m2e connector for build-helper-maven-plugin installed

Tiago

unread,
Oct 27, 2011, 10:34:33 AM10/27/11
to Google Web Toolkit
Ha, amazing!
Thank you Patrick for the fast and precise answer!

Shouldn't that doc page I linked in the OP be updated?

Best regards,
Tiago.

Patrick Julien

unread,
Oct 27, 2011, 10:46:23 AM10/27/11
to google-we...@googlegroups.com
Probably, you're always free to write a ticket to the gwt team

Thomas Broyer

unread,
Oct 27, 2011, 10:47:09 AM10/27/11
to google-we...@googlegroups.com
If maven-compiler-plugin executes the validation tool, then you don't need to call it explicitly using the exec-maven-plugin. You'd have to configure Eclipse manually though.
Or you could disable annotation processing in the maven-compiler-plugin and run the ValidationTool using the exec-maven-plugin (and m2e should execute it as soon as a file changes in your project).

Also, note that the "specific for Indigo" is actually "specific for m2e 1.0" (which, I believe, can be installed on Helios)
Reply all
Reply to author
Forward
0 new messages