Why is Gin generating source files in the “target/classes” directory?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 08:28:26

问题


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

回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/21326341/why-is-gin-generating-source-files-in-the-target-classes-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!