2015-10-12 2 views
0

Я довольно новичок в Maven, но я использую его, потому что это то, что дает плагин GWTP при создании нового проекта. У меня есть несколько DTO, которые я создаю, используя аннотацию @GenDto. Ниже мой pom.xml файл:GWTP Boilerplate Generation с Maven - несоответствие успеха сборки

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

Это прекрасно работает, если я делаю Maven построить с целями clean gwt:run, но затем все последующие сборки только с целью gwt:run будет ошибка, говоря duplicate class: com.test.shared.dto.LoginDto.

Если я последую предложению here, чтобы добавить <compilerArgument>-proc:none</compilerArgument>, то последующие сборки будут работать. Однако, с исходными clean gwt:run голами, это не удастся, сказав cannot find symbol: class LoginDto.

Есть ли способ сделать это так, чтобы две сборки были согласованы?

ответ

0

Это ошибка maven-compiler-plugin 3.2 (и 3.1 IIRC). Снизьте до 3.0 и добавьте компилятор build-helper-maven, чтобы добавить сгенерированную исходную папку в качестве исходной папки в фазе process-classes (важно «после compile фазы»).

+0

Это фиксировало мою проблему Maven, но теперь у меня возникают проблемы с компилятором GWT, не находящим скомпилированные классы. Я могу видеть файлы .class сгенерированных DTO в каталоге сборки, но компилятор GWT говорит, что для него нет исходного кода. Есть идеи? – blah1234

+0

Отсюда и необходимость в компиляторе build-helper-maven. –

+0

@ blah1234: Источник dir "/ apt" заканчивается, он должен быть: $ {project.build.directory}/сгенерированные источники/apt –