Skip to content
Eirik Sletteberg edited this page Mar 28, 2023 · 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-yarn

  • nodeVersion - the version of node to install
  • yarnVersion - the version of yarn to install
  • nodeDownloadRoot (optional) - where to download node from, defaults to https://nodejs.org/dist/
  • yarnDownloadRoot (optional) - where to download yarn from, defaults to https://github.com/yarnpkg/yarn/releases/download/
  • serverId (optional) - Server Id for download username and password, defaults to ""
  • skip.installyarn (optional) - Flag for whether or not to skip execution of this plugin

install-node-and-npm

  • nodeVersion - the version of node to install
  • npmVersion (optional with node version >= 4.0.0) - the version of npm to install. Defaults to using npm provided by node distribution
  • downloadRoot (optional) - where to download node and npm from. Defaults to http://nodejs.org/dist/
  • npmDownloadRoot (optional) - where to download npm from. Defaults to https://registry.npmjs.org/npm/-/ if npmVersion is specified, or downloadRoot if both npmVersion and downloadRoot is specified.

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>

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. https://web.archive.org/web/20140606070610/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 or 3.0

In case you need to work with Maven 2 instead of Maven 3.1, 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>
...