Code Monkey home page Code Monkey logo

frontend-maven-plugin's Introduction

frontend-maven-plugin

Build Status OSX and Linux Build status Windows Maven Central

This plugin downloads/installs Node and NPM locally for your project, runs npm install, and then any combination of Bower, Grunt, Gulp, Jspm, Karma, or Webpack. It's supposed to work on Windows, OS X and Linux.

If you prefer Yarn over NPM for your node package fetching, this plugin can also download Node and Yarn and then run yarn install for your project.

What is this plugin meant to do?

  • Let you keep your frontend and backend builds as separate as possible, by reducing the amount of interaction between them to the bare minimum; using only 1 plugin.
  • Let you use Node.js and its libraries in your build process without installing Node/NPM globally for your build system
  • Let you ensure that the version of Node and NPM being run is the same in every build environment

What is this plugin not meant to do?

  • Not meant to replace the developer version of Node - frontend developers will still install Node on their laptops, but backend developers can run a clean build without even installing Node on their computer.
  • Not meant to install Node for production uses. The Node usage is intended as part of a frontend build, running common javascript tasks such as minification, obfuscation, compression, packaging, testing etc.

Notice: This plugin does not support already installed Node or npm versions. Use the exec-maven-plugin instead.

Requirements

  • Maven 3.6 and Java 1.8
  • For Maven 2 support take a look at the wiki.

Installation

Include the plugin as a dependency in your Maven project. Change LATEST_VERSION to the latest tagged version.

<plugins>
    <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <!-- Use the latest released version:
        https://repo1.maven.org/maven2/com/github/eirslett/frontend-maven-plugin/ -->
        <version>LATEST_VERSION</version>
        ...
    </plugin>
...

Usage

Have a look at the example project, to see how it should be set up: https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plugin/src/it/example%20project/pom.xml

Recommendation: Try to run all your tasks via npm scripts instead of running bower, grunt, gulp etc. directly.

Installing node and npm

The versions of Node and npm are downloaded from https://nodejs.org/dist, extracted and put into a node folder created in your installation directory . Node/npm will only be "installed" locally to your project. It will not be installed globally on the whole system (and it will not interfere with any Node/npm installations already present).

<plugin>
    ...
    <executions>
        <execution>
            <!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
            <id>install node and npm</id>
            <goals>
                <goal>install-node-and-npm</goal>
            </goals>
            <!-- optional: default phase is "generate-resources" -->
            <phase>generate-resources</phase>
        </execution>
    </executions>
    <configuration>
        <nodeVersion>v4.6.0</nodeVersion>

        <!-- optional: with node version greater than 4.0.0 will use npm provided by node distribution -->
        <npmVersion>2.15.9</npmVersion>
        
        <!-- optional: where to download node and npm from. Defaults to https://nodejs.org/dist/ -->
        <downloadRoot>http://myproxy.example.org/nodejs/</downloadRoot>
    </configuration>
</plugin>

You can also specify separate download roots for npm and node as they are stored in separate repos. In case the root configured requires authentication, you can specify a server ID from your maven settings file:

<plugin>
    ...
    <configuration>
        <!-- optional: where to download node from. Defaults to https://nodejs.org/dist/ -->
        <nodeDownloadRoot>http://myproxy.example.org/nodejs/</nodeDownloadRoot>
	<!-- optional: credentials to use from Maven settings to download node -->
        <serverId>server001</serverId>
        <!-- optional: where to download npm from. Defaults to https://registry.npmjs.org/npm/-/ -->
        <npmDownloadRoot>https://myproxy.example.org/npm/</npmDownloadRoot>
    </configuration>
</plugin>

You can use Nexus repository Manager to proxy npm registries. See https://help.sonatype.com/display/NXRM3/Npm+Registry

Notice: Remember to gitignore the node folder, unless you actually want to commit it.

Installing node and yarn

Instead of using Node with npm you can alternatively choose to install Node with Yarn as the package manager.

The versions of Node and Yarn are downloaded from https://nodejs.org/dist for Node and from the Github releases for Yarn, extracted and put into a node folder created in your installation directory. Node/Yarn will only be "installed" locally to your project. It will not be installed globally on the whole system (and it will not interfere with any Node/Yarn installations already present).

If your project is using Yarn Berry (2.x or above), the Yarn version is handled per project but a Yarn 1.x install is still needed as a "bootstrap". The plugin will try to detect .yarnrc.yml file in the current Maven project/module folder, at the root of the multi-module project if relevant, and in the folder from which the mvn command was run. If detected, the plugin will assume your project is using Yarn Berry. It will install the 1.x Yarn version you specify with yarnVersion as bootstrap, then hand over to your project-specific version.

Have a look at the example POM to see how it should be set up with Yarn: https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plugin/src/it/yarn-integration/pom.xml

<plugin>
    ...
    <execution>
        <!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
        <id>install node and yarn</id>
        <goals>
            <goal>install-node-and-yarn</goal>
        </goals>
        <!-- optional: default phase is "generate-resources" -->
        <phase>generate-resources</phase>
    </execution>
    <configuration>
        <nodeVersion>v6.9.1</nodeVersion>
        <yarnVersion>v0.16.1</yarnVersion>

        <!-- optional: where to download node from. Defaults to https://nodejs.org/dist/ -->
        <nodeDownloadRoot>http://myproxy.example.org/nodejs/</nodeDownloadRoot>
        <!-- optional: where to download yarn from. Defaults to https://github.com/yarnpkg/yarn/releases/download/ -->
        <yarnDownloadRoot>http://myproxy.example.org/yarn/</yarnDownloadRoot>        
    </configuration>
</plugin>

Running npm

All node packaged modules will be installed in the node_modules folder in your working directory. By default, colors will be shown in the log.

<execution>
    <id>npm install</id>
    <goals>
        <goal>npm</goal>
    </goals>

    <!-- optional: default phase is "generate-resources" -->
    <phase>generate-resources</phase>

    <configuration>
        <!-- optional: The default argument is actually
        "install", so unless you need to run some other npm command,
        you can remove this whole <configuration> section.
        -->
        <arguments>install</arguments>
    </configuration>
</execution>

Notice: Remember to gitignore the node_modules folder, unless you actually want to commit it. Npm packages will always be installed in node_modules next to your package.json, which is default npm behavior.

npx

You can also use npx command, enabling you to execute the CLI of installed packages without a run-script, or even packages that aren't installed at all.

<execution>
    <id>say hello</id>
    <goals>
        <goal>npx</goal>
    </goals>

    <phase>generate-resources</phase>

    <configuration>
        <arguments>cowsay hello</arguments>
    </configuration>
</execution>

Running yarn

As with npm above, all node packaged modules will be installed in the node_modules folder in your working directory.

<execution>
    <id>yarn install</id>
    <goals>
        <goal>yarn</goal>
    </goals>
    <configuration>
         <!-- optional: The default argument is actually
         "install", so unless you need to run some other yarn command,
         you can remove this whole <configuration> section.
         -->
        <arguments>install</arguments>
    </configuration>
</execution>

Yarn with Private Registry

NOTE: if you have a private npm registry that mirrors the npm registry, be aware that yarn.lock includes URLs to the npmjs.org module registry and yarn install will use these paths when installing modules.

If you want yarn.lock to use your private npm registry, be sure to run these commands on your local machine before you generate yarn.lock:

yarn config set registry <your_registry_url>
yarn install

This will create URLs in your yarn.lock file that reference your private npm registry.

Another way to set a registry is to add a .npmrc file in your project's root directory that contains:

registry=<your_registry_url>

Also you can set a registry using a tag npmRegistryURL

<execution>
    <id>yarn install</id>
    <goals>
        <goal>yarn</goal>
    </goals>
    <configuration>
         <!-- optional: The default argument is actually
         "install", so unless you need to run some other yarn command,
         you can remove this whole <configuration> section.
         -->
        <arguments>install</arguments>
	<!-- optional: where to download npm modules from. Defaults to https://registry.yarnpkg.com/ -->
	<npmRegistryURL>http://myregistry.example.org/</npmRegistryURL>
    </configuration>
</execution>

Running bower

All bower dependencies will be installed in the bower_components folder in your working directory.

<execution>
    <id>bower install</id>
    <goals>
        <goal>bower</goal>
    </goals>

    <configuration>
        <!-- optional: The default argument is actually
        "install", so unless you need to run some other bower command,
        you can remove this whole <configuration> section.
        -->
        <arguments>install</arguments>
    </configuration>
</execution>

Notice: Remember to gitignore the bower_components folder, unless you actually want to commit it.

Running Grunt

It will run Grunt according to the Gruntfile.js in your working directory. By default, colors will be shown in the log.

<execution>
    <id>grunt build</id>
    <goals>
        <goal>grunt</goal>
    </goals>

    <!-- optional: the default phase is "generate-resources" -->
    <phase>generate-resources</phase>

    <configuration>
        <!-- optional: if not specified, it will run Grunt's default
        task (and you can remove this whole <configuration> section.) -->
        <arguments>build</arguments>
    </configuration>
</execution>

Running gulp

Very similar to the Grunt execution. It will run gulp according to the gulpfile.js in your working directory. By default, colors will be shown in the log.

<execution>
    <id>gulp build</id>
    <goals>
        <goal>gulp</goal>
    </goals>

    <!-- optional: the default phase is "generate-resources" -->
    <phase>generate-resources</phase>

    <configuration>
        <!-- optional: if not specified, it will run gulp's default
        task (and you can remove this whole <configuration> section.) -->
        <arguments>build</arguments>
    </configuration>
</execution>

Running jspm

All jspm dependencies will be installed in the jspm_packages folder in your working directory.

<execution>
    <id>jspm install</id>
    <goals>
        <goal>jspm</goal>
    </goals>

    <configuration>
	    <!-- optional: The default argument is actually
	    "install", so unless you need to run some other jspm command,
	    you can remove this whole <configuration> section.
	    -->
        <arguments>install</arguments>
    </configuration>
</execution>

Running Karma

<execution>
    <id>javascript tests</id>
    <goals>
        <goal>karma</goal>
    </goals>

    <!-- optional: the default plase is "test". Some developers
    choose to run karma in the "integration-test" phase. -->
    <phase>test</phase>

    <configuration>
        <!-- optional: the default is "karma.conf.js" in your working directory -->
        <karmaConfPath>src/test/javascript/karma.conf.ci.js</karmaConfPath>
    </configuration>
</execution>

Skipping tests: If you run maven with the -DskipTests flag, karma tests will be skipped.

Ignoring failed tests: If you want to ignore test failures run maven with the -Dmaven.test.failure.ignore flag, karma test results will not stop the build but test results will remain in test output files. Suitable for continuous integration tool builds.

Why karma.conf.ci.js? When using Karma, you should have two separate configurations: karma.conf.js and karma.conf.ci.js. (The second one should inherit configuration from the first one, and override some options. The example project shows you how to set it up.) The idea is that you use karma.conf.js while developing (using watch/livereload etc.), and karma.conf.ci.js when building - for example, when building, it should only run karma once, it should generate xml reports, it should run only in PhantomJS, and/or it should generate code coverage reports.

Running Karma through Grunt or gulp: You may choose to run Karma directly through Grunt or through gulp instead, as part of the grunt or gulp execution. That will help to separate your frontend and backend builds even more.

Running Webpack

<execution>
    <id>webpack build</id>
    <goals>
        <goal>webpack</goal>
    </goals>

    <!-- optional: the default phase is "generate-resources" -->
    <phase>generate-resources</phase>

    <configuration>
        <!-- optional: if not specified, it will run webpack's default
        build (and you can remove this whole <configuration> section.) -->
        <arguments>-p</arguments>
    </configuration>
</execution>

Optional Configuration

Working directory

The working directory is where you've put package.json and your frontend configuration files (Gruntfile.js or gulpfile.js etc). The default working directory is your project's base directory (the same directory as your pom.xml). You can change the working directory if you want:

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>

    <!-- optional -->
    <configuration>
        <workingDirectory>src/main/frontend</workingDirectory>
    </configuration>
</plugin>

Notice: Npm packages will always be installed in node_modules next to your package.json, which is default npm behavior.

Installation Directory

The installation directory is the folder where your node and npm are installed. You can set this property on the different goals. Or choose to set it for all the goals, in the maven configuration.

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>

    <!-- optional -->
    <configuration>
        <installDirectory>target</installDirectory>
    </configuration>    
</plugin>

Proxy settings

If you have configured proxy settings for Maven in your settings.xml file, the plugin will automatically use the proxy for downloading node and npm, as well as passing the proxy to npm commands.

Non Proxy Hosts: npm does not currently support non proxy hosts - if you are using a proxy and npm install is not downloading from your repository, it may be because it cannot be accessed through your proxy. If that is the case, you can stop the npm execution from inheriting the Maven proxy settings like this:

<configuration>
    <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven>
</configuration>

If you have configured proxy settings for Maven in your settings.xml file, the plugin will automatically pass the proxy to bower commands. If that is the case, you can stop the bower execution from inheriting the Maven proxy settings like this:

<configuration>
    <bowerInheritsProxyConfigFromMaven>false</bowerInheritsProxyConfigFromMaven>
</configuration>

If you want to disable proxy for Yarn you can use yarnInheritsProxyConfigFromMaven. When you have proxy settings in your settings.xml file if you don't use this param it will run code below with proxy settings, in some cases you don't want that. Adding this param into the configuration section will solve this issue

<execution>
    <id>tests</id>
    <goals>
        <goal>yarn</goal>
    </goals>
    <phase>compile</phase>
    <configuration>
        <yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven>
        <arguments>run test</arguments>
    </configuration>
</execution>

Environment variables

If you need to pass some variable to Node, you can set that using the property environmentVariables in configuration tag of an execution like this:

<configuration>
    <environmentVariables>
        <!-- Simple var -->
        <Jon>Snow</Jon>
        <Tyrion>Lannister</Tyrion>
        
        <!-- Var value take from maven properties -->
        <NODE_ENV>${NODE_ENV}</NODE_ENV>
    </environmentVariables>        
</configuration>

Ignoring Failure

Ignoring failed tests: If you want to ignore test failures in specific execution you can set that using the property maven.test.failure.ignore in configuration tag of an execution like this:

<configuration>
    <testFailureIgnore>true</testFailureIgnore>
</configuration>

Skipping Execution

Each frontend build tool and package manager allows skipping execution. This is useful for projects that contain multiple builds (such as a module containing Java and frontend code).

Note that if the package manager (npm or yarn) is skipped, other build tools will also need to be skipped because they would not have been downloaded. For example, in a project using npm and gulp, if npm is skipped, gulp must also be skipped or the build will fail.

Tools and property to enable skipping

  • npm -Dskip.npm
  • yarn -Dskip.yarn
  • bower -Dskip.bower
  • bun -Dskip.bun
  • grunt -Dskip.grunt
  • gulp -Dskip.gulp
  • jspm -Dskip.jspm
  • karma -Dskip.karma
  • webpack -Dskip.webpack

Eclipse M2E support

This plugin contains support for M2E, including lifecycle mappings and support for incremental builds in Eclipse. The install-node-and-npm goal will only run on a full project build. The other goals support incremental builds to avoid doing unnecessary work. During an incremental build the npm goal will only run if the package.json file has been changed. The grunt and gulp goals have new srcdir and triggerfiles optional configuration options; if these are set they check for changes in your source files before being run. See the wiki for more information.

Helper scripts

During development, it's convenient to have the "npm", "bower", "grunt", "gulp" and "karma" commands available on the command line. If you want that, use those helper scripts!

To build this project:

Run $ mvn clean install

Issues, Contributing

Please post any issues on the Github's Issue tracker. Pull requests are welcome! You can find a full list of contributors here.

License

Apache 2.0

frontend-maven-plugin's People

Contributors

ammendonca avatar arminha avatar b-long avatar blacktiger avatar bmarwell avatar casell avatar cavva79 avatar chrisvdp avatar dependabot[bot] avatar eirslett avatar fidel-karsto avatar heldinz avatar jgeorgeson avatar jglick avatar jimmyfm avatar karlvr avatar kash-raman avatar klieber avatar kwa avatar melbit-simonwhite avatar mikethomsen avatar mtraynham avatar pitgrap avatar reinhard avatar seregamorph avatar snyk-bot avatar stephenc avatar stevenbower avatar wherget avatar zardoz89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frontend-maven-plugin's Issues

Consider adding a sourceDirectory configuration option

Consider the following scenario: I want to run Gulp tasks for an Angular project in a subdirectory in my Maven module, but I don't necessarily want to have Node.js installed (for whatever reason, each machine that runs the Maven project is responsible for setting up its own Node/NPM installation). In other words, I need to configure the workingDirectory option but I do not want to use the install-node-and-npm goal.

Apparently this is impossible right now. Using the workingDirectory option means that the plugin will look for the source files in that directory but it also looks for a node installation in that directory:

Caused by: java.io.IOException: Cannot run program "c:\bla\bla\src\node\node" (in directory "c:\bla\bla\src"): CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
        at com.github.eirslett.maven.plugins.frontend.lib.ProcessExecutor.executeAndRedirectOutput(ProcessExecutor.java:58)
        ... 24 more

Forgive me any ignorance on the subject, but I'd like to propose that the workingDirectory is split into 2 different options:

  • workingDirectory: the location where to install any runtime files, such as the node and NPM runtimes, regardless of source files.
  • sourceDirectory: the location where to find the actual project source files, regardless of Node/NPM binaries.

What do you think? This seems a little related to issue #18.

Rename "target" configuration to "arguments"

From

<execution>
    <id>grunt build</id>
    <goals>
        <goal>grunt</goal>
    </goals>
    <configuration>
      <target>my grunt --arguments</target>
    </configuration>
</execution>

to

<execution>
    <id>grunt build</id>
    <goals>
        <goal>grunt</goal>
    </goals>
    <configuration>
      <arguments>my grunt --arguments</arguments>
    </configuration>
</execution>

Feature request: Cache the downloaded installer

It would be great if the plugin could cache the downloaded node installer in one location, and install it to another location (under target, or in a configurable place; see #18). That way you can install into target and get a fresh, virgin installation every time you do "mvn clean", but you don't have to re-download from a remote internet host on every build. This is the approach used by the cargo plugin.

Always run Grunt with --no-color

The colors reportedly mess up Maven logs (#2).
I think I'm going to turn off colors by default. Is there any use case where colors in the Maven build log is desired anyways?

Cannot download

Hello,

For some reason I am not able to find your plugin for download from github (error: not found), whereas I can fetch another one (such as allegro's grunt-maven-plugin) with success.
I used the pom plugin configuration from your example. Any idea?

unwanted path create for node_temp/node.tar.gz

Hi,

I'm seeing this message during my build process.

(I'm not sure if my workplace is "ok" with their directory structure appearing here -names replace with A,B,C,D, etc),

Unpacking /Users/chrisdep/Documents/A/B/C/D/E/F/G/H/I/npm.tar.gz into /Users/chrisdep/Documents/A/B/C/D/E/F/G/H/I/node

After its done, there is a new directory created in the location I started the build from, 'Users'.

And inside Users, chrisdep and so on...

$projectroot/Users/chrisdep/Documents/A/B/C/D/E/F/G/H/I/node_tmp/

https://github.com/eirslett/frontend-maven-plugin/search?q=node_tmp&ref=cmdform

Chris

ERROR: The system cannot find the path specified.

I am trying to simply run a Grunt task from Maven using the 0.0.15-SNAPSHOT (i have also tried 0.0.14) and can't seem to get it to work. The grunt task does nothing more the print a log statement currently. I am getting "The system cannot find the path specified." but the directory is there. I have also tried to configure the workingDirectory using the Maven ${project.basedir}, hardcoding it to the path and removing the configuration completely.

Any Ideas?

[INFO] Running 'grunt build:dev --no-color' in C:\projects\spire
[INFO] The system cannot find the path specified.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.407s
[INFO] Finished at: Thu Mar 06 10:39:40 EST 2014
[INFO] Final Memory: 9M/149M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:0.0.15-SNAPSHOT:grunt (grunt build) on project music: 'grunt b
uild:dev --no-color' failed. (error code 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:0.0.15-SNAPSHO
T:grunt (grunt build) on project music: 'grunt build:dev --no-color' failed. (error code 1)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: 'grunt build:dev --no-color' failed. (error code 1)
at com.github.eirslett.maven.plugins.frontend.mojo.GruntMojo.execute(GruntMojo.java:37)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

SUGGESTION: add PortableGit for multi-platform bower support

It's possible to add bower npm package. Unfortunately bower requires git to run.

OS X and many *nix distros are shipped with git. Windows is clearly an outlier.

Do you think it would make sense to add PortableGit to the project just as you did with node executable? The other problem then is somehow telling bower which git to use.

Plugin may not work on OSX (due to BSD readlink)

Mac OSX uses BSD readlink which does not support the -f flag as the GNU version, so when running the node/with_new_path throws:

...
[INFO] readlink: illegal option -- f
[INFO] usage: readlink [-n] [file ...]
[INFO] usage: dirname path
...

I haven't noticed any major issue due to that, but I assume they may happen with symlinks.

I have replaced $(readlink -f $0) locally with $(python -c 'import os,sys;print os.path.realpath(sys.argv[1])' $0). Maybe not the best approach to use python but was the cleanest I was able to have working.

Let me know if you want me to do a PR with a fix for this.

Can't download NodeJs from internal Nexus

The host I'm using blocks access to the third party URLs so NodeJs and npm can't be downloaded from nodejs.org website. An alternative we come up with is to upload NodeJs and npm packages into nexus as an maven aritifact. However, the way the plugin build NodeJs's file path and name with OS name at the end doesn't work with maven naming convention.

Is it possible to add another parameter in install-node-and-npm goal to specify nodejs's download url rather than just giving the download root? Is there a way to work around the issue I have with the current code?

maven.test.skip parameter is ignored by karma runner

maven.test.skip is used and respected by the maven-surefire-plugin. It's also used in eclipse with m2e plugin.

Adding support for the maven.test.skip parameter would enable frontend-maven-plugin to integrate better into eclipse ecosystem.

Make Maven system properties available to grunt

Maven includes build-related system properties such as project.build.directory and project.version.
It'd be nice to have these system properties available within the frontend-maven-plugin's grunt goal.

E.g., when iterating through grunt-visible environment variables ...

//somewhere programmatically within Gruntfile.js
grunt.log.writeln("About to list all available environment variables");
for (var propt in process.env) {
    grunt.log.writeln(propt + ": " + process.env[propt]);
}

... then this list would include, among others, the environment variable project.version with the enclosing Maven project's version value.

Trying to get this running but...

So just cloned the repo and did the mvn clean install. I am now trying to figure out how to run the example application and view it using nodejs server? Any help would be greatly appreciated! Thanks :)

Can't find 'node/with_new_path.sh'

Suddenly, I'm unable to run grunt commands. It looks like it can't resolve the path to node.js. Is this related to #18?.

[INFO] sh: [my project path]/node/with_new_path.sh: No such file or directory

Here's the error message with a little context:

[INFO] 
[INFO] --- frontend-maven-plugin:0.0.11:grunt (grunt build) @ ui ---
[INFO] Running 'grunt dist:all --no-color' in [my project path]
[INFO] sh: [my project path]/node/with_new_path.sh: No such file or directory
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] UI parent pom ..................................... SUCCESS [0.518s]
[INFO] UI ................................................ FAILURE [8.688s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.720s
[INFO] Finished at: Wed Jan 08 10:46:49 CST 2014
[INFO] Final Memory: 10M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:0.0.11:grunt (grunt build) on project ui: 'grunt dist:all --no-color' failed. (error code 127) -> [Help 1]

Grunt's command line interface (CLI) globally

I want to understand this right, the plugin take into consideration that the Grunt's CLI should be installed globally right?
I see that in the plug-in is:
private static final String TASK_LOCATION = "/node_modules/grunt-cli/bin/grunt";
or where in the plug0in GruntJS is installed?
Thanks

Running "sass:dist" (sass) task failed

[INFO] Running "sass:dist" (sass) task
[INFO] Warning: 
[INFO] You need to have Ruby and Sass installed and in your PATH for this task to work.
[INFO] More info: https://github.com/gruntjs/grunt-contrib-sass
[INFO]  Use --force to continue.
[INFO] 
[INFO] Aborted due to warnings.
[INFO] ------------------------------------------------------------------------

I could install sass locally and add it to my PATH, but I was wondering if this plugin provides a way around installing front-end tools. Would having it install sass be out of scope?

Please let me know if you'd like more details about the error.

also provide NTCredentials in DefaultFileDownloader

in case of a proxy with ntlm authentication NTCredentials are needed.

        credentialsProvider.setCredentials(
                new AuthScope(proxy.host, proxy.port),
                new NTCredentials(proxy.username + ":"+ proxy.password)
        );

Proxy settings not respected by all calls

Awesome plugin. One of the better maven plugins I've used in a long while!

One thing that could be even better: automatic configuration of proxy settings for subsequent calls after Node and NPM has been installed.

I've run into the following situations:

  • npm install (can be configured by setting the https-proxy command line argument for npm).
  • phantomjs download. The phantomjs npm package triggers a download of the phantomjs binary (?), which uses proxy from the environment http_proxy setting.

Would it be possible to set these automatically? The latter is the one that bugs me the most, as it requires all devs to have a common setting (yet another thing that everyone has to set up before their environment is ready).

Duplicatation of `--no-color` for Grunt sample

The sample pom.xml shows usage of --no-color argument for the grunt task - https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plugin/src/it/example%20project/pom.xml#L48.

I see it is a default argument at
https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/GruntRunner.java#L15
so there is no need to add it explicitly.
I'd suggest to remove it from the sample project pom.xml.

Warnings though the build with frontend-maven-plugin

For every in a project i get something like this

[INFO] --- frontend-maven-plugin:0.0.11:npm (npm install brunch) @ zeppelin-web ---
[INFO] Running 'npm install -g brunch --color=false' in /Users/alex/Documents/_NFLabs/zeppelin/zeppelin-web
[INFO] readlink: illegal option -- f
[INFO] usage: readlink [-n] [file ...]
[INFO] usage: dirname path

not sure how lethal that is as overall build status is success

Plugin doesn't seem to abide maven -quiet flag

mvn -quit test

[info] npm WARN package.json [email protected] No description
[info] npm WARN package.json [email protected] No repository field.
[info] npm WARN package.json [email protected] No README data
[info] npm http GET https://registry.npmjs.org/karma-junit-reporter
[info] npm http 200 https://registry.npmjs.org/karma-junit-reporter
[info] npm http GET https://registry.npmjs.org/karma-junit-reporter/-/karma-junit-reporter-0.1.0.tgz
[info] npm http 200 https://registry.npmjs.org/karma-junit-reporter/-/karma-junit-reporter-0.1.0.tgz
[info] npm http GET https://registry.npmjs.org/xmlbuilder/0.4.2
[info] npm http 200 https://registry.npmjs.org/xmlbuilder/0.4.2
[info] npm http GET https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.4.2.tgz
[info] npm http 200 https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.4.2.tgz
[info] [email protected] node_modules/karma-junit-reporter
[info] └── [email protected]
[info] Running Grunt in /Users/torkvalo/oppdrag/app-main/web

It should not give the info output.

grunt-cli error

I have grunt dependency in my package.json
But every time I try to run grunt tasks with this maven plugin I got error:
Cannot find module '...l\node_modules\grunt-cli\bin\grunt'

Does it mean that grunt-cli should be installed globaly? And maybe you know how to avoid this issue

Gulp support planned for next release?

Hi there,

Not so much an issue, but I noticed the README in master includes a section for gulp support, which we're quite excited about.

Are you planning on including gulp support in the next release? Anything we can do to help get that release out the door?

Thanks,
~Rob

Don't reinstall npm modules with npm goal

I'm new to NodeJs and I'm not sure if 'npm install' already supports this, but it would be nice if the 'npm' goal could tell modules were already installed. Then, just like the 'install-node-and-npm' goal, it could skip downloading modules again if they already exist within the configured working directory.

Getting failure with install-node-and-npm goal

I'm hoping it's something simple. I've gone through the guide a couple of times and I'm not finding what's wrong. I also tried with 0.0.12 for the plugin, and some other pairs of Node/NPM versions from http://nodejs.org/dist. Any ideas?

The error message is:

The parameters 'nodeVersion', 'npmVersion' for goal com.github.eirslett:frontend-maven-plugin:0.0.11:install-node-and-npm are missing or invalid

My pom.xml has this:

        <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>0.0.11</version>
            <!-- optional -->
            <configuration>
                <workingDirectory>src/main/webapp/websrc</workingDirectory>
            </configuration>
            <executions>
                <execution>
                    <id>install node and npm</id>
                    <goals>
                        <goal>install-node-and-npm</goal>
                    </goals>
                    <configuration>
                        <nodeVersion>v0.10.18</nodeVersion>
                        <npmVersion>1.3.8</npmVersion>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Node keeps running when killing maven

When running a Grunt watch task and hitting "Ctrl-C" to stop the process. Node.exe keeps running in the background.

I haven't found a way to kill node.exe other than going manually in the task manager...

We are using a watch task to compile sass files in the background.

Cannot use npm newer than 1.4.12

It seems there is some problem with installing npm 1.4.13 and newer.
I use pretty much the same pom.xml as the linked sample project in the README and
using <npmVersion>1.4.12</npmVersion> works but <npmVersion>1.4.13</npmVersion>. According to npm info npm and http://registry.npmjs.org/npm/ the latest version is 1.4.16.

Is it something related to the fact that npm is distributed with node.js since a while ?
If so then please either update the README and/or do not require npmVersion for newer node.js.

Thanks for this nice plugin!

Not pulling the latest version of NodeJS

@eirslett This is a great plugin, but it seems to be currently trying to download Node v0.10.18 . Is there a properties file or something you're using to configure this value by default that is perhaps not checked into the repo?

Use of global installation of npm and grunt-cli

Hello,

What do you think about the idea to provide a way to use a global installation of node (npm) and grunt-cli ? Maybe an additional conf parameter in the install-node-and-npm goal section, which would bypass the node install.

I think it would be nice in case of CIP environment too : only one installation of node and grunt-cli is required for all the projects. One download+install for each project is a little bit repetitive.

The problem I am facing for now is that I'm unable to use the plugin because it requires download : I'm blocked by the proxy antivirus (my proxy settings are correct, the node.exe file is blocked when I try to download it via Chrome).

Thanks in advance for your response.
Sébastien.

Java 7 incompatibility

Hello,

As I'm compiling with Java 6, I guess the error below tells me that you're using Java 7-compiled artifacts?
Thank you.

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:0.0.6:install-node-and-npm (install node and npm) on project MyProject: Execution install node and npm of goal com.github.eirslett:frontend-maven-plugin:0.0.6:install-node-and-npm failed: An API incompatibility was encountered while executing com.github.eirslett:frontend-maven-plugin:0.0.6:install-node-and-npm: java.lang.UnsupportedClassVersionError: org/rauschig/jarchivelib/ArchiverFactory : Unsupported major.minor version 51.0
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>com.github.eirslett:frontend-maven-plugin:0.0.6
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/jerome/.m2/repository/com/github/eirslett/frontend-maven-plugin/0.0.6/frontend-maven-plugin-0.0.6.jar
[ERROR] urls[1] = file:/C:/Users/jerome/.m2/repository/org/rauschig/jarchivelib/0.3.0/jarchivelib-0.3.0.jar
[ERROR] urls[2] = file:/C:/Users/jerome/.m2/repository/org/apache/commons/commons-compress/1.5/commons-compress-1.5.jar
[ERROR] urls[3] = file:/C:/Users/jerome/.m2/repository/org/tukaani/xz/1.2/xz-1.2.jar
[ERROR] urls[4] = file:/C:/Users/jerome/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.13/jackson-mapper-asl-1.9.13.jar
[ERROR] urls[5] = file:/C:/Users/jerome/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.13/jackson-core-asl-1.9.13.jar
[ERROR] urls[6] = file:/C:/Users/jerome/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.10/plexus-utils-3.0.10.jar
[ERROR] urls[7] = file:/C:/Users/jerome/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.plexus/0.0.0.M2a/org.eclipse.sisu.plexus-0.0.0.M2a.jar
[ERROR] urls[8] = file:/C:/Users/jerome/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
[ERROR] urls[9] = file:/C:/Users/jerome/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
[ERROR] urls[10] = file:/C:/Users/jerome/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar
[ERROR] urls[11] = file:/C:/Users/jerome/.m2/repository/com/google/guava/guava/10.0.1/guava-10.0.1.jar
[ERROR] urls[12] = file:/C:/Users/jerome/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar
[ERROR] urls[13] = file:/C:/Users/jerome/.m2/repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
[ERROR] urls[14] = file:/C:/Users/jerome/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[ERROR] urls[15] = file:/C:/Users/jerome/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.0.0.M2a/org.eclipse.sisu.inject-0.0.0.M2a.jar
[ERROR] urls[16] = file:/C:/Users/jerome/.m2/repository/asm/asm/3.3.1/asm-3.3.1.jar
[ERROR] urls[17] = file:/C:/Users/jerome/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[18] = file:/C:/Users/jerome/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]

Make 'install-node-and-npm' goal optional

It would be really nice to not install node or npm at all, as both are pre-installed on all of our development machines and build agents (as well as on the PATH). Whenever I attempt to simply run and 'npm install' followed by 'gulp build' or 'grunt build' without the 'install-node-and-npm' goal, I get a path not specified error. I understand this is because it is looking to run node from {workingDirectory}/node, but it would simply make just as much sense to remove such a dependency in the case where node versions were managed outside of this plugin. This is a different request than optionally specifying the node directory as I would never perform a clean of said directory.

Spaces in working directory cause issues

If you have spaces in the working directory of your project, IE:

C:\Application Development\foo\bar\project

Node.js will fail to detect that it has already been installed and will always download and install. Also, npm install will fail with the following message:

[INFO] Running 'npm install --color=false' in C:\Application Development\foo\bar\project
[INFO] The filename, directory name, or volume label syntax is incorrect.

nodejs.org returns 403 status code when installing Node

Hi there,
I'm new to this plug-in. When I attempt to run a build, the plug-in is receiving a 403 status code attempting to download the .tar.gz file for my specified Node version from nodejs.org directly, no proxy involved.

I can access this same file directly in my browser, so I wondered if there is something about the Maven process itself that is failing - e.g. that nodejs.org is receiving a request that it thinks is malicious and rejecting it.

A great workaround for this would be to allow me to have the tar in my codebase instead of downloading it every time, or better still, having the plug-in use the system-wide install of Node on my machine.

Thanks!

it halt when no internet is present

Hi!

When I run the maven task and have no internet, the execution halt at karma runner until I reconnect the internet.

I tried to run the karma task in grunt, without internet, and I had no problem.

with_new_path.sh don't work with Solaris10

I'm getting the following error message when trying to run this plugin on Solaris 10:

/data/path/node/with_new_path.sh: PATH=$(dirname $(readlink -f /data/path/node/with_new_path.sh)):/usr/sbin:/usr/bin: is not an identifier
'npm install --color=false' failed. (error code 1)

I have no clue how to fix this since I'm not a Java developer by trade. But as far as i could tell this is due to a Solaris10 legacy issue.

Feature request: testFailureIgnore

First of all, I think, that frontend-maven-plugin is the best plugin so far to run karma tests. It's clean and does not force non-forntend developers to install node.js. Great approach. Contragulations.

I think, that the plugin would benefit from a feature 'testFailureIgnore' known from maven-surefie-plugin, which makes it possible to have a maven profile which runs all tests, but doesn't stop at first failure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.