I'd like to use the maven-replacer-plugin to replace $file-list$ in a file with a comma separated list of files in a folder of my project. Is this possible?
thanks
Here is what I did :
using the antrun plugin create a temp file with the list in it :
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<fileset id="my-fileset" dir="src/main/resources" />
<pathconvert targetos="unix" pathsep=","
property="my-file-list" refid="my-fileset">
<map from="${basedir}\src\main\resources\" to="" />
</pathconvert>
<echo file="${basedir}\target\file-list.txt">${my-file-list}</echo>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
then using the replacer plugin I replace the list in the file that I want :
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<executions>
<execution>
<id>replace-file-list</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<ignoreMissingFile>false</ignoreMissingFile>
<file>target/MY_FILE.TXT</file>
<regex>false</regex>
<token>$file-list$</token>
<valueFile>target/file-list.txt</valueFile>
</configuration>
</execution>
</executions>
</plugin>
I'm sure there must be a better way, but hope this helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With