2016-12-02 2 views
0

Ich bin in ein Szenario, das heißt, lesen Sie eine Eigenschaftendatei, und basierend auf dem Wert der Eigenschaft Datei erstellen Ordner und Ressourcen aus einem Verzeichnis zu kopieren.Maven: Property-Datei lesen und Ressourcen kopieren

properties-file: xyz.properties 

CLIENTLIST=A,B 

Ich möchte folgende Schritte in Maven durchführen.

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. 

Ist es möglich in maven?

Antwort

0

Ich habe dies mit einigen 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/@[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> 

Ich habe verwendet Eigenschaften lesen, Iterator und Copy-Ressourcen-Plugin zu bekommen, was ich brauchte.

  1. Zuerst lese ich Eigenschaftendatei.
  2. In Schleife iterierte Werte, die aus der Eigenschaftendatei lesen.
  3. Und erstellt Ordner in Schleife und kopierte Ressourcen in den Ordner erstellt.
Verwandte Themen