I am having a problem with this very redundant maven configuration.
The application I'm working on is sometimes created for environments that need alternative resource packages. The current way to prepare resources for deployment is to add them to a single .zip file. The build wizard then deploys the compressed resources to the server. For some environments, alternative versions of some resources must be used. The folder structure in the project is as follows:
src / main / resources
- resource1
- resource2
- resource2
ENV1 /
-resource1 (environment-specific)
ENV2 /
-resource1 (environment-specific)
-resource3 (environment-specific)
In most environments, the resource zip file should contain the files resource1 , resource2 , resource3 . For ENV1 zip file must contain ENV1/resource1 , resource2 , resource3 . For ENV3 zip file requires ENV2/resource1 , resource2 , ENV2/resource3 .
I am currently doing this with an assembly descriptor for each environment and a separate execution in my POM file:
<plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>zip-normal-resources</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptor>assembly-descriptor.xml</descriptor> </configuration> </execution> <execution> <id>zip-ENV1-resources</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptor>assembly-descriptor-ENV1.xml</descriptor> </configuration> </execution>
And each descriptor looks very similar. "Normal" assembly descriptor:
<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>Resources</id> <includeBaseDirectory>false</includeBaseDirectory> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <directory>src/main/resources</directory> <includes> <include>*.properties</include> <include>*.xml</include> </includes> <outputDirectory>/</outputDirectory> <filtered>true</filtered> </fileSet> <fileSet> <directory>${project.build.outputDirectory}/resources</directory> <outputDirectory>/</outputDirectory> <includes> <include>**/*</include> </includes> </fileSet> </fileSets> </assembly>
Environment specific descriptor:
<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>Resources-ENV1</id> <includeBaseDirectory>false</includeBaseDirectory> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <directory>src/main/resources</directory> <includes> <include>*.properties</include> <include>*.xml</include> </includes> <excludes> <exclude>resource1</exclude> </excludes> <outputDirectory>/</outputDirectory> <filtered>true</filtered> </fileSet> <fileSet> <directory>src/main/resources/ENV1</directory> <includes> <include>*.properties</include> <include>*.xml</include> </includes> <outputDirectory>/</outputDirectory> <filtered>true</filtered> </fileSet> <fileSet> <directory>${project.build.outputDirectory}/resources</directory> <outputDirectory>/</outputDirectory> <includes> <include>**/*</include> </includes> </fileSet> </fileSets> </assembly>
This solution works, but it is very inefficient. I do not like to have several assemblies for each environment that are almost identical, with the exception of the environment names. Is there any way to simplify this?
maven maven-assembly-plugin
FrustratedWithFormsDesigner
source share