如何将依赖关系复制到gae war / WEB-INF / lib [英] How to copy dependencies to gae war/WEB-INF/lib

查看:134
本文介绍了如何将依赖关系复制到gae war / WEB-INF / lib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自Ant的角度,请原谅我。我意识到在这里已经有很多关于如何设置依赖关系的问题,但是他们都没有告诉如何去做需要做的事情。



问题1
目前,在使用maven-war-plugin时,当我运行mvn war:war时,它会在目标文件夹中创建一个war文件夹。


$ b $但是,我希望将所有依赖项的jar复制到由google eclipse plugin(启用了gae,禁用gwt)设置的war / WEB-INF / lib中,而不会覆盖Google eclipse插件放置在那里的jar。



我不想设置war文件或war目录。我只需要将所有非gae jar文件复制/合并到gae jar文件中,这样当项目作为gae web应用程序运行时,Eclipse不会抱怨ClassNotFoundException。



问题2
在Eclipse中使用Ant时,我可以在Eclipse中运行Ant目标。 b

现在,我必须从shell窗口执行mvn命令(这对于Eclipse会话的存在是相互忽略的)。看来只有当我更新依赖关系时,自动完成的唯一一件事情。



有没有办法,或者是任何用于eclipse的插件,它们可以让我在内部运行mvn目标Eclipse?



其他信息
$ b mvn依赖项:copy-dependencies 会持续复制到 target / dependency 目录中,其中包含以下内容:

 < plugin> 
< artifactId> maven-dependency-plugin< / artifactId>
<执行次数>
<执行>
< id>复制依赖关系< / id>
<阶段>过程资源< /阶段>
<目标>
<目标>复制依赖关系< / goal>
< /目标>
<配置>
< outputDirectory> $ {basedir} / war / WEB-INF / lib /< / outputDirectory>
< overWriteReleases> false< / overWriteReleases>
< overWriteSnapshots> false< / overWriteSnapshots>
< overWriteIfNewer> true< / overWriteIfNewer>
< excludeArtifactIds> gwt-user,gwt-dev< / excludeArtifactIds>
< / configuration>
< /执行>
< /执行次数>
< / plugin>

我甚至尝试改变为绝对路径

 <输出目录> 
/ home / geek / eclipse / workspace / Demo-autoshoppe / holycow
< / outputDirectory>

但是holycow目录仍然是空的,mvn仍然存在于复制到 target /依赖项目录。我当前的解决方案是将 target / dependency 作为 war / WEB-INF / lib 的软链接,这是非常糟糕的杂牌。为什么maven对outputDirectory规范不敏感?我使用的是Ubuntu的Maven 2.2。

解决方案

我有真正的答案给你,我的男人。 b

使用default-cli执行ID。确保你使用的是Maven 2.2+。这个exec-id适用于mojo的命令行执行。

 < build> 
< pluginManagement>
< plugins>
<! - 将依赖关系复制到war / WEB-INF / lib以获得GAE proj合规性。 - >
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-dependency-plugin< / artifactId>
<执行次数>
<执行>
< id> default-cli< / id>
<目标>
<目标>复制依赖关系< / goal>
< /目标>
<配置>
< outputDirectory> $ {basedir} / war / WEB-INF / lib /< / outputDirectory>
< overWriteReleases> false< / overWriteReleases>
< overWriteSnapshots> false< / overWriteSnapshots>
< overWriteIfNewer> true< / overWriteIfNewer>
< excludeArtifactIds> gwt-user,gwt-dev< / excludeArtifactIds>
< / configuration>
< /执行>
< /执行次数>
< / plugin>
< / plugins>
< / pluginManagement>
< / build>

干杯。


I'm coming from Ant perspective, so pardon me. I realise there are quite a few questions here already on how to maven dependencies, but none of them seem to tell how to do what need to do.

Question 1: Currently, in conjunction with using maven-war-plugin, when I run mvn war:war, it creates a war folder in target folder.

However, I wish copy all the dependencies' jars to war/WEB-INF/lib set up by google eclipse plugin (with gae enabled, gwt disabled), without overwriting the jars that google eclipse plugin placed there.

I don't wish to setup a war file or war directory. I just need to copy/consolidate all the non-gae jars with the gae jars so that when the project is run as a gae web app, Eclipse would not complain ClassNotFoundException.

Question 2: When using Ant in Eclipse, I could run Ant targets within Eclipse.

Right now, I have to perform mvn commands from a shell window (which is mutually oblivious to the existence of an Eclipse session). It appears that the only thing that is automatically done is whenever I update dependencies.

Is there a way, or any plugin for eclipse that would allow me to run mvn goals within Eclipse?

Additional info:

mvn dependency:copy-dependencies persists in copying to target/dependency directory, with the following:

  <plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
      <execution>
        <id>copy-dependencies</id>
        <phase>process-resources</phase>
        <goals>
          <goal>copy-dependencies</goal>
        </goals>
        <configuration>
          <outputDirectory>${basedir}/war/WEB-INF/lib/</outputDirectory>
          <overWriteReleases>false</overWriteReleases>
          <overWriteSnapshots>false</overWriteSnapshots>
          <overWriteIfNewer>true</overWriteIfNewer>
          <excludeArtifactIds>gwt-user,gwt-dev</excludeArtifactIds>
        </configuration>
      </execution>
    </executions>
  </plugin>

I even tried changing to absolute path

<outputDirectory>
  /home/geek/eclipse/workspace/Demo-autoshoppe/holycow
</outputDirectory>

But holycow directory is still empty and mvn still persists in copying to target/dependency directory. My current solution is to softlink target/dependency as war/WEB-INF/lib, which is a very very bad kludge. Why is maven not sensitive to outputDirectory specification? I am using Ubuntu's maven 2.2.

解决方案

I have the real answer for you, my man.

Use the "default-cli" execution id. Make sure you're using Maven 2.2+. This exec-id applies to command-line executions of the mojo.

  <build>
    <pluginManagement>
      <plugins>
        <!-- Copy dependencies to war/WEB-INF/lib for GAE proj compliance. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
              <id>default-cli</id>
              <goals>
                <goal>copy-dependencies</goal>
              </goals>
              <configuration>
                <outputDirectory>${basedir}/war/WEB-INF/lib/</outputDirectory>
                <overWriteReleases>false</overWriteReleases>
                <overWriteSnapshots>false</overWriteSnapshots>
                <overWriteIfNewer>true</overWriteIfNewer>
                <excludeArtifactIds>gwt-user,gwt-dev</excludeArtifactIds>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

Cheers.

这篇关于如何将依赖关系复制到gae war / WEB-INF / lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆