Maven: Read property file and copy resources

假如想象 提交于 2019-12-04 20:38:04

I did this using couple of plugins,

<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>

I have used properties read, iterator and copy-resources plugin to get what I needed.

  1. First I read property file.
  2. In loop iterated values which read from properties file.
  3. And created folder each in loop and copied resources to created folder.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!