1

我使用 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

4

1 回答 1

1

正如插件使用 includeScope 所记录的:

http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html#includeScope

编辑

我为什么要这样做?因为我必须同时支持 ant 和 maven 构建工作。

考虑使用 Ivy 来管理与 Ant 的依赖关系:http: //ant.apache.org/ivy/

这里有一篇文章如何配置 Ivy 以连接到 Nexus:

https://support.sonatype.com/entries/21627528-how-do-i-configure-my-ivy-build-to-download-artifacts-from-nexus

于 2013-04-18T13:11:04.567 回答