[ http://jira.codehaus.org/browse/MASSEMBLY-445?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stevo Slavic updated MASSEMBLY-445: ----------------------------------- Attachment: org.apache.maven.plugins.maven-assembly-plugin-MASSEMBLY-445.patch After rethinking this new feature, I've come to a conclusion that initially it would be enough to just expose assembly id so it becomes referenceable as parameter from within component descriptors. Here is a patch ( [^org.apache.maven.plugins.maven-assembly-plugin-MASSEMBLY-445.patch] ) which adds support for this new feature. It works like this: - If assembly id is defined in assembly descriptor ([assembly-1.1.1.xsd|http://maven.apache.org/xsd/assembly-1.1.1.xsd] allows it not to be) that is being processed by the assembly plugin, then assembly interpolator gets configured to replace "${assembly.id}" references with current assembly's id value; - This substitution works correctly also when assembly id itself references some cli/environment/project parameter/property, like project.build.finalName; - A fresh interpolator is created for interpolation of every assembly in a given project, so correct assembly id will be used for assembly interpolation if there are more than one assemblies defined; - Because of when existing assembly plugin code applies assembly interpolation (after merging info from component descriptor(s) into assembly - and I didn't want to change that), assembly.id can be referenced from assembly descriptor, but primary goal was to support referencing it from component descriptor; - If assembly.id is defined as project property, or given as cli parameter, than that property/parameter value will take precedence compared to assembly descriptor's id value when it comes to assembly/component interpolation. Patch contains additional tests for this feature, and all of them, including existing ones, pass. > Support parametrization of component descriptors > ------------------------------------------------ > > Key: MASSEMBLY-445 > URL: http://jira.codehaus.org/browse/MASSEMBLY-445 > Project: Maven 2.x Assembly Plugin > Issue Type: Wish > Affects Versions: 2.2-beta-4 > Reporter: Stevo Slavic > Attachments: > org.apache.maven.plugins.maven-assembly-plugin-MASSEMBLY-445.patch > > > Please support parametrization of component descriptors. One should be able > to specify parameter placeholders in component descriptors, and when > referencing component descriptor from an assembly descriptor provide actual > parameter value(s) which would then be applied to the parameter placeholders. > One should be able to set global parameters (for all component descriptors), > and component descriptor specific parameters, with component descriptor > specific parameters overriding global ones if their names overlap. > This would be useful if e.g. one uses assembly descriptors to specify > assemblies for different deployment environments, and if these assemblies > differ (see example [1]) only in which environment specific configuration > file should be included in the assembly where this distinction is based on > configuration file name suffix - this suffix could be passed to shared > component descriptor as parameter, like in example [2]. > [1] assembly descriptor example without parameters > <?xml version="1.0" encoding="UTF-8"?> > <assembly > xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 > > http://maven.apache.org/xsd/assembly-1.1.1.xsd"> > <id>prod</id> > <formats> > <format>war</format> > </formats> > <includeBaseDirectory>false</includeBaseDirectory> > <fileSets> > <fileSet> > > <directory>${project.build.directory}/${project.build.finalName}</directory> > <outputDirectory>/</outputDirectory> > <excludes> > <exclude>**/jdbc.properties</exclude> > <exclude>**/jdbc-*.properties</exclude> > </excludes> > <excludes> > <exclude>**/log4j.xml</exclude> > <exclude>**/log4j-*.xml</exclude> > </excludes> > </fileSet> > </fileSets> > <files> > <file> > > <source>${project.build.outputDirectory}/com/foo/bar/cfg/jdbc-${environment}.properties</source> > > <outputDirectory>WEB-INF/classes/com/foo/bar/cfg/</outputDirectory> > <destName>jdbc.properties</destName> > </file> > <file> > > <source>${project.build.outputDirectory}/com/foo/bar/cfg/log4j-${environment}.xml</source> > <outputDirectory>WEB-INF/classes/</outputDirectory> > <destName>log4j.xml</destName> > </file> > </files> > </assembly> > [2] parametrized component descriptor and usage example > src/main/assembly/component.xml > --------------------- > <component> > <fileSets> > <fileSet> > > <directory>${project.build.directory}/${project.build.finalName}</directory> > <outputDirectory>/</outputDirectory> > <excludes> > <exclude>**/jdbc.properties</exclude> > <exclude>**/jdbc-*.properties</exclude> > </excludes> > <excludes> > <exclude>**/log4j.xml</exclude> > <exclude>**/log4j-*.xml</exclude> > </excludes> > </fileSet> > </fileSets> > <files> > <file> > > <source>${project.build.outputDirectory}/com/foo/bar/cfg/jdbc-${environment}.properties</source> > > <outputDirectory>WEB-INF/classes/com/foo/bar/cfg/</outputDirectory> > <destName>jdbc.properties</destName> > </file> > <file> > > <source>${project.build.outputDirectory}/com/foo/bar/cfg/log4j-${environment}.xml</source> > <outputDirectory>WEB-INF/classes/</outputDirectory> > <destName>log4j.xml</destName> > </file> > </files> > </component> > src/main/assembly/packaging-prod.xml > ------------------------------------------------------ > <?xml version="1.0" encoding="UTF-8"?> > <assembly > xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 > > http://maven.apache.org/xsd/assembly-1.1.1.xsd"> > <id>prod</id> > <formats> > <format>war</format> > </formats> > <includeBaseDirectory>false</includeBaseDirectory> > <componentDescriptors> > <componentDescriptor> > > <pathToComponentDescriptor>src/main/assembly/component.xml</pathToComponentDescriptor> > <parameters> > <parameter> > <name>environment</environment> > <value>prod</value> > </parameter> > </parameters > </componentDescriptor> > </componentDescriptors> > </assembly> > src/main/assembly/packaging-stag.xml > ------------------------------------------------------ > <?xml version="1.0" encoding="UTF-8"?> > <assembly > xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 > > http://maven.apache.org/xsd/assembly-1.1.1.xsd"> > <id>stag</id> > <formats> > <format>war</format> > </formats> > <includeBaseDirectory>false</includeBaseDirectory> > <componentDescriptors> > <componentDescriptor> > > <pathToComponentDescriptor>src/main/assembly/component.xml</pathToComponentDescriptor> > <parameters> > <!-- component descriptor specific parameters > --> > <parameter> > <name>environment</environment> > <value>stag</value> > </parameter> > </parameters> > </componentDescriptor> > </parameters> > <!-- global parameters for all component descriptors --> > </parameters> > </componentDescriptors> > </assembly> -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira