I have a Maven project (we'll call it Shared Assembly Project) that defines an assembly file that looks like this:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/2.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/2.2.0 http://maven.apache.org/xsd/assembly-2.2.0.xsd">
<id>shared-assembly</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${schema.directory}</directory>
<outputDirectory>schemas</outputDirectory>
</fileSet>
</fileSets>
</assembly>
This assembly file is in src/main/resources/assemblies/shared-assembly.xml and can be referenced in other projects' POMs like this (which we'll call the Referencing Project):
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>shared-assembly</artifactId>
<version>${shared.assembly.version}</version>
</dependency>
</dependencies>
<configuration>
<descriptorRefs>
<descriptorRef>shared-assembly</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
The problem is the ${schema.directory} property in shared-assembly.xml. I want to specify a default value in shared-assembly.xml or the Shared Assembly Project's pom. Then, the Referencing Project should be able to override the schema.directory if needed. Unfortunately, Maven doesn't allow sharing of properties from dependency pom files. It also seems like I can't just replace "${schema.directory}" with "target/generated-sources/schema", then override the fileSet.directory in the plugin configuration. Finally, it seems like there's no property default syntax similar to this:
${schema.directory:target/generated-sources/schema}
My goals:
- Shared Assembly Project specifies the default value
- If Referencing Project uses the default value, no additional configuration required
- If Referencing Project overrides the default value, it should be simple for Referencing Project to do so (no additional plugins required)
I know there are plugins that would allow the Referencing Project to pull a property from a file in the Shared Assembly Project. However, this violates goal #2, since it would need that additional plugin just to get the default value.