【发布时间】:2016-04-20 10:27:13
【问题描述】:
我正在创建一个非 java Maven 工件。在pom.xml 中,我解决了一些依赖关系,然后使用exec 插件运行自定义脚本。有些文件是在目录中创建的,但是 Maven 在将它们打包到 jar 中时看不到它们。
当我运行mvn package 两次时,第二次运行确实包含 jar 中的资源文件。
任何想法为什么会发生这种情况?该脚本在compile 阶段运行,因此在package 阶段创建jar 时文件已经创建。
这是我的pom.xml 配置的相关(希望)部分:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>build-plugin</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bash</executable>
<arguments>
<argument>build_plugin.sh</argument>
<argument>${workspace}</argument>
<argument>${plugin}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${project.basedir}/${outputPath}</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>target/**</exclude>
</excludes>
</resource>
</resources>
所有变量和路径都是有效的,在第二次运行时,我得到了一个包含预期内容的 jar。但不是在第一次。
【问题讨论】:
标签: java maven maven-resources-plugin