Skip to content

Commit c08321d

Browse files
author
Quang Minh Tran
authored
GH-1288: As a smith I want to fix the Eclipse nightly build (missing yarn) (#1289)
GH-1288: As a smith I want to fix the Eclipse nightly build (missing yarn) (#1289)
1 parent f715912 commit c08321d

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

docker-build/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" && \
9898
#
9999
# Yarn install
100100
#
101-
ENV YARN_VERSION 1.13.0
101+
ENV YARN_VERSION 1.15.2
102102

103103
RUN set -ex && \
104104
for key in \

eclipse-nightly.jenkinsfile

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pipeline {
2424

2525
environment {
2626
NODEJS_PATH= '/shared/common/node-v10.15.3-linux-x64/bin'
27+
YARN_PATH = '/shared/common/yarn/1.15.2/bin'
2728
PATH = "${PATH}" +
2829
":/shared/common/apache-ant-1.9.6/bin" +
2930
":/shared/common/maven/apache-maven-3.5.2/bin/" +

plugins/org.eclipse.n4js/src/org/eclipse/n4js/binaries/BinariesConstants.java

+27
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public final class BinariesConstants {
5252
*/
5353
public static final String DEFAULT_NODE_PATH_VM_ARG = "org.eclipse.n4js.defaultNodePath";
5454

55+
/**
56+
* Default yarn path, similar to {@code DEFAULT_NODE_PATH_VM_ARG}
57+
*/
58+
public static final String DEFAULT_YARN_PATH_VM_ARG = "org.eclipse.n4js.defaultYarnPath";
59+
5560
/**
5661
* Jenkins environment variable for the {@code Node.js} binary path. Points to the actual binary (with an absolute
5762
* path) instead of pointing to the folder containing the binary.
@@ -62,6 +67,16 @@ public final class BinariesConstants {
6267
*/
6368
public static final String NODEJS_PATH_ENV = "NODEJS_PATH";
6469

70+
/**
71+
* Jenkins environment variable for the {@code yarn} binary path. Points to the actual binary (with an absolute
72+
* path) instead of pointing to the folder containing the binary.
73+
*
74+
* <p>
75+
* Even if it is available the {@link #DEFAULT_YARN_PATH_VM_ARG <code>org.eclipse.n4js.defaultYarnPath</code>} VM
76+
* argument might override this configuration.
77+
*/
78+
public static final String YARN_PATH_ENV = "YARN_PATH";
79+
6580
/**
6681
* The (fallback) built-in default {@code Node.js} path if the above VM or ENV property is not specified.
6782
*
@@ -74,6 +89,18 @@ public final class BinariesConstants {
7489
? new File("C:" + separator + "Program Files" + separator + "nodejs").getAbsolutePath()
7590
: new File(separator + "usr" + File.separator + "local" + separator + "bin").getAbsolutePath();
7691

92+
/**
93+
* The (fallback) built-in default {@code yarn} path if the above VM or ENV property is not specified.
94+
*
95+
* <ul>
96+
* <li>On Windows systems: {@code C:\Program Files\yarn}</li>
97+
* <li>On Unix systems: {@code /usr/local/bin}</li>
98+
* </ul>
99+
*/
100+
public static final String BUILT_IN_DEFAULT_YARN_PATH = isWindows()
101+
? new File("C:" + separator + "Program Files" + separator + "yarn").getAbsolutePath()
102+
: new File(separator + "usr" + File.separator + "local" + separator + "bin").getAbsolutePath();
103+
77104
/** The minimum {@code Node.js} version. */
78105
public static final VersionNumber NODE_MIN_VERSION = SemverUtils.createVersionNumber(10, 13, 0);
79106
/** The label for {@code Node.js}. */

plugins/org.eclipse.n4js/src/org/eclipse/n4js/binaries/BinariesLocatorHelper.java

+28-5
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,30 @@ public Path findNodePath() {
113113
* @return string with absolute path to the binary
114114
*/
115115
public Path findYarnPath() {
116+
Path yarnPathCandidate = null;
116117

117-
Path yarnPathCandidate;
118+
// 1. lookup by DEFAULT_YARN_PATH_VM_ARG
119+
yarnPathCandidate = resolveFolderContaingBinary(
120+
tryGetEnvOrSystemVariable(BinariesConstants.DEFAULT_YARN_PATH_VM_ARG));
121+
if (yarnPathCandidate != null) {
122+
info("User specified default Yarn path will be used: '" + yarnPathCandidate
123+
+ ".' based on the '" + BinariesConstants.DEFAULT_YARN_PATH_VM_ARG + "' VM argument.");
124+
return yarnPathCandidate;
125+
}
126+
debug("Could not resolve node path from '" + BinariesConstants.DEFAULT_NODE_PATH_VM_ARG
127+
+ "' VM argument.");
118128

119-
// 1. lookup by PATH
129+
// 2. lookup by YARN_PATH_ENV
130+
yarnPathCandidate = resolveFolderContaingBinary(
131+
tryGetEnvOrSystemVariable(BinariesConstants.YARN_PATH_ENV));
132+
if (yarnPathCandidate != null) {
133+
info("User specified default yarn path will be used: '" + yarnPathCandidate
134+
+ ".' based on the '" + BinariesConstants.YARN_PATH_ENV + "' environment argument.");
135+
return yarnPathCandidate;
136+
}
137+
debug("Could not resolve yarn path from '" + BinariesConstants.YARN_PATH_ENV);
138+
139+
// 3. lookup by PATH
120140
yarnPathCandidate = resolveFolderContaingBinary(
121141
ExecutableLookupUtil.findInPath(BinariesConstants.YARN_BINARY_NAME));
122142
if (yarnPathCandidate != null) {
@@ -126,7 +146,7 @@ public Path findYarnPath() {
126146
}
127147
debug("Could not resolve yarn path from OS PATH variable.");
128148

129-
// 2. lookup by OS query
149+
// 4. lookup by OS query
130150
yarnPathCandidate = resolveFolderContaingBinary(
131151
lookForBinary(BinariesConstants.YARN_BINARY_NAME));
132152
if (yarnPathCandidate != null) {
@@ -137,8 +157,11 @@ public Path findYarnPath() {
137157
}
138158
debug("Could not resolve yarn path from OS dynamic lookup.");
139159

140-
debug("Falling back to node path ...");
141-
return findNodePath();
160+
// 5. use default, whether it is correct or not.
161+
info("Could not resolve yarn path. Falling back to default path: " + yarnPathCandidate);
162+
yarnPathCandidate = new File(BinariesConstants.BUILT_IN_DEFAULT_YARN_PATH).toPath();
163+
164+
return yarnPathCandidate;
142165
}
143166

144167
private String lookForBinary(String binaryName) {

0 commit comments

Comments
 (0)