 ------
 Usage
 ------
 Samuel Santos
 ------
 2013-09-08
 ------

Usage

  This document is intended to provide instructions for using the Minify Maven Plugin.\
  In order for this discussion to be useful, it's critical to cover two topics:

    [[1]] Configuring your project's <<<pom.xml>>> to run the plugin during the project's build cycle

    [[2]] Invoking the plugin from the command-line

* Configure Minify Maven Plugin

  By tying the goals of the plugin to a phase in the build cycle, the specified goals will run each time that phase of the build cycle is executed. Doing this can make it easier to add the plugin to your project, because it eliminates the need to run the plugin standalone.

  To bind the minify goal of the Minify Maven Plugin to a phase in the build cycle, you will need to add the <<<execution>>> tag with the <<<goal>>> set to <<<minify>>>. Optionally, you can bind the plugin to a different build phase by using the <<<phase>>> option. For instance, using <<<package>>> in the <<<phase>>> option will force the minify goal to run each time this phase of the build cycle occurs.

  For a complete list of the available configuration options see {{{./minify-mojo.html}minify:minify}} goal overview page.

** Merge order

  The following rules for file order are applied when input CSS  files are merged and minified into a single output file:

    [[1]] Input files defined in <<<cssSourceFiles>>> are merged before files defined in <<<cssSourceIncludes>>>.

    [[2]] Input files defined in <<<cssSourceIncludes>>> are sorted by filename before merging (see {{{./examples/patterns.html}Using include/exclude patterns}}).

    [[3]] If a file is configured both in <<<cssSourceFiles>>> and <<<cssSourceIncludes>>> then only the one defined in <<<cssSourceFiles>>> will be processed.

  The same rules for JavaScript files are applied for tags <<<jsSourceFile>>> and <<<jsSourceIncludes>>> respectively.

+---+
<project>
  <!-- ... -->
  <build>
    <plugins>
      <!-- ... -->
      <plugin>
        <groupId>com.samaxes.maven</groupId>
        <artifactId>minify-maven-plugin</artifactId>
        <version>1.7.4</version>
        <executions>
          <execution>
            <id>default-minify</id>
            <phase>package</phase><!-- When omitted defaults to 'process-resources' -->
            <configuration>
              <charset>UTF-8</charset>
              <cssSourceDir>css</cssSourceDir>
              <cssSourceFiles>
                <cssSourceFile>file-1.css</cssSourceFile>
                <!-- ... -->
                <cssSourceFile>file-n.css</cssSourceFile>
              </cssSourceFiles>
              <cssFinalFile>style.css</cssFinalFile>
              <jsSourceDir>js</jsSourceDir>
              <jsSourceFiles>
                <jsSourceFile>file-1.js</jsSourceFile>
                <!-- ... -->
                <jsSourceFile>file-n.js</jsSourceFile>
              </jsSourceFiles>
              <jsFinalFile>script.js</jsFinalFile>
              <jsEngine>CLOSURE</jsEngine>
            </configuration>
            <goals>
              <goal>minify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- ... -->
    </plugins>
  </build>
  <!-- ... -->
</project>
+---+

* Invoke from the command-line

  Create the project archive containing the new files.

+---+
mvn package
+---+
