Maven:读取属性文件并复制资源 [英] Maven: Read property file and copy resources
本文介绍了Maven:读取属性文件并复制资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到某种情况,即读取属性文件,并根据属性文件的值创建文件夹并将资源从某个目录复制到该文件夹.
I am into some scenario that is, read a properties file, and based on the value of property file create folder and copy resources from some directory to it.
properties-file: xyz.properties
CLIENTLIST=A,B
我想在maven中执行以下步骤.
I want to perform following steps in maven.
1. From above properties file pom should read the property.
2. In loop I want to create folders by name A and B.
3. After creating folder i want to copy some resources into it.
ex: after creating folder A , want to copy some resource files from x/y/z directory.
在maven中有可能吗?
Is it possible in maven ?
推荐答案
我使用了几个插件,
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>read property file</id>
<phase>install</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/dirOne/xyz.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>iterator-maven-plugin</artifactId>
<version>0.3</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>iterator</goal>
</goals>
<configuration>
<content>${CLIENTLIST}</content>
<pluginExecutors>
<pluginExecutor>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
<goal>copy-resources</goal>
<configuration>
<outputDirectory>${basedir}/dirTwo/@item@/</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources/</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<excludes><exclude>**/*.cmd</exclude></excludes>
</resource>
</resources>
</configuration>
</pluginExecutor>
</pluginExecutors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我已经使用属性读取,迭代器和copy-resources插件来获取所需的内容.
I have used properties read, iterator and copy-resources plugin to get what I needed.
- 首先我读取属性文件.
- 从属性文件读取的循环迭代值.
- 然后循环创建一个文件夹,并将资源复制到创建的文件夹中.
这篇关于Maven:读取属性文件并复制资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文