Skip to content
Franco Victorio edited this page Apr 18, 2016 · 16 revisions

Welcome to the frontend-maven-plugin wiki!

This wiki should be open for everyone to post examples and documentation. It may not be as updated as the README file which serves as the core documentation.

Configuration

Each plugin goal has different configuration options.

install-node-and-npm

  • nodeVersion - the version of node to install
  • npmVersion - the version of npm to install
  • downloadRoot (optional) - where to download node and npm from, defaults to http://nodejs.org/dist/

npm

  • arguments - the arguments to pass to npm, defaults to install.

grunt & gulp

  • arguments - the arguments to pass to grunt or gulp, e.g. build
  • srcdir (optional, for M2Eclipse integration) - a directory to check for changed files before executing in an incremental build
  • triggerfiles (optional, for M2Eclipse integration) - a list of files to check for changes before executing in an incremental build
  • outputdir (optional, for M2Eclipse integration) - a directory to refresh when the build completes, so Eclipse sees changed files

The changed file checking only occurs during an incremental build when using M2Eclipse. In any other environment those options are ignored and builds are always run.

Example:

<configuration>
  <srcdir>${basedir}/src/main/frontend</srcdir>
  <outputdir>${project.build.directory}/frontend</outputdir>
  <triggerfiles>
    <triggerfile>gulpfile.js</triggerfile>
    <triggerfile>package.json</triggerfile>
  </triggerfiles>
</configuration>

karma

  • karmaConfPath - the path to the karma configuration file, defaults to karma.conf.js

Environment Variables

You can add an <environmentVariables> element to the configuration element of gulp, grunt or karma to pass additional variables that will be accessible using process.env. For example:

<configuration>
    <environmentVariables>
        <OUTPUT_DIR>${project.build.directory}</OUTPUT_DIR>
    </environmentVariables> 
</configuration>

Support for io.js

There's a way to make this plugin work, with the download-maven-plugin: https://github.com/eirslett/frontend-maven-plugin/issues/136

Blogs mentioning this plugin

  1. http://wicketinaction.com/2014/07/build-resources-with-node.js/ - describes how to use frontend-maven-plugin for building, watching and live reloading Less and JavaScript resources in Apache Wicket application

  2. http://supposed.nl/2014/06/02/integrate-gulp-and-grunt-into-your-maven-build.html - Integrate Gulp And Grunt Into Your Maven Build

Maven 2

In case you need to work with Maven 2 instead of Maven 3, you can use the Frontend-Maven-Plugin up to version 0.0.22 and add an additional dependency in the plugin configuration to plexus-utils like so:

<plugins>
    <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <!-- Use the latest possible version:
        https://repo1.maven.org/maven2/com/github/eirslett/frontend-maven-plugin/ -->
        <version>0.0.22</version> <!-- last version supported by maven 2 -->
        <dependencies>
            <dependency>
                <groupId>org.codehaus.plexus</groupId>
                <artifactId>plexus-utils</artifactId>
                <version>2.1</version>
            </dependency>
        </dependencies>
        ...
    </plugin>
...
Clone this wiki locally