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.2k stars 867 forks source link

install-node-and-npm - Use local binary archive #1107

Open venkateshkolisetty-ctl opened 9 months ago

venkateshkolisetty-ctl commented 9 months ago

Do you want to request a feature or report a bug?

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce.

Using <goal>install-node-and-npm</goal> and <nodeVersion>. This is downloading from https://nodejs.org/dist

What is the expected behavior?

Take the binary file from repository. Choose from a local file that will be available in the repository.

I have archives inside repository as

node-binary
    /v18.16.0
        /node-v18.16.0.tar.gz
        /node-v18.16.0-win-x64.zip

To make the plugin use local files instead of fetching from internet, I tried below configuration

<execution>
  <id>install-node-and-npm</id>
  <goals>
    <goal>install-node-and-npm</goal>
  </goals>
  <configuration>
    <nodeVersion>v18.16.0</nodeVersion>
    <nodeDownloadRoot>${project.baseUri}/node-binary/</nodeDownloadRoot>
  </configuration>
</execution>

This seems to be working in Windows

[INFO] --- frontend:1.14.0:install-node-and-npm (install-node-and-npm) @ emo-tools-frontend ---
[INFO] Installing node version v18.16.0
[INFO] Downloading file:///C:/Users/*******/repo/CATALOG/BMCM-emo-tools/emo-tools-frontend//node-binary/v18.16.0/node-v18.16.0-win-x64.zip to C:\Users\*******\.m2\repository\com\github\eirslett\node\18.16.0\node-18.16.0-win-x64.zip
[INFO] Unpacking C:\Users\*******\.m2\repository\com\github\eirslett\node\18.16.0\node-18.16.0-win-x64.zip into C:\Users\*******\repo\CATALOG\BMCM-emo-tools\emo-tools-frontend\node\tmp
[INFO] Copying node binary from C:\Users\*******\repo\CATALOG\BMCM-emo-tools\emo-tools-frontend\node\tmp\node-v18.16.0-win-x64\node.exe to C:\Users\*******\repo\CATALOG\BMCM-emo-tools\emo-tools-frontend\node\node.exe
[INFO] Installed node locally.
[INFO] 
[INFO] --- frontend:1.14.0:npm (npm-run-install) @ emo-tools-frontend ---
[INFO] Running 'npm install' in C:\Users\*******\repo\CATALOG\BMCM-emo-tools\emo-tools-frontend

But build is failing in Jenkins

[INFO] --- frontend:1.14.0:install-node-and-npm (install-node-and-npm) @ emo-tools-frontend ---
[INFO] Installing node version v18.16.0
[INFO] Downloading file:///app/jenkins/workspace/_tools_BMCM-emo-tools_PR-26-head/emo-tools-frontend//node-binary/v18.16.0/node-v18.16.0-linux-x64.tar.gz to /home/jenkins/.m2/repository/com/github/eirslett/node/18.16.0/node-18.16.0-linux-x64.tar.gz
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.14.0:install-node-and-npm (install-node-and-npm) on project emo-tools-frontend: Could not download Node.js: Could not download [file:////node-binary/v18.16.0/node-v18.16.0-linux-x64.tar.gz](file://node-binary/v18.16.0/node-v18.16.0-linux-x64.tar.gz): File system element for parameter 'source' does not exist: '/node-binary/v18.16.0/node-v18.16.0-linux-x64.tar.gz' -> [Help 1]

Please mention your frontend-maven-plugin and operating system version. Windows 11 x64

tmclane commented 5 months ago

FYI:

If you rename your files as follows it will find them:

node-v18.16.0.tar.gz => node-18.16.0-linux-x64.tar.gz