eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.21k stars 867 forks source link

Can't add arguments when running the npm goal from the command line #1035

Open erex1 opened 2 years ago

erex1 commented 2 years ago

I am running the latest version of the plugin (1.12.1) on my windows machine (Windows 10 Pro 21H2).

I have this execution that is working perfectly when i run it from the pom.xml:

...
<execution>
    <id>npm version</id>
    <goals>
        <goal>npm</goal>
    </goals>
    <configuration>
        <workingDirectory>frontend</workingDirectory>
        <installDirectory>./</installDirectory>
        <arguments>version ${project.version}</arguments>
    </configuration>
</execution>
...

But when I try to run the same thing directly from the command line I can't get it to work. The issue seems to be that everything else then the configuration.arguments is set correctly (i.e configuration.workingDirectory and configuration.installDirectory is set correctly). This causes the plugin to always run the "npm install", since "install" is the default value for arguments.

Here is the command I am trying to run from the command line: mvn frontend:npm -Darguments="version 1.2.3" -DworkingDirectory=frontend -DinstallDirectory=./ (I have tried several variations of the "-Darguments=" value in case the issue is with spaces and/or the double quotes, where I just try to run anything else than the npm install command, but I cant get it to work)

Am I missing something here, or is this a bug?

The reason I want to run in from the command line is because i want to run it as a command in completionGoals with the maven-release-plugin (https://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#completionGoals)

cboehme commented 2 years ago

I think, your problem might be that the property to pass arguments to npm is not arguments but frontend.npm.arguments (see here).