2011-06-28 34 views

回答

3

我不知道你是否看过这个,但你可以使用compileSourcesArtifacts属性来包含你生成的代码作为外部库。有一篇关于在GWT Plugin Documentation中设置的文章。但是,只有当您不需要将外部代码包含在您的Web应用程序中时,此功能才有效。

当我们过去需要这样做时,我们使用maven-resources-plugin's copy-resources goal将源代码复制到我们的主包结构中,并配置了maven-clean-plugin to remove the files。由于gwt编译发生在build lifecycleprepare-package阶段,因此您需要将源文件复制到目录之前(我们将其限制为process-classes)。

+0

我将那些其他源文件复制到gwt编译中去的目录是什么? –

+0

我需要更多地了解你想要对他们做什么。他们是观点,主持人,图书馆类,模型还是其他? –

+0

它们是生成的工件,gwtp事件和动作。但是我发现只要我在gwt:compile之前编译java就行了(没关系)。不需要这样一个复杂的解决方案。 –

2

我把i18n的目标放在生成资源阶段,它运行良好。它将在gwt编译之前执行。

<plugins> 
     <!-- GWT Maven Plugin--> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>gwt-maven-plugin</artifactId> 
      <version>2.5.0-rc1</version> 
      <dependencies> 
       <dependency> 
        <groupId>com.google.gwt</groupId> 
        <artifactId>gwt-user</artifactId> 
        <version>${gwtVersion}</version> 
       </dependency> 
       <dependency> 
        <groupId>com.google.gwt</groupId> 
        <artifactId>gwt-dev</artifactId> 
        <version>${gwtVersion}</version> 
       </dependency> 
       <dependency> 
        <groupId>com.google.gwt</groupId> 
        <artifactId>gwt-servlet</artifactId> 
        <version>${gwtVersion}</version> 
       </dependency> 
      </dependencies> 

      <executions> 
       **<execution> 
        <id>generate-i18n</id> 
        <phase>generate-resources</phase> 
        <goals> 
         <goal>i18n</goal> 
        </goals> 
       </execution>** 
       <execution> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>resources</goal> 
         <goal>compile</goal> 
         <goal>test</goal> 
         <goal>generateAsync</goal> 
        </goals> 
       </execution> 

      </executions> 

      <configuration> 
        <!-- your config --> 
      </configuration> 
     </plugin> 
0

这是可行的,因为您生成的输出是在正常源文件夹中生成的。 但问题是如何添加额外的源文件夹。