Solution to the cyclic dependency error when building with Maven

5,801 views
Skip to first unread message

Gabriel

unread,
Oct 27, 2011, 9:14:52 AM10/27/11
to GWTP
Hi,

I found a workaround for using cyclic dependencies between presenters
and views when building with Maven - switch from javac to eclipse
compiler, which is what GWT uses anyway. I wrote a blog post detailing
the required Maven configuration: http://www.recompile.it/2011/10/replacing-javac-with-eclipse-compiler.html

I Hope it helps people.

Gabriel

Christian Goudreau

unread,
Oct 27, 2011, 2:37:31 PM10/27/11
to gwt-pl...@googlegroups.com
A second approach is to have the view interface or the ui handlers interface out of your classes :D

Cheers,
--
Christian Goudreau

Sydney

unread,
Nov 1, 2011, 11:11:33 AM11/1/11
to gwt-pl...@googlegroups.com
Thanks for the post, can you fix the minor typo you have on your site: groupid and artifactid should have capital I (i.e. groupId, artifactId). With Maven 3.0.3 the pom is not valid. BTW I am running into a maven issue because I am using annotations (@GenEvent). I have to run the compile twice to make my code compile.

mvn clean compile => cannot find symbol errors
mvn compile => works

It seems that the first compile, generate the sources, then compile everything but does not include the generated sources. In the second compile, it compiles with the generate sources. I don't understand why because I configured maven to use the generated sources folder:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.7</version> 
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals><goal>add-source</goal></goals>
            <configuration>
                <sources>
                    <source>${project.build.directory}/generated-sources/annotations</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

Any ideas?

Rob Ferguson

unread,
Nov 2, 2011, 2:12:28 AM11/2/11
to gwt-pl...@googlegroups.com
Hi,

The following works for me:

->

  ...

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

  ...

      <!-- 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>
                <!--
                <processor>com.gwtplatform.dispatch.annotation.processor.GenDtoProcessor</processor>
                <processor>com.gwtplatform.dispatch.annotation.processor.GenEventProcessor</processor>
                -->
              </processors>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Add new directory (target/generated-sources/apt) 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>

->

Cheers
Rob

http://code.google.com/p/gwt-cx/

Sydney

unread,
Nov 2, 2011, 11:15:44 AM11/2/11
to gwt-pl...@googlegroups.com
Now I can run a mvn clean compile and it works. But in Eclipse my pom.xml is not valid: 
Error executing (org.bsc.maven:maven-processor-plugin:2.0.5:process:process:generate-sources) pom.xml


Asier

unread,
Nov 3, 2011, 5:00:17 AM11/3/11
to gwt-pl...@googlegroups.com

I think you must add some lifecycle-mappings to the <build> section of your POM:

<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>

<pluginExecution>
<pluginExecutionFilter>


<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>

<versionRange>[${maven-processor-plugin.version},)</versionRange>


<goals>
<goal>process</goal>
</goals>

</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>

Regards

Sydney

unread,
Nov 3, 2011, 10:17:41 AM11/3/11
to gwt-pl...@googlegroups.com, avs...@gmail.com
Unfortunately I already have that plugin configured as you described in your previous post.

Philippe Beaudoin

unread,
Nov 3, 2011, 10:53:16 AM11/3/11
to gwt-pl...@googlegroups.com
Hi Sydney,

Looking to correct that mistake. Can you point out to the precise location where it is?

   Philippe

Sydney

unread,
Nov 3, 2011, 11:11:06 AM11/3/11
to gwt-pl...@googlegroups.com
Here is the part of my pom.xml:

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

The error is at the line <execution>. I tried with and without the processors part, it works for both with the command line but not in eclipse.

Sydney

unread,
Nov 6, 2011, 7:48:47 PM11/6/11
to gwt-pl...@googlegroups.com
Philippe, 

I created a simple project that reproduces the issue. The project is the one you can create with GWTP Plugin, I just moved the files to the correct folders to mavenize it. I also removed all jars from /src/main/webapp/lib to save spaces.

Sydney
gwtp-plugin-maven.zip

Philippe Beaudoin

unread,
Nov 24, 2011, 10:27:41 AM11/24/11
to gwt-pl...@googlegroups.com
I was looking for the typo in "groupId" and "artifactId", can't find them.
Reply all
Reply to author
Forward
0 new messages