Maven 2 如何从pom.xml执行jar
我想通过maven-2在项目目标文件夹的特定位置创建一个buildinfo文件,特别是在target/abc_project/META-INF文件夹中 下面是我在pom.xml中所做的Maven 2 如何从pom.xml执行jar,maven-2,pom.xml,command-execution,Maven 2,Pom.xml,Command Execution,我想通过maven-2在项目目标文件夹的特定位置创建一个buildinfo文件,特别是在target/abc_project/META-INF文件夹中 下面是我在pom.xml中所做的 <build> <finalName>abc_project</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugi
<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>
但奇怪的是,相同的代码适用于1个项目,而不适用于其他2个项目。是否有其他方法可以获得相同的结果。实际上,错误报告表明目录target\abc\u project\META-INF可能不存在。没有更多的信息,我只能猜测。创建abc\U project\META-INF目录的插件可能在exec maven插件之后调用。yeah。。这是真的,直到那时它才创建abc_项目文件夹本身,而使用的是安装/部署以外的阶段。我不知道为什么会这样。。如果有人能告诉我什么时候在maven中使用所有必需的依赖文件夹创建完整的目标文件夹,那就太棒了。project.build.directory默认值:target和project.build.outputDirectory默认值:target/类是在编译阶段创建的。您是否将project.build.outputDirectory属性更改为target\abc\u project?您的项目有点奇怪。您是否更改了默认设置?target\abc\u project\META-INF\info.txt应该来自哪里?
</plugins>
</build>
[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'.