2016-12-02 4 views
0

私は、プロパティファイルを読み込み、プロパティファイルの値に基づいてフォルダを作成し、リソースをいくつかのディレクトリからそれにコピーします。Maven:プロパティファイルとコピーリソースを読み込みます

properties-file: xyz.properties 

CLIENTLIST=A,B 

以下の手順を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でも可能ですか?

答えて

0

私は性質が、私は必要なものを得るために、イテレータとコピーリソースプラグインを読んで使用しているプラ​​グインのカップル、

<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/@[email protected]/</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> 

を使用してこれをしました。

  1. 最初にプロパティファイルを読みました。
  2. ループ内では、プロパティファイルから読み取った値が反復されます。
  3. ループ内にそれぞれ作成したフォルダを作成し、作成したフォルダにリソースをコピーします。
関連する問題