ITeye博客

Maven文件重命名

sunjing · 2017-05-07 14:09 · Maven · 开源软件 · Markdown

最近一直在做老系统的升级项目,其中不同环境的配置文件使用了不同的名字,那怎样利用Maven重命名文件呢?可以使用copy-rename-maven-plugin插件,如下:

 

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
                <exclude>config.properties</exclude>
            </excludes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>com.coderplus.maven.plugins</groupId>
            <artifactId>copy-rename-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>rename-file</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>rename</goal>
                    </goals>
                    <configuration>
                        <sourceFile>${project.build.outputDirectory}/config-dev.properties</sourceFile>
                        <destinationFile>${project.build.outputDirectory}/config.properties</destinationFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

 

使用不同的文件,维护复杂,也不容易看出不同环境的区别,最好修改为使用properties。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。