Reputation: 1587
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
Upvotes: 7
Views: 7960
Reputation: 4544
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).
Upvotes: 5