The combine goal takes a single configuration element.
The combination element defines a complete set of pipeline stage implementations that, taken together, will result in the combining of a set of inputs into a single output. How this combining is achieved is determined by what pipeline stage implementations are selected and what parameters are specified. Not all configuration is required. In fact, in the grand maven tradition of providing common sense defaults, most of the configuration has default values that will work in the majority of cases.
Let’s break it down section by section. There is a complete sample pom at the end.
The input stage is where all the resources are read.
The inputSourceReader element defines what input stage implementation will be used.
See the pipeline stage construction page for details on how the value specified in this parameter translates into a Java object used to read input resources.
Default value: FileInputSourceReader
The inputResources section defines a list of resources that will be pulled in and combined. The generic term “resources” is used instead of “file” because the plugin is intended to pull data from any source, not just filesystem files. That being said, the only input stage implementation that currently exists is a file reader. However, should it be necessary to pull from another source, say a socket or RSS feed, then it is trivial to write and wire up a new input stage implementation.
Well, the actual work of getting data from the socket or RSS feed will not be trivial, but the rest will. See the combiner-maven-plugin api documentation for information on writing a custom input stage implementation. See the pipeline stage construction page for details on how to wire in the custom implementation.
In the case of the FileInputSourceReader, both the includes and excludes sections take ant style expressions to define the files on the filesystem that will be combined together
Default value: depends on the input stage implementation being used, check the documentation for that implementation to determine what defaults are used
The transform stage is an optional stage where the resources that were read in can be manipulated in preparation for being combined. For example, it may be necessary to remove all newlines or to apply escaping.
The transformers section is a list where all the transformer stage implementations are listed.
This section is the only available configuration for the transformer stage. See the combiner-maven-plugin api documentation for information on writing a custom transformer stage implementation. See the [pipeline stage construction (pipeline_stage_construction.html “pipeline stage construction”) page for details on how to wire in the custom implementation.
Default value: none, if no transformers are specified, then the resources flow through this stage unchanged
The combine stage is when all the resources are manipulated into a single resource. For example, the appending combiner simply appends each resource together one after the other. See the combiner-maven-plugin api documentation for information on writing a custom combiner stage implementation. See the [pipeline stage construction (pipeline_stage_construction.html “pipeline stage construction”) page for details on how to wire in the custom implementation.
The output stage is where the single combined resource is written. The destination resource can be whatever type of resource the output stage implementation uses. Typically this will be a file on the filesystem but could also be a ssh or ftp location.
The outputSourceWriter element defines what output stage implementation will be used.
See the pipeline stage construction page for details on how the value specified in this parameter translates into a Java object used to write output resources.
Default value: FileOutputSourceWriter
The outputDestination element defines the location where the combined resource will be written. The value of this element depends on what output stage implementation was selected in the outputSourceWriter element.
Default value: depends on the output stage implementation being used, check the documentation for that implementation to determine what defaults are used
The encoding element determines the encoding that will be used to both read input resources and write output resources.
Default value: ${project.build.sourceEncoding}
The pom configuration for the four stages is very minimal. There may be other configuration necessary for the pipeline stage implementations. For example, if resources are written to a destination via ftp, it may be necessary to provide a username and password. The way to pass additional configuration information is via the settings section of the pom configuration.
<plugin> <groupId>com.github.jasonmfehr</groupId> <artifactId>combiner-maven-plugin</artifactId> <version>1.0.0-beta-05</version> <configuration> <skip>false</skip> <encoding>UTF-8</encoding> <combinations> <combination> <id>append-files</id> <inputResources> <includes> <include>src/main/resources/file*.txt</include> </includes> <excludes> <exclude>src/main/resources/file-exclude-me.txt</exclude> </excludes> </inputResources> <inputSourceReader>InputReader</inputSourceReader> <transformers> <transformer>Transformer1</transformer> <transformer>Transformer2</transformer> </transformers> <combiner>Combiner</combiner> <outputSourceWriter>OutputWriter</outputSourceWriter> <outputDestination>output-file.txt</outputDestination> <settings> <key1>value1</key1> <key2>value2</key2> </settings> </combination> </combinations> </configuration> <executions> <execution> <id>combiner</id> <goals> <goal>combine</goal> </goals> </execution> </executions> </plugin>