使用Maven生成GWTP Boilerplate - 构建成功不一致

时间:2015-10-12 18:26:36

标签: eclipse maven gwt boilerplate gwtp

我对Maven很新,但我使用它是因为这是GWTP插件在创建新项目时所提供的内容。我有一些使用@GenDto注释创建的DTO。以下是我的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>com.test</groupId>
    <artifactId>MyProject</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>MyProject</name>

    <properties>
        <!-- client -->
        <gwt.version>2.7.0</gwt.version>
        <gwtp.version>1.5</gwtp.version>
        <gin.version>2.1.2</gin.version>
        <!-- server -->
        <guice.version>3.0</guice.version>
        <resteasy.version>3.0.13.Final</resteasy.version>
        <jbcrypt.version>0.3m</jbcrypt.version>
        <jax-rs.version>1.1.1</jax-rs.version>
        <arcbees.version>1.2</arcbees.version>

        <!-- testing -->
        <junit.version>4.12</junit.version>
        <jukito.version>1.4.1</jukito.version>

        <!-- maven -->
        <gwt-maven-plugin.version>2.7.0</gwt-maven-plugin.version>
        <maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
        <maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
        <maven-war-plugin.version>2.5</maven-war-plugin.version>
        <maven-resources-plugin.version>2.5</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>

        <target.jdk>1.7</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>

        <pluginManagement>
            <plugins>

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

                <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</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>${target.jdk}</source>
                        <target>${target.jdk}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <compilerArgument>-proc:none</compilerArgument>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven-war-plugin.version}</version>
                    <configuration>
                        <archiveClasses>true</archiveClasses>
                    </configuration>
                </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-maven-plugin.version}</version>
                    <configuration>
                        <!-- With multiple tests use GwtTestSuite.java for speed -->
                        <includes>**/*GwtTest.java</includes>
                        <bindAddress>0.0.0.0</bindAddress>
                        <extraJvmArgs>-Xss1024K -Xmx1024M -XX:MaxPermSize=256M</extraJvmArgs>
                        <logLevel>TRACE</logLevel>
                        <copyWebapp>true</copyWebapp>
                        <hostedWebapp>${webappDirectory}</hostedWebapp>
                        <runTarget>MyProject.jsp</runTarget>
                        <modules>
                            <module>com.test.MyProject</module>
                        </modules>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

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

        <!-- GWT-Platform -->
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-mvp-client</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-rpc-client</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-rpc-server-guice</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-rpc-shared</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-rest</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform.extensions</groupId>
            <artifactId>dispatch-rest-delegates</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-rest-shared</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-processors</artifactId>
            <version>${gwtp.version}</version>
        </dependency>


        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.0.2.Final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>10.12.1.1</version>
        </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.inject.extensions</groupId>
            <artifactId>guice-persist</artifactId>
            <version>${guice.version}</version>
        </dependency>

        <dependency>
            <groupId>com.google.gwt.inject</groupId>
            <artifactId>gin</artifactId>
            <version>${gin.version}</version>
        </dependency>

        <dependency>
            <groupId>org.mindrot</groupId>
            <artifactId>jbcrypt</artifactId>
            <version>${jbcrypt.version}</version>
        </dependency>
        <dependency>
            <groupId>com.arcbees</groupId>
            <artifactId>guicy-resteasy</artifactId>
            <version>${arcbees.version}</version>
        </dependency>

        <!-- REST -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
            <version>${resteasy.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson2-provider</artifactId>
            <version>${resteasy.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-guice</artifactId>
            <version>${resteasy.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>${jax-rs.version}</version>
            <!-- Provided because RestEasy has its own implementation -->
            <scope>provided</scope>
        </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>
    </dependencies>
</project>

如果我使用目标clean gwt:run进行Maven构建,它会正常工作,但是只有目标gwt:run的任何后续构建都会出错,说duplicate class: com.test.shared.dto.LoginDto

如果我按照建议here添加<compilerArgument>-proc:none</compilerArgument>,则后续构建工作正常。但是,根据原来的clean gwt:run目标,它会失败,说cannot find symbol: class LoginDto

有没有办法让两个版本保持一致?

1 个答案:

答案 0 :(得分:0)

这是maven-compiler-plugin 3.2(和3.1 IIRC)的错误。降级到3.0,并添加build-helper-maven编译器,将生成的源文件夹添加为process-classes阶段的源文件夹(重要的是&#34;在compile阶段后#34;)