Maven GWT 插件复制同一快照 jar 的多个版本

发布于 2024-12-06 14:06:28 字数 3529 浏览 0 评论 0原文

我在构建项目(mvn clean install)时遇到这个问题,一些传递依赖项是快照版本,被下载并复制到目标 webapp 目录中,例如 XXXUtil-1.0-20110922.172721- 52.jar.然后,当我运行 mvn gwt:run 时,它发现使用 XXXUtil-1.0-SNAPSHOT.jar 并将其复制到目标 webapp 目录。我不明白为什么会发生这种情况。无论我是爆炸跑还是原地跑都没关系。

<plugins>
    <!-- GWT Maven Plugin -->
    <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>2.3.0-1</version>
            <executions>
                    <execution>
                            <goals>
                                    <goal>compile</goal>
                                    <goal>i18n</goal>
                                    <goal>generateAsync</goal>
                            </goals>
                    </execution>
            </executions>
            <configuration>
                    <runTarget>Shell.html</runTarget>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>
    <i18nMessagesBundle>com.myapp.client.Messages</i18nMessagesBundle>
            </configuration>
            <dependencies>
                    <dependency>
                            <groupId>com.google.gwt</groupId>
                            <artifactId>gwt-user</artifactId>
                            <version>${gwt.version}</version>
                    </dependency>
                    <dependency>
                            <groupId>com.google.gwt</groupId>
                            <artifactId>gwt-dev</artifactId>
                            <version>${gwt.version}</version>
                    </dependency>
            </dependencies>
    </plugin>

    <!-- Copy static web files before executing gwt:run -->
    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <executions>
                    <execution>
                            <phase>compile</phase>
                            <goals>
                                    <goal>exploded</goal>
                            </goals>
                    </execution>
            </executions>
            <configuration>
<!-- <outputFileNameMapping>@{artifactId}@-@{version}@.@{extension}@</outputFileNameMapping>  -->
                    <webappDirectory>${webappDirectory}</webappDirectory>
            </configuration>
    </plugin>
</plugins>

这里描述的建议都没有帮助: http://www.tikalk .com/alm/forums/maven-war-plugin-picking-multiple-version-same-snapshot-jars

如果我构建 XXXUtil-1.0-SNAPSHOT.jar 的本地快照,它可以工作,但从 Nexus 存储库下载快照时则不行。另一种看待它的方式是,项目 A 生成一个 WAR,并依赖于 B.jar,而 B.jar 又依赖于 C.jar。当我使用 mvn install 构建战争时,它会在 WEB-INF/lib 中生成正确的 jar,因此我们有 C-1.0-20110922.172721-52.jar。这是正确的,如果我部署我的战争,它就会起作用。如果我使用 eclipse 在托管模式下运行,那就没问题了。但是当我运行 mvn:gwt-run 时,C-1.0-SNAPSHOT.jar 被复制到 WEB-INF/lib 中,因此我有 2 个 jar C-1.0-SNAPSHOT.jar 和 C-1.0-20110922.172721-52.jar。

I have this issue where I build my project (mvn clean install), some of the transitive dependencies are snapshot versions and are downloaded and copied into the target webapp directory e.g XXXUtil-1.0-20110922.172721-52.jar. Then when I run mvn gwt:run, it finds uses XXXUtil-1.0-SNAPSHOT.jar and copies it to the target webapp directory. I can't figure out why this is happening. In doesn't matter whether I run as exploded or inplace.

<plugins>
    <!-- GWT Maven Plugin -->
    <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>2.3.0-1</version>
            <executions>
                    <execution>
                            <goals>
                                    <goal>compile</goal>
                                    <goal>i18n</goal>
                                    <goal>generateAsync</goal>
                            </goals>
                    </execution>
            </executions>
            <configuration>
                    <runTarget>Shell.html</runTarget>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>
    <i18nMessagesBundle>com.myapp.client.Messages</i18nMessagesBundle>
            </configuration>
            <dependencies>
                    <dependency>
                            <groupId>com.google.gwt</groupId>
                            <artifactId>gwt-user</artifactId>
                            <version>${gwt.version}</version>
                    </dependency>
                    <dependency>
                            <groupId>com.google.gwt</groupId>
                            <artifactId>gwt-dev</artifactId>
                            <version>${gwt.version}</version>
                    </dependency>
            </dependencies>
    </plugin>

    <!-- Copy static web files before executing gwt:run -->
    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <executions>
                    <execution>
                            <phase>compile</phase>
                            <goals>
                                    <goal>exploded</goal>
                            </goals>
                    </execution>
            </executions>
            <configuration>
<!-- <outputFileNameMapping>@{artifactId}@-@{version}@.@{extension}@</outputFileNameMapping>  -->
                    <webappDirectory>${webappDirectory}</webappDirectory>
            </configuration>
    </plugin>
</plugins>

None of the suggestions described here help:
http://www.tikalk.com/alm/forums/maven-war-plugin-picking-multiple-version-same-snapshot-jars.

If i build local snapshots of XXXUtil-1.0-SNAPSHOT.jar it works buts not when downloading snapshots from a nexus repository. Another way to look at it is like this Project A generates a WAR, and depends on B.jar, which depends on C.jar. When i build my war using mvn install, it generates the correct jars in WEB-INF/lib so we have C-1.0-20110922.172721-52.jar. Which is correct and it works if i deploy my war. If i run in hosted mode using eclipse, its fine. But when i run mvn:gwt-run, C-1.0-SNAPSHOT.jar is copied into WEB-INF/lib so i have 2 jars C-1.0-SNAPSHOT.jar and C-1.0-20110922.172721-52.jar.

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

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

发布评论

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

评论(2

爱给你人给你 2024-12-13 14:06:28

我唯一可以建议你的是尝试调试 maven-gwt-plugin。

从 git 存储库中签出它
https://github.com/gwt-maven-plugin/gwt-maven -插件.git

The only thing I can suggest you is to try to debug maven-gwt-plugin.

Checkout it from git repository
https://github.com/gwt-maven-plugin/gwt-maven-plugin.git

情感失落者 2024-12-13 14:06:28

我有完全相同的问题。调试后,我删除了 maven-war-plugin 的使用并添加了 maven-resources-plugin (编译阶段,复制资源目标)。之后我尝试了 gwt:run 并安装,没有任何问题。这样,我们就可以避免依赖项被复制两次。

I had exactly the same problem. After debugging, I removed the use of maven-war-plugin and added maven-resources-plugin (compile phase, copy-resources goal). I tried gwt:run and install after that, worked without any problems. This way, we avoid the dependencies getting copied twice.

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