Question

I am using Maven to build my GWT project. I am using Gin to generate some boilerplate code:

package com.lokur.motd.client.events;

import com.gwtplatform.dispatch.annotation.GenEvent;

@GenEvent
public class EditorChange {
}

But, when I run "mvn clean install" command, Maven is generating Gin related Java source in the target/classes/com/lokur/motd/client/events directory. Why are there .java files going into the classes directory?

I'm using the Maven plug-ins below to generate Java source in the target/generated-sources folder:

<plugin>
    <groupId>org.bsc.maven</groupId>
    <artifactId>maven-processor-plugin</artifactId>
    <version>2.0.5</version>
    <executions>
        <execution>
            <id>process</id>
            <goals>
                <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>target/generated-sources/apt</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

In this case, two EditorChangeEvent.java files are getting generated: one in generated-sources folder; another in target/classes/<..package..> folder. Thus, causing below compilation failure:

duplicate class:
com.lokur.motd.client.events.EditorChangeEvent
Était-ce utile?

La solution

Though could not make out why the "Java Source files" were going into the "classes" directory, the issue was with the version of GWT supported by our project. It did not support @GenEvent as the project was not configured to use Gin. So, created Event and Handler classes manually instead of relying on Gin's annotations. Now, it works well. Closing this thread.

Autres conseils

The problem is that the org.bsc.maven.maven-processor-plugin and the compiler plugin are generating the (same) sources to different folders. The solution is to disable one processor. In my solution I disabled the org.bsc.maven.maven-processor-plugin link.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top