在构建jar时,我希望包含一个文件,对其进行重命名并将其放入jar中,但Maven会将重命名后的文件放入目标文件夹,而不是放入jar中。如何重命名要包含在jar中的文件
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>filter-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>../rest-api/src/main/resources/xcs-${xcs.rest.api.version}.yaml</include><!-- File I want to rename -->
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>copy-and-rename-file</id>
<phase>compile</phase>
<goals>
<goal>rename</goal>
</goals>
<configuration>
<sourceFile>../rest-api/src/main/resources/xcs-${xcs.rest.api.version}.yaml</sourceFile>
<destinationFile>${project.build.directory}/xcs.yaml</destinationFile><!-- Desired name -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>发布于 2019-09-23 21:35:11
您正在尝试使用错误的目标和执行id复制并重命名文件。试试这个:
<executions>
<execution>
<id>copy-rename</id>
<phase>compile</phase>
<goals>
<goal>copy</goal>
</goals>
...https://stackoverflow.com/questions/55117976
复制相似问题