【发布时间】:2015-08-18 07:44:30
【问题描述】:
如何告诉 Maven 将依赖项复制到特定位置?
旁白:我在 Eclipse 中有一个 GWT 项目,它也是一个大型项目的 Maven 模块。这个 GWT 项目依赖于一些库,我需要将它们复制到 <project-dir>/war/WEB-INF/lib。我怎样才能告诉 Maven 这样做?
编辑:我找到了一种复制单个依赖项的方法 - 但有没有一种方法可以通过简单的指令复制所有依赖项?
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<overWrite>false</overWrite>
<outputDirectory>${basedir}/war/WEB-INF/lib</outputDirectory>
<destFileName>optional-new-name.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/wars</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
我也试过这个:
</dependencies>
<build>
<outputDirectory>${project.basedir}/war/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<!-- up to <phase>deploy</phase> -->
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/war/WEB-INF/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
以错误告终:
Artifact 尚未打包。在反应堆工件上使用时,应在打包后执行复制:参见 MDEP-187。
【问题讨论】: