【发布时间】:2011-06-28 20:23:20
【问题描述】:
如何将另一个源目录添加到 maven gwt 编译插件?我有一些生成的代码需要包含在编译中。
如果我不能,人们建议如何解决这个问题?
【问题讨论】:
如何将另一个源目录添加到 maven gwt 编译插件?我有一些生成的代码需要包含在编译中。
如果我不能,人们建议如何解决这个问题?
【问题讨论】:
我不知道您是否对此进行了研究,但您可以使用compileSourcesArtifacts 属性将您生成的代码作为外部库包含在内。 GWT Plugin Documentation 中有一篇关于设置的文章。但是,这仅在您不需要将外部代码包含在您的网络应用程序中时才有效。
过去每当我们需要这样做时,我们都会使用maven-resources-plugin's copy-resources goal 将源代码复制到我们的主包结构中,并配置maven-clean-plugin to remove the files。由于 gwt 编译发生在 build lifecycle 的 prepare-package 阶段,因此您需要将源文件复制到之前的目录中(我们绑定到 process-classes)。
【讨论】:
我将 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>
【讨论】:
这是有效的,因为您生成的输出是在正常的源文件夹中生成的。 但问题是如何添加额外的源文件夹。
【讨论】: