Maven重命名包含文件

Maven rename included file

构建 jar 时,我想包含一个文件,将其重命名并将其放入 jarMaven 将重命名的文件放入目标文件夹而不是将其放入 jar 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>
...