Issue
-
Customers may encounter failures using Gradle v.4 + Workspace. Here is the relevant stacktrace exception:
> Task :downloadNode FAILED
Trying to download http://mirrors.lax.liferay.com/nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz to /home/jenkins/.liferay/mirrors/nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz.tmp
Trying to download http://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz to /home/jenkins/.liferay/mirrors/nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz.tmp
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':downloadNode'.
> Redirection detected from http to https. Protocol switch unsafe, not allowed.
Environment
- Gradle v.4 + Workspace
- Liferay DXP 7.0+
Resolution
- Apply the following in
build.gradleas a workaround:
import com.liferay.gradle.util.OSDetector buildscript { dependencies { classpath group: "com.liferay", name: "com.liferay.gradle.util", version: "1.0.34" } repositories { mavenCentral() } } allprojects { plugins.withId("com.liferay.node") { def nodeArch def nodeExt def nodeOS if (OSDetector.getBitmode().equals("32")) nodeArch = "x86" else nodeArch = "x64" if (OSDetector.isWindows()) nodeExt = "zip" else nodeExt = "tar.gz" if (OSDetector.isApple()) nodeOS = "darwin"; else if (OSDetector.isWindows()) nodeOS = "win"; else nodeOS = "linux" node { nodeUrl = "https://nodejs.org/dist/v${nodeVersion}/node-v${nodeVersion}-${nodeOS}-${nodeArch}.${nodeExt}" } } }
Additional Information
-
There has been a change to how downloads from nodejs.com switch from http -> https. The fix is already in place for Gradle v.5 + latest Workspace plugin versions. However, those customers using Gradle v.4 + Liferay Workspace plugin version 2.1.5 or lower will need to use the aforementioned
build.gradleworkaroundThe workaround fixes the issue by overriding thenodeURLproperty which is normally automatically calculated by our node plugin.