首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven重命名包含的文件

Maven重命名包含的文件
EN

Stack Overflow用户
提问于 2019-03-12 17:24:40
回答 1查看 343关注 0票数 1

在构建jar时,我希望包含一个文件,对其进行重命名并将其放入jar中,但Maven会将重命名后的文件放入目标文件夹,而不是放入jar中。如何重命名要包含在jar中的文件

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-23 21:35:11

您正在尝试使用错误的目标和执行id复制并重命名文件。试试这个:

代码语言:javascript
复制
<executions>
    <execution>
        <id>copy-rename</id>
        <phase>compile</phase>
        <goals>
            <goal>copy</goal>
        </goals>
...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55117976

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档