“duplicate class” on boilerplate generation (GWTP) with maven

女生的网名这么多〃 提交于 2019-12-09 01:26:39

问题


After using the boilerplate mechanisms of GWTP I get the error that the classes (which where generated) are already existing.

The folder target/generated-sources contains "annotations" and "apt" but no "gwt". Both folders "annotations" and "apt" have the same content.

my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>de.s.pp</groupId>
    <artifactId>projectplanning</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>Projekt Planung</name>
    <description>Basic GWTP application</description>

    <properties>
        <!-- client -->
        <gwt.version>2.7.0</gwt.version>
        <gwtp.version>1.4</gwtp.version>
        <gin.version>2.1.2</gin.version>

        <!-- server -->
        <guice.version>3.0</guice.version>

        <!-- testing -->
        <junit.version>4.11</junit.version>
        <jukito.version>1.1</jukito.version>

        <!-- maven -->
        <gwt-maven-plugin.version>2.7.0</gwt-maven-plugin.version>
        <maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
        <maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
        <maven-resources-plugin.version>2.7</maven-resources-plugin.version>
        <maven-processor-plugin.version>2.0.5</maven-processor-plugin.version>
        <maven-build-helper-plugin.version>1.7</maven-build-helper-plugin.version>

        <source.jdk>1.6</source.jdk>
        <target.jdk>1.6</target.jdk>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
    </properties>

    <build>
        <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>${project.build.directory}/generated-sources/apt</directory>
            </resource>
            <resource>
                <directory>${project.build.directory}/generated-sources/gwt</directory>
            </resource>
        </resources>

        <plugins>

            <!-- Run annotation processors on src/home/java sources -->
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>2.2.4</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.gwtplatform</groupId>
                        <artifactId>gwtp-processors</artifactId>
                        <version>${gwtp.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!-- Copy the generated classses -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.5</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>
                                <source>${project.build.directory}/generated-sources/gwt</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>



            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${source.jdk}</source>
                    <target>${target.jdk}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>

            </plugin>
            <!-- JUnit Testing - skip *.GwtTest cases -->
            <!-- 'mvn test' - runs the Jukito tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                    <excludes>
                        <exclude>**/*GwtTest.java</exclude>
                    </excludes>
                </configuration>
            </plugin>

            <!-- GWT -->
            <!-- 'mvn gwt:run' - runs development mode -->
            <!-- 'mvn gwt:debug' - runs debug mode -->
            <!-- 'mvn gwt:compile' - compiles gwt -->
            <!-- 'mvn integration-test' - runs the gwt tests (*GwtTest.java) -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwt.version}</version>
                <configuration>
                    <!-- With multiple tests use GwtTestSuite.java for speed -->
                    <includes>**/*GwtTest.java</includes>
                    <extraJvmArgs>-Xss1024K -Xmx1024M -XX:MaxPermSize=256M</extraJvmArgs>

                    <copyWebapp>true</copyWebapp>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>

                    <!-- <logLevel>DEBUG</logLevel> -->
                    <runTarget>index.html</runTarget>
                    <modules>
                        <module>de.s.pp.projectplanning</module>
                    </modules>
                </configuration>
                <executions>
                    <execution>
                        <id>compileAndTest</id>
                        <goals>
                            <goal>compile</goal>
                            <goal>test</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>packageGeneration</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-maven-plugin</artifactId>
                <version>3.2.0-release</version>
                <configuration>
                    <fork>false</fork>
                    <api>JDO</api>
                    <!-- <ddlFile>${basedir}/servicecenter.ddl</ddlFile> -->
                    <props>${basedir}/datanucleus.properties</props>
                    <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings 
                    only. It has no influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.datanucleus
                                        </groupId>
                                        <artifactId>
                                            datanucleus-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [3.2.0-release]
                                        </versionRange>
                                        <goals>
                                            <goal>enhance</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.bsc.maven</groupId>
                                        <artifactId>
                                            maven-processor-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.2.4,)
                                        </versionRange>
                                        <goals>
                                            <goal>process</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>

                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.bsc.maven</groupId>
                                        <artifactId>maven-processor-plugin</artifactId>
                                        <versionRange>[2.2.4,)</versionRange>
                                        <goals>

                                            <goal>generate-sources</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute />
                                    </action>
                                </pluginExecution>





                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.codehaus.mojo
                                        </groupId>
                                        <artifactId>
                                            build-helper-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.5,)
                                        </versionRange>
                                        <goals>
                                            <goal>add-source</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <!-- Google Web Toolkit -->
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwt.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwt.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- GWT-Platform -->

        <!-- MVP component -->
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-mvp-client</artifactId>
            <version>${gwtp.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Dispatch component -->
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-rpc-client</artifactId>
            <version>${gwtp.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-rpc-server-guice</artifactId>
            <!-- Or, if you use spring: <artifactId>gwtp-dispatch-server-spring</artifactId> -->
            <version>${gwtp.version}</version>
        </dependency>

        <!-- Crawler component -->
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-crawler</artifactId>
            <version>${gwtp.version}</version>
        </dependency>

        <!-- Annotation component -->
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-processors</artifactId>
            <version>${gwtp.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Tester component -->
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-tester</artifactId>
            <version>${gwtp.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- DI -->
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>${guice.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-servlet</artifactId>
            <version>${guice.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-assistedinject</artifactId>
            <version>${guice.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt.inject</groupId>
            <artifactId>gin</artifactId>
            <version>${gin.version}</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jukito</groupId>
            <artifactId>jukito</artifactId>
            <version>${jukito.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Guava -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>16.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-gwt</artifactId>
            <version>16.0</version>
        </dependency>

        <!-- Database -->
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>[3.2.0, 3.2.99)</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jdo</artifactId>
            <version>[3.2.0, 3.2.99)</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-rdbms</artifactId>
            <version>[3.2.0, 3.2.99)</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>2.2.9</version>
        </dependency>
        <dependency>
            <groupId>org.mindrot</groupId>
            <artifactId>jbcrypt</artifactId>
            <version>0.3m</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.11</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-guice</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-web</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.10-beta1</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>maven-restlet</id>
            <name>Public online Restlet repository</name>
            <url>http://maven.restlet.org</url>
        </repository>
        <repository>
            <id>mvnrepository</id>
            <name>Public online Restlet repository</name>
            <url>http://mvnrepository.com/artifact</url>
        </repository>
    </repositories>
</project>

The output:

[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Projekt Planung 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> gwt-maven-plugin:2.7.0:run (default-cli) @ projectplanning >>>
[INFO] 
[INFO] --- maven-processor-plugin:2.2.4:process (process) @ projectplanning ---
[WARNING] No processors specified. Using default discovery mechanism.
[INFO] 
[INFO] --- build-helper-maven-plugin:1.5:add-source (add-source) @ projectplanning ---
[INFO] Source directory: C:\Workspaces\s\projectplanning\target\generated-sources\apt added.
[INFO] Source directory: C:\Workspaces\s\projectplanning\target\generated-sources\gwt added.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ projectplanning ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 57 resources
[INFO] Copying 2 resources
[INFO] skip non existing resourceDirectory C:\Workspaces\s\projectplanning\target\generated-sources\gwt
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ projectplanning ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 187 source files to C:\Workspaces\s\projectplanning\target\projectplanning-1.0-SNAPSHOT\WEB-INF\classes
[INFO] /C:/Workspaces/s/projectplanning/src/main/java/de/s/pp/server/security/UserPermissionActionValidator.java: C:\Workspaces\s\projectplanning\src\main\java\de\s\pp\server\security\UserPermissionActionValidator.java uses unchecked or unsafe operations.
[INFO] /C:/Workspaces/s/projectplanning/src/main/java/de/s/pp/server/security/UserPermissionActionValidator.java: Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Workspaces/s/projectplanning/target/generated-sources/apt/de/s/pp/shared/dispatch/actionresult/GetAllClustersResult.java:[7,8] duplicate class: de.s.pp.shared.dispatch.actionresult.GetAllClustersResult
[ERROR] /C:/Workspaces/s/projectplanning/target/generated-sources/annotations/de/s/pp/shared/dispatch/actionresult/GetAllClustersAction.java:[5,8] duplicate class: de.s.pp.shared.dispatch.actionresult.GetAllClustersAction
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.458 s
[INFO] Finished at: 2015-01-20T18:11:43+01:00
[INFO] Final Memory: 30M/277M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project projectplanning: Compilation failure: Compilation failure:
[ERROR] /C:/Workspaces/s/projectplanning/target/generated-sources/apt/de/s/pp/shared/dispatch/actionresult/GetAllClustersResult.java:[7,8] duplicate class: de.s.pp.shared.dispatch.actionresult.GetAllClustersResult
[ERROR] /C:/Workspaces/s/projectplanning/target/generated-sources/annotations/de/s/pp/shared/dispatch/actionresult/GetAllClustersAction.java:[5,8] duplicate class: de.s.pp.shared.dispatch.actionresult.GetAllClustersAction
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

回答1:


The problem was that the maven-processor-plugin and the maven-compiler-plugin where generating the (same) sources to different folders. The solution is to disable one processor. I decided that the maven-processor-plugin will be disabled.

The other option is to add <compilerArgument>-proc:none</compilerArgument> to the maven-compiler-plugin. This has the benifit that mvn generate-sources is working.



来源:https://stackoverflow.com/questions/28051289/duplicate-class-on-boilerplate-generation-gwtp-with-maven

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