【发布时间】:2013-04-18 23:54:58
【问题描述】:
我使用 copy-dependencies 目标来复制当前工件的依赖项。 但它不会复制范围为“提供”的依赖项。 如何解决?
xml配置是标准的:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>lib</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeArtifactIds>project-services</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<finalName>project-web</finalName>
</build>
我为什么要这样做? 因为我必须同时支持 ant 和 maven 构建工作。 因此,我想通过运行 mvn install -o 将所有依赖项复制到单独的目录中。在 Ant build.xml 中,我将该目录的路径包含为类路径。之后 Ant 构建 ear 文件并包含整个 lib 目录,没有系统 tools.jar 和其他“提供”的 jar。 Apache Maven 的版本是 3.0.3
【问题讨论】:
-
你在运行哪个 Maven 命令?
-
您为什么要这样做?具有 scope=provided 的依赖项以这种方式标记,因为它们已经存在于目标环境中。为什么要复制它们?
-
如果您需要复制它们,为什么要标记它们提供?
-
我更新了问题。 Maven 3.