[构建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>
您正在尝试使用错误的目标和执行ID复制并重命名该文件。试试这个:
<executions>
<execution>
<id>copy-rename</id>
<phase>compile</phase>
<goals>
<goal>copy</goal>
</goals>
...