Skip to content

Instantly share code, notes, and snippets.

@hatemalimam
Last active September 6, 2016 01:52
Show Gist options
  • Save hatemalimam/9804007 to your computer and use it in GitHub Desktop.
Save hatemalimam/9804007 to your computer and use it in GitHub Desktop.
Simple YUI Compressor Maven Mojo Config, nosuffix needed, line-breaks after 1000 columns
<pluginRepositories>
<pluginRepository>
<name>oss.sonatype.org</name>
<id>oss.sonatype.org</id>
<url>http://oss.sonatype.org/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
</plugin>
<!-- You should have this already in you pom.xml! -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
<encoding>UTF-8</encoding>
<webResources>
<resource>
<directory>${project.build.directory}/min</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- Javascript and CSS files compression -->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<!-- Replace the files (nosuffix needed like ".min" -->
<nosuffix>true</nosuffix>
<jswarn>false</jswarn>
<!-- Overwrite existing files -->
<excludes>
<exclude>**/*.min.js</exclude>
<!--<exclude>**/*.css</exclude> *if you want to exclude css*-->
</excludes>
<warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
<webappDirectory>${project.build.directory}/min</webappDirectory>
<!-- a new line is added after 1000 columns is reached -->
<linebreakpos>1000</linebreakpos>
</configuration>
<executions>
<execution>
<id>compress_js_css</id>
<!-- this phase is very important, otherwise the files will be overwritten by the original ones -->
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment