Maven(3) plugin which merges multiple text files into one
<mergers> <merge> <target>${build.outputDirectory}/target.txt</target> <sources> <source>src/main/config/${property}/application.txt</source> <source>src/main/config/extended/application.txt</source> <source>src/main/config/default/application.txt</source> </sources> </merge> </mergers>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> [...] <dependencies> <dependency> <groupId>org.zcore.maven</groupId> <artifactId>merge-maven-plugin</artifactId> <version>0.0.3</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.zcore.maven</groupId> <artifactId>merge-maven-plugin</artifactId> <configuration> <mergers> <merger> <target>${build.outputDirectory}/target.txt</target> <sources> <source>src/main/resources/input0.txt</source> <source>src/main/resources/input1.txt</source> <source>src/main/resources/inputn.txt</source> </sources> <newLineBetween>false</newLineBetween> </merger> </mergers> </configuration> </plugin> </plugins> </build> [...] </project>
From the CLI use mvn org.zcore.maven:merge-maven-plugin:merge
, but within the POM it can be easily connected to a phase (most common would be package
):
<plugin> … <executions> <execution> <id>merge-files</id> <phase>package</phase> <goals> <goal>merge</goal> </goals> </execution> </executions> </plugin>