Maven文件重命名

最近一直在做老系统的升级项目,其中不同环境的配置文件使用了不同的名字,那怎样利用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。

猜你喜欢

转载自billben.iteye.com/blog/2373011