如何将依赖项复制到gae war/WEB-INF/lib

Ble*_*eek 5 eclipse google-app-engine maven-2

我来自Ant的观点,所以请原谅我.我知道这里已经有很多关于maven依赖关系的问题了,但是它们似乎都没有告诉我们如何做需要做的事情.

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

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

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

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

现在,我必须从shell窗口执行mvn命令(这与Eclipse会话的存在完全无关).似乎每当我更新依赖项时,唯一自动完成的事情就是这样.

是否有一种方法,或任何允许我在Eclipse中运行mvn目标的eclipse插件?

附加信息:

mvn dependency:copy-dependencies持续复制到target/dependency目录,具有以下内容:

  <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>
Run Code Online (Sandbox Code Playgroud)

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

<outputDirectory>
  /home/geek/eclipse/workspace/Demo-autoshoppe/holycow
</outputDirectory>
Run Code Online (Sandbox Code Playgroud)

但是holycow目录仍然是空的,并且mvn仍然存在于复制到target/dependency目录中.我目前的解决方案是软链接target/dependencywar/WEB-INF/lib,这是一个非常非常糟糕的杂牌.为什么maven对outputDirectory规范不敏感?我正在使用Ubuntu的maven 2.2.

Ste*_*lla 7

我有真正的答案,我的男士.

使用"default-cli"执行ID.确保您使用的是Maven 2.2+.此exec-id适用于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>
Run Code Online (Sandbox Code Playgroud)

干杯.