我正在使用com.github.goldin
提供的copy-maven-plugin
。我想通過Maven複製一些文件。使用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。在這裏面是另一個包含pom.xml pom值的Server-SubParent。現在裏面是包含jar的Server-SubFunctionality。
Accoriding到你的答案這可怎麼achived:
$ {} project.basedir
這三個項目中的服務器SubParent是服務器家長的模塊,但服務器SubParent是另一個包含另一個包含真實功能的模塊。
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>
'它包含的問題。' *有什麼問題?* – 2013-08-22 13:40:42
'/../ src /'不是一個有效的路徑構造,不在任何我知道的操作系統上,特別是在Windows上。實際的錯誤是什麼,否則這個錯誤會被拒絕投票並且很快關閉。 –
請參閱上面的修改。 – user1646481