如何在 mvn:package 中包含 GWT 生成的文件

发布于 2025-01-01 12:06:43 字数 318 浏览 5 评论 0原文

所以我正在尝试将现有的 Maven 项目转换为 SmartGWT。我可以使用 GWT,但 SmartGWT 在使用 Chrome 时遇到一些问题,并且 GWT 无法在 Firefox 8+ 上使用(我有 9)。所以我不太擅长 GWT,但我的理解是,如果我可以部署编译版本,我应该能够让 SmartGWT 工作。我尝试使用 mvn 包,但 JAR 中不包含 GWT 文件。

如何使用 Maven 将 GWT 文件打包为 Jar,以便可以在 tomcat 上运行?

更新:

mvn cleancompilegwt:compilepackage对我有用

So I am trying to convert and existing maven project over to SmartGWT. I have GWT working but SmartGWT has some kind of problem working with Chrome and GWT doesn't work with firefox 8+ (I have 9). So I am not very good with GWT but my understanding is I should be able to get SmartGWT to work if I can deploy a compiled verison. I tried using mvn package but that doesn't include the GWT files in the JAR.

How do you package a Jar with the GWT files using Maven so it can be run on tomcat?

update:

mvn clean compile gwt:compile package worked for me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

﹎☆浅夏丿初晴 2025-01-08 12:06:43

您也可以将 gwt:compile 目标绑定到 prepare-package<,而不是总是输入完整的构建命令 mvn cleancompile gwt:compile package /code> 阶段,以便它将在打包阶段之前运行(以及在测试目标完成之后等),因此您可以只运行 mvn package (或 mvn clean package,这会更接近你上面有什么)。将执行添加到 gwt-maven-plugin 定义中,如下所示

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>gwt-maven-plugin</artifactId>
    <version>2.4.0</version>
    <executions>
      <execution>
        <phase>prepare-package</phase>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

Instead of always entering the full build command mvn clean compile gwt:compile package, you, you could also bind the gwt:compile goal to the prepare-package phase, so that it will run just before the package phase (and after the testing goals have completed, among others), so you can just run mvn package (or mvn clean package, which would be closer to what you have above). Add an execution to the gwt-maven-plugin definition, something like this

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>gwt-maven-plugin</artifactId>
    <version>2.4.0</version>
    <executions>
      <execution>
        <phase>prepare-package</phase>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
水中月 2025-01-08 12:06:43

您可以做两件事来提供帮助。一种是将 smartGWT 安装到本地 Maven 存储库中,以便其源代码和 jar 可用于构建。

mvn install:install-file -Dfile=path/to/smart-gwt.jar -Dsources=path/to/smart-gwt.jar -Dversion=1.2.3 -DgroupId=group-id-to-use -DartifactId=smart-gwt -DgeneratePom=true -Dpackaging=jar

只要 jar 的版本和路径正确,请将这些值替换为您想要的任何值。现在只需将其包含在任何其他依赖项中即可;使用您创建的groupId和artifactId。

接下来,如果您想使用 smart-gwt 源而不是 jar,您可以生成自己的 gwt 友好的 jar,其中包含捆绑的源。按如下方式设置exportModule

<packaging>jar</packaging>

<!--...-->

<build>
 <sourceDirectory>src/main/java</sourceDirectory>
 <testSourceDirectory>tests/main/java</testSourceDirectory>

<resources>
  <resource>
    <directory>${basedir}/src/main/java</directory>
    <includes>
      <include>**/*.java</include>
      <include>**/*.json</include>
      <include>**/*.png</include>
      <include>**/*.gwt.xml</include>
    </includes>
  </resource>
  <resource>
    <directory>${basedir}/super/main/java</directory>
    <includes>
      <include>**/*.java</include>
      <include>**/*.json</include>
      <include>**/*.png</include>
      <include>**/*.gwt.xml</include>
    </includes>
  </resource>
</resources>

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
  </plugin>

  <plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <configuration>
      <filesets>
        <fileset><directory>war</directory></fileset>
        <fileset><directory>gwt-unitCache/</directory></fileset>
      </filesets>
    </configuration>
  </plugin>
 </plugins>
</build>

您可以使用上述模块安装您自己的gwt jar,假设使用以下命令命名为exportModule

 mvn -f exportModule/pom.xml clean install

You can do two things to help out. One is to install smartGWT into your local maven repository so it's sources and jar are available for builds.

mvn install:install-file -Dfile=path/to/smart-gwt.jar -Dsources=path/to/smart-gwt.jar -Dversion=1.2.3 -DgroupId=group-id-to-use -DartifactId=smart-gwt -DgeneratePom=true -Dpackaging=jar

Replace the values with whatever you want, so long as the version and path to jar is correct. Now just include it as you would with any other dependency; use the groupId and artifactId you made up.

Next, if you want to use smart-gwt source instead of jar, you can generate a gwt-friendly jar of your own that has bundled sources. Setup an exportModule as follows

<packaging>jar</packaging>

<!--...-->

<build>
 <sourceDirectory>src/main/java</sourceDirectory>
 <testSourceDirectory>tests/main/java</testSourceDirectory>

<resources>
  <resource>
    <directory>${basedir}/src/main/java</directory>
    <includes>
      <include>**/*.java</include>
      <include>**/*.json</include>
      <include>**/*.png</include>
      <include>**/*.gwt.xml</include>
    </includes>
  </resource>
  <resource>
    <directory>${basedir}/super/main/java</directory>
    <includes>
      <include>**/*.java</include>
      <include>**/*.json</include>
      <include>**/*.png</include>
      <include>**/*.gwt.xml</include>
    </includes>
  </resource>
</resources>

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
  </plugin>

  <plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <configuration>
      <filesets>
        <fileset><directory>war</directory></fileset>
        <fileset><directory>gwt-unitCache/</directory></fileset>
      </filesets>
    </configuration>
  </plugin>
 </plugins>
</build>

You can install your own gwt jar with the above module, assumed to be named exportModule using the command

 mvn -f exportModule/pom.xml clean install
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文