I want to pack two or more very similar distributions, the only difference is path to data set that will be inside those distributions.
Given this example for path: ${project.basedir}/src/config/dataset1
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>dataset1</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/config/dataset1/aaa</directory>
<outputDirectory>conf/aaa</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/config/dataset1/bbb</directory>
<outputDirectory>conf/bbb</outputDirectory>
</fileSet>
</fileSets>
<!-- MANY MORE FILESETS... -->
</assembly>
Now I want exactly the same assembly descriptor for different data set, for example: ${project.basedir}/src/config/dataset2
Off course I could create two assembly descriptors. But then again I would have to keep in mind to change multiple places when needed, or worse when adding another dataset or two.
Is there a way how solve this, like creating multiple executions and passing properties to it? Or something ever nicer?
EDIT: This wish item would solve everything: https://jira.codehaus.org/browse/MASSEMBLY-445
This descriptor specifies the type of assembly archive to create, the contents of the assembly, and the ways in which dependencies or its modules are bundled with an assembly. <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Defines the rules for matching and working with files in a given base directory.
The Assembly Plugin for Maven enables developers to combine project output into a single distributable archive that also contains dependencies, modules, site documentation, and other files. Your project can easily build distribution "assemblies" using one of the prefabricated assembly descriptors.
This goal is suitable either for binding to the lifecycle or calling directly from the command line (provided all required files are available before the build starts, or are produced by another goal specified before this one on the command line).
Yes, you could use properties for this.
pom.xml
. E.g.:<properties> <dataset.dir>config/dataset</dataset.dir> </properties>
Use them in your assembly descriptor just like any other property (e.g ${project.basedir}
)
For different executions you could:
use several build profiles (Maven profiles) where override property value;
or pass values directly as a mvn call argument (like mvn package -Dprop=val
)
Also, if you want to use these properties in any other place, you could populate them via placeholders in any config by using other maven plugins (for instance, maven-resource-plugin).
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