copy-maven-plugin
が提供するを使用していcom.github.goldin
ます。Maven を使用していくつかのファイルをコピーしたいと考えています。
ただし、ドライブが異なるため、パスをハードコーディングしたくありません。例えば:
<build>
<plugins>
<plugin>
<groupId>com.github.goldin</groupId>
<artifactId>copy-maven-plugin</artifactId>
<version>0.2.5</version>
<executions>
<execution>
<id>create-archive</id>
<phase>test</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<resources>
<resource>
<targetPath>/../src/Server-Parent/src/test/resources</targetPath>
<file>/../src/Server-Parent/DB/src/test/resources/mongoDB.xml</file>
<destFileName>mongoDB.xml</destFileName>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
たとえば、ハードコーディングするとC:\folder name\src\Server-Parent\src\test\resources
、どの Maven プロジェクトからでも完全に機能します。しかし、私が置くとすぐに、../src
または/../src
それには問題が含まれています。
これを修正する方法はありますか?
[ERROR] Failed to execute goal com.github.goldin:copy-maven-plugin:0.2.5:copy (c reate-archive) on project Server-Parent: Processing <resource> [Target p ath(s) [/../src/Server-Parent/src/test/resources], directory [C:/folder name\src/Server-Parent/DB/src/test/resources], dependencies []] fa iled with [java.lang.AssertionError]: [C:\folder name\src\Server-Parent\DB\sr c\test\resources] does not exist. Expression: d.directory -> [Help 1] [ERROR]
編集2:
私が達成しようとしていること:
pom値を含むpom.xmlであるServer-Parentがあります。この内部には、pom.xml pom 値を含む別の Server-SubParent があります。この中には、jar を含む Server-SubFunctionality があります。
あなたの答えによると、これをどのように達成できますか:
${project.basedir}
これは、Server-SubParent が Server-Parent のモジュールである 3 つのプロジェクトですが、Server-SubParent は、実際の機能を含む別のモジュールを含む別の pom です。
Server-Parent
<modelVersion>4.0.0</modelVersion>
<artifactId>Server-Parent</artifactId>
<packaging>pom</packaging>
<name>Server-Parent</name>
<modules>
<module>Server-Sub-Parent</module>
</modules>
Server-SubParent
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.server</groupId>
<artifactId>Server-Parent</artifactId>
<version>S06B1-RELEASE</version>
</parent>
<artifactId>Server-Sub-Parent</artifactId>
<packaging>pom</packaging>
<name>Server-Sub-Parent</name>
<modules>
<module>Server-Sub-ParentFunctionality</module>
</modules>
Server-Sub-Parent-Functionality
<parent>
<groupId>com.server</groupId>
<artifactId>Server-Sub-Parent</artifactId>
<version>S06B1-RELEASE</version>
</parent>
<artifactId>Server-Sub-Parent-Functionality</artifactId>
<packaging>jar</packaging>
<name>Server-Sub-Parent-Functionality</name>