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.22k stars 868 forks source link

fix 'Access Denied' issue with error 1 on windows('<cwd>\target\node\yarn\dist\bin\yarn.cmd install') #995

Closed cloorc closed 3 years ago

cloorc commented 3 years ago

…yarn\dist\bin\yarn.cmd install')

[INFO] --- frontend-maven-plugin:1.12.0:yarn (yarn install) @ ui-ngx ---
[DEBUG] Configuring mojo com.github.eirslett:frontend-maven-plugin:1.12.0:yarn from plugin realm ClassRealm[plugin>com.github.eirslett:frontend-maven-plugin:1.12.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@6d5380c2]
[DEBUG] Configuring mojo 'com.github.eirslett:frontend-maven-plugin:1.12.0:yarn' with basic configurator -->
[DEBUG]   (f) arguments = install
[DEBUG]   (f) installDirectory = C:\Users\yi\data\src\osc\thingsboard\thingsboard\ui-ngx\target
[DEBUG]   (f) project = MavenProject: org.thingsboard:ui-ngx:3.3.0-SNAPSHOT @ C:\Users\yi\data\src\osc\thingsboard\thingsboard\ui-ngx\pom.xml
[DEBUG]   (f) repositorySystemSession = org.eclipse.aether.DefaultRepositorySystemSession@5a00eb1e
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@36fcf6c0
[DEBUG]   (f) skipTests = false
[DEBUG]   (f) testFailureIgnore = false
[DEBUG]   (f) workingDirectory = C:\Users\yi\data\src\osc\thingsboard\thingsboard\ui-ngx
[DEBUG]   (f) yarnInheritsProxyConfigFromMaven = true
[DEBUG]   (f) execution = com.github.eirslett:frontend-maven-plugin:1.12.0:yarn {execution: yarn install}
[DEBUG] -- end configuration --
[INFO] Running 'yarn install' in C:\Users\yi\data\src\osc\thingsboard\thingsboard\ui-ngx
[DEBUG] Executing command line [C:\Users\yi\data\src\osc\thingsboard\thingsboard\ui-ngx\target\node\yarn\dist\bin\yarn.cmd, install]
[INFO] Access is denied.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:11 min
[INFO] Finished at: 2021-08-12T17:53:45+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:yarn (yarn install) on project ui-ngx: Failed to run task: 'yarn install' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:yarn (yarn install) on project ui-ngx: Failed to run task

With screenshot as following:

screenshot-20210812-175339

NOTE: we are using 1.12.0 of frontend-maven-plugin but encountered this error on my Win10 laptop.

Device name yi-station
Processor   11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz   2.30 GHz
Installed RAM   16.0 GB (15.7 GB usable)
Device ID   D9363FE1-52E5-4D23-833B-042B354FC7D7
Product ID  00331-20020-00000-AA564
System type 64-bit operating system, x64-based processor
Pen and touch   No pen or touch input is available for this display

Summary

Instead of using yarn.cmd as the executable for Runtime.getRuntime().exec, we can just using yarn.js directly with executable node.

Tests and Documentation

screenshot-20210812-180113

cloorc commented 3 years ago

NOTE: partial downloaded node.exe result in this failure. And the node.exe located at .m2\repository\com\github\eirslett\node\. Please make sure the executables are downloaded successfully.