为什么Gin在“目标/类”中生成源文件?目录? [英] Why is Gin generating source files in the "target/classes" directory?

查看:162
本文介绍了为什么Gin在“目标/类”中生成源文件?目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Maven构建我的GWT项目。我使用杜松子酒来生成一些样板代码:

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 {
}



<但是,当我运行mvn clean install命令时,Maven在 target / classes / com / lokur / motd / client / events 目录中生成与Gin相关的Java源代码。为什么 .java 文件进入目录?

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?

我使用下面的Maven插件在 target / generated- sources 文件夹中生成Java源代码:

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>

在这种情况下,两个 EditorChangeEvent.java 文件正在生成:一个在 generated-sources 文件夹中;另一个位于 target / classes /< .. package ..> 文件夹中。
因此,导致编译失败:

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


推荐答案

虽然无法弄清楚为什么 Java源文件正在进入classes目录,问题在于我们项目支持的GWT版本。
由于该项目未配置为使用杜松子酒,因此它不支持@GenEvent。因此,手动创建了Event和Handler类,而不是依赖于Gin的注释。现在,它运作良好。关闭此主题。

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.

这篇关于为什么Gin在“目标/类”中生成源文件?目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆