I am trying to include xml file in pom.xml (maven) .
My pom.xml looks somehting likes this
<?xml version="1.0" encoding="UTF-8"?>
<project>
<!-- <xi:include href="minify.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
--> <modelVersion>4.0.0</modelVersion>
<groupId>myproject</groupId>
<artifactId>myproject</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<description></description>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<!-- include plugin tag from other xml file -->
// I would like maintain one seperate xml file to hold all plugin tags (to reduce pom.xml //file content.
</plugins>
I am using "com.samaxes.maven" to minify css and js files .
But I have kept my css and js files in many seperate folders . I need to include this below tag repeatedly
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.4</version>
<executions>
<execution>
<id>default-minify-1</id>
<configuration>
<charset>utf-8</charset>
<jsEngine>CLOSURE</jsEngine>
<skipMerge>true</skipMerge>
<nosuffix>true</nosuffix>
<!-- <skipMinify>true</skipMinify> --> <!--skips already minfied css fiels -->
<cssSourceDir>inc/one/css</cssSourceDir>
<cssTargetDir>inc/one/css/mini</cssTargetDir>
<cssSourceIncludes>
<cssSourceInclude>*.css</cssSourceInclude>
</cssSourceIncludes>
<jsSourceDir>proj/platform/common/js/</jsSourceDir>
<jsTargetDir>proj/platform/common/js/mini</jsTargetDir>
<jsSourceIncludes>
<jsSourceInclude>*.js</jsSourceInclude>
</jsSourceIncludes>
<closureCreateSourceMap>true</closureCreateSourceMap>
</configuration>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
</plugin>
I googled possible way to include multiple directories ,then I decided to include all directories by repeating above snippet code . But later though to separate all mifiy include to other xml file . I am looking some way to include xml file inside tag . Some one please help me out.
Another way of doing this is to use the iterator maven plugin. It has an ability to iterate over folders and invoke another plugin for each item.
For your scenario, it would be something like
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>iterator-maven-plugin</artifactId>
<version>0.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>iterator</goal>
</goals>
<configuration>
<folder>whatever/your/folder/is</folder>
<pluginExecutors>
<pluginExecutor>
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.4</version>
</plugin>
<goal>minify</goal>
<executions>
<execution>
<id>default-minify-1</id>
<configuration>
<charset>utf-8</charset>
<jsEngine>CLOSURE</jsEngine>
<skipMerge>true</skipMerge>
<nosuffix>true</nosuffix>
<!-- <skipMinify>true</skipMinify> --> <!--skips already minfied css fiels -->
<cssSourceDir>@item@/inc/one/css</cssSourceDir>
<cssTargetDir>@item@/inc/one/css/mini</cssTargetDir>
<cssSourceIncludes>
<cssSourceInclude>*.css</cssSourceInclude>
</cssSourceIncludes>
<jsSourceDir>@item@/proj/platform/common/js/</jsSourceDir>
<jsTargetDir>@item@/proj/platform/common/js/mini</jsTargetDir>
<jsSourceIncludes>
<jsSourceInclude>*.js</jsSourceInclude>
</jsSourceIncludes>
<closureCreateSourceMap>true</closureCreateSourceMap>
</configuration>
</execution>
</executions>
</pluginExecutor>
</pluginExecutors>
</configuration>
</execution>
</executions>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With