Original source files below sub-folder keyfilter:
Aggregated file in target below sub-folder keyfilter:
This can be achieved with the following resources set
<resourcesSet>
<includes>
...
<include>keyfilter/**</include>
...
</includes>
<aggregations>
<aggregation>
<inputDir>...</inputDir>
<subDirMode>true</subDirMode>
</aggregation>
</aggregations>
</resourcesSet>
The second feature is a preparation of uncompressed resources. Sometimes you have to build / deliver compressed and uncompressed resources. In JSF you can use then uncompressed resources if ProjectStage is "Development". RichFaces has e.g. this handy feature. resources-optimizer-maven-plugin allows to define several aggregation tags, e.g. one for compressed and one for uncompressed resources. The following picture demonstrates this approach.Two folders, for compressed (primefaces-extensions) and uncompressed (primefaces-extensions-uncompressed) resources:
That can be achieved with this resources set
<resourcesSet>
<includes>
...
</includes>
<aggregations>
<aggregation>
<inputDir>${resources.dir.compressed}</inputDir>
...
</aggregation>
<aggregation>
<withoutCompress>true</withoutCompress>
<inputDir>${resources.dir.uncompressed}</inputDir>
...
</aggregation>
</aggregations>
</resourcesSet>
<properties>
<resources.dir.compressed>
${project.build.directory}/classes/META-INF/resources/primefaces-extensions
</resources.dir.compressed>
<resources.dir.uncompressed>
${project.build.directory}/classes/META-INF/resources/primefaces-extensions-uncompressed
</resources.dir.uncompressed>
</properties>
Output directory for uncompressed resources should be created first. Put maven-resources-plugin with phase generate-resources in front of resources-optimizer-maven-plugin (phase prepare-package).<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${resources.dir.uncompressed}</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources/META-INF/resources/primefaces-extensions</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
These were examples for an JAR project. The same is also valid for WAR (web) projects of course.



Aw, this was a really nice post. In idea I would like to put in writing like this additionally – taking time and actual effort to make a very good article… but what can I say… I procrastinate alot and by no means seem to get something done.
ReplyDeleteThe aggregation of several files to one compress file doesn't work. Aggregations/Aggreation is unknown...
ReplyDeleteSure it works. We use it. What for version do you use? Try the last one (0.5).
ReplyDelete