Using the maven replacer plugin to display files in a folder

I would like to use maven-replacer-plugin to replace $ file-list $ in a comma separated file with the list of files in my project folder. Is it possible?

thanks

+4
source share
1 answer

Here is what I did:

using the antrun plugin, create a temporary file with a 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 will 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 should be a better way, but hope this helps someone.

+9
source

All Articles