开发者

How to execute a jar from pom.xml

开发者 https://www.devze.com 2023-01-14 18:53 出处:网络
I want to create a build info file into the specific location of the project\'s target folder (especially in target/abc_project/META-INF folder) through maven-2.

I want to create a build info file into the specific location of the project's target folder (especially in target/abc_project/META-INF folder) through maven-2.

Following is what I am doing in the 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>

while giving the phase other than install, deploy, I get the following error -

[INFO] Excepti开发者_JAVA百科on 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'.

But strangely, the same code is working for 1 project and not for other 2 projects. Is there any alternative to obtain the same.


Actually the error report indicates that the directory target\abc_project\META-INF probably does not exist. Without more information I can only speculate. Maybe the plugin which create the abc_project\META-INF directory is called after the exec-maven-plugin.

0

精彩评论

暂无评论...
验证码 换一张
取 消