模块打包为pom时,maven中会跳过GWT编译

标签 gwt gwt-maven-plugin

我正在尝试在另一场 war 中重用已组装的 gwt 编译。为此,我尝试更改当前 Maven 模块的包装 warpom 。然后,我计划使用 maven- assembly-plugin 来压缩 gwt 的模块 js 输出,并稍后在另一个 war 模块中使用它。

我尝试更改包装标签 <packaging>war</packaging><packaging>pom</packaging>在 pom.xml 中 Validation sample 。 gwt-maven-plugin 永远不会进入编译。相反,它会跳过编译!!!!!!

  1. What is happening?
  2. Is this expected?
  3. Is there any workaround?

enter image description here

最佳答案

要将多个 gwt 编译模块加入到单个 .war 文件中,使用 maven-dependency-plugin 非常容易。

  1. 将所有 gwt 示例打包为习惯性的 (.war),如果您有私有(private) Maven 存储库,则使用 mvn installmvn deploy 安装它们。
  2. 创建一个war类型的空maven模块,没有任何代码,但具有maven文件夹结构,您可以在这里放置您需要的任何其他内容,例如全局src/main/webapp/index.html.
  3. 配置新模块以使用maven-dependency-plugin,如下所示,然后运行mvn package:

    <dependency>
        <groupId>my.group</groupId>
        <artifactId>example1</artifactId>
        <version>...</version>
        <type>war</type>
    </dependency>
    ...
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>unpack-gwt-examples</id>
          <phase>prepare-package</phase>
          <goals>
            <goal>unpack-dependencies</goal>
          </goals>
          <configuration>
            <includeGroupIds>my.group</includeGroupIds>
            <includes>**/example1/**</includes>
            <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}</outputDirectory>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

最后,与 gwt-maven-plugin 相关,与任何其他 Maven 插件一样,选择 pom 打包生命周期的适当阶段(打包、安装或部署)就足够了:

  ...
  <packaging>pom</packaging>
  ...
     <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        ...
        <configuration>
        ...
        </configuration>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>compile</goal>
                </goals>
            </execution>
        </executions>
      </plugin>

不幸的是,gwt-maven-plugin 在打包为 pom 时明确禁止编译,请查看 line #269 of CompileMojo.java

关于模块打包为pom时,maven中会跳过GWT编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15563057/

相关文章:

java - GWT 意外的内部编译器错误

java - 最新的 Google Maps API V3(gwt-maps 3.10.0-alpha-7 除外)与 GWT 2.7.0 兼容吗?

java - gwt-maven-plugin 在 IDE 和命令行中的不同行为

maven - GWT Maven 项目无法编译 - 没有可用于类型的源代码

java - 如何在gwt maven项目中调试和修改时自动复制webapp文件夹中的静态资源文件

java - 在 Chrome 浏览器的 GXT EditorGrid 中单击鼠标时,焦点不会从 TextField 出来

java - 获取 GWT DialogBox 绝对位置 - onLoad/onAttach/show 没有帮助

java - 我可以将参数传递给 GWT 模块构造函数吗?

GWT maven 编译器输出目录

总重量。马文。在项目源或资源中找不到 GWT 模块 <module_name>