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

app*_*tup 5 gwt gwt-maven-plugin

我试图在另一场战争中重用组装的 gwt 编译。对于这个我尝试从改变目前的Maven模块的包装warpom。然后我计划使用 maven-assembly-plugin 来压缩 gwt 的模块 js 输出,然后在另一个 war 模块中使用它。

我试图改变包装标签<packaging>war</packaging>,以 <packaging>pom</packaging>从pom.xml的验证样品。gwt-maven-plugin 从不进入编译。相反,它跳过编译!!!!

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

在此处输入图片说明

Man*_*ino 4

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

  1. 将所有 gwt 示例打包为习惯性的 (.war),然后安装它们mvn install,或者mvn deploy如果您有私人 Maven 存储库。
  2. 创建一个类型为 的空 Maven 模块war,没有代码,但具有 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>
    
    Run Code Online (Sandbox Code Playgroud)

最后,与 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>
Run Code Online (Sandbox Code Playgroud)

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