我想通過maven-2在項目目標文件夾的特定位置(特別是在target/abc_project/META-INF文件夾中)創建一個build info文件。如何從pom.xml執行jar
以下是我在做什麼在pom.xml
<build>
<finalName>abc_project</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<id>buid-info-generator</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>xyz.jar</argument>
<argument>target/abc_project/META-INF/info.txt</argument>
<argument>date</argument>
<argument>hg summary</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugins>
</build>
而不是install, deploy
給予phase
其他,我碰到下面的錯誤 -
[INFO] Exception in thread "main" java.io.FileNotFoundException: target\abc_project\META-INF\info.txt (The system cannot find the path specified)
[INFO] at java.io.FileOutputStream.open(Native Method)
[INFO] at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
[INFO] at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
[INFO] at java.io.FileWriter.<init>(FileWriter.java:73)
[INFO] at com.nbec.svn.build.info.BuildInfoGenerator.main(BuildInfoGenerator.java:30)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Result of cmd.exe /X /C "java -jar xyz.jar target/abc_project/META-INF/info.txt "date "hg summary"" execution is: '1'.
但奇怪的是,相同的代碼正在爲1個項目工作,而不是其他2個項目。有沒有其他辦法可以獲得同樣的結果。
你的項目有一些奇怪的東西。你改變了默認值嗎? target \ abc_project \ META-INF \ info.txt應該從哪裏來? – 2010-09-06 20:16:33