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 ファイルを構築し、システムの tools.jar やその他の「提供された」jar を含まない lib ディレクトリ全体を含めます。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/

ここでは、Nexus に接続するように Ivy を構成する方法を投稿します。

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

于 2013-04-18T13:11:04.567 に答える