Closed eyp closed 2 months ago
I don't think this is purely and issue of the frontend plugin, but the way of how Maven works. A Maven build always consists of several phases (clean, compile, test-compile, test ..). Plugins may hook into those phases with several goals, like the compiler plugin attaching its compile goal to the compile phase and the testCompile goal to the test-compile phase.
Regarding the frontend plugin install-node-and-npm and npm are goals, that are bound to the generate-resources phase be default. So if you would call mvn generate-resources those goals would be executed. Adding an execution configuration could be used to bind these goals to another phase. Or offer additional configuration / execution steps for a certain goal.
By using or adding an execution step, you may rebind a goal to another phase. So instead of running the goal install-node-and-npm you could make it to be executed within the clean phase of maven. What the execution configuration do not do is overriding the configurations of a goal when calling it directly.
Calling mvn frontend:install-node-and-npm will indeed invoke this exact goal offered by the plugin. But Maven will not lookup the configuration within the exeuction elements but the default plugin configuration. So having a basic configuration like this would work:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.15.0</version>
<configuration>
<nodeVersion>v17.9.1</nodeVersion>
</configuration>
</plugin>
Changing the configuration of the plugin to this one:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.15.0</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v17.9.1</nodeVersion>
</configuration>
</execution>
</executions>
</plugin>
will cause mvn frontend:install-node-and-npm to fail as the required nodeVersion is not configured for the direct invocation of the goal. If you would call it like mvn frontend:install-node-and-npm -DnodeVersion=v17.9.1 it would work again. Also calling mvn generate-resources would work, as the execution step would tell Maven "hey, if we are at the install-node-and-npm goal, consider this configuration".
But what also would work, would be calling the install-node-and-npm with an explicit identifier (that's what the
Yes, I didn't mean it was an issue of the plugin (that's why I tagged it as a question). Thanks for the reply, it's useful.
I'm trying just to run the
install-node-and-npm
goal. Following the example project, if I configure the plugin like this:I get this error:
To avoid the issue and install the specified NodeJs version I need to move the
configuration
section outside theexecution
:Also, I have a related problem with the other kind of goals like
npm
. It always does the defaultinstall
command instead of reading the configuration I specified: