Skip to content

Commit

Permalink
Revert "LPS-91967 Use liferay-binaries-cache-2017 to cache Yarn packa…
Browse files Browse the repository at this point in the history
…ges"

This reverts commit a35f675.
  • Loading branch information
petershin committed Apr 30, 2019
1 parent adf01d3 commit a1f1517
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
1 change: 0 additions & 1 deletion build-common.xml
Expand Up @@ -1907,7 +1907,6 @@ rerun your task.
<propertyref name="aspectj.configuration" />
<propertyref name="baseline.jar.report.level" />
<propertyref name="baseline.jar.report.only.dirty.packages" />
<propertyref name="build.binaries.cache.dir" />
<propertyref name="git.working.branch.name" />
<propertyref name="jacoco.agent.configuration" />
<propertyref name="jacoco.agent.jar" />
Expand Down
38 changes: 22 additions & 16 deletions modules/util.gradle
Expand Up @@ -38,6 +38,8 @@ task wrapper(type: Wrapper)
task wrapperSubrepo(type: Wrapper)

FileTree libDependenciesFileTree = fileTree(dir: "../lib", include: "*/dependencies.properties")
File nodeModulesCacheDir = new File(rootDir, "node_modules_cache")
File userNodeModulesCacheDir = new File(System.getProperty("user.home"), ".liferay/node-modules-cache/" + Integer.toHexString(rootDir.canonicalPath.hashCode()))

Map<File, Properties> libDependenciesMap = libDependenciesFileTree.collectEntries {
Properties properties = GUtil.loadProperties(it)
Expand Down Expand Up @@ -91,37 +93,41 @@ repositories {
}

setUpYarn {
File userNodeModulesCacheYarnLockFile = new File(userNodeModulesCacheDir, "yarn.lock")
File yarnLockFile = new File(rootDir, "yarn.lock")

args "install"
args "--frozen-lockfile"

scriptFile = new File(projectDir, "yarn-1.13.0.js")

doFirst {
String cacheDir = project.findProperty("build.binaries.cache.dir")

if (cacheDir) {
File yarnCacheDir = new File(rootDir.parentFile, cacheDir + "/.yarn")
String registry = project.findProperty("nodejs.npm.ci.registry")

if (yarnCacheDir.parentFile.exists()) {
logger.lifecycle "Using cache {}", yarnCacheDir
if (yarnLockFile.exists() && registry) {
logger.lifecycle "Using registry {}", registry

args "--cache-folder"
args yarnCacheDir
}
yarnLockFile.text = yarnLockFile.text.replaceAll("https://registry.yarnpkg.com", registry)
}

String registry = project.findProperty("nodejs.npm.ci.registry")
if (userNodeModulesCacheYarnLockFile.exists() && yarnLockFile.exists() && (userNodeModulesCacheYarnLockFile.text == yarnLockFile.text)) {
logger.lifecycle "Restoring node_modules_cache from {}", userNodeModulesCacheDir

if (registry) {
File yarnLockFile = new File(rootDir, "yarn.lock")
FileUtil.syncDir(project, userNodeModulesCacheDir, nodeModulesCacheDir, true)

if (yarnLockFile.exists()) {
logger.lifecycle "Using registry {}", registry
logger.lifecycle "Running Yarn install in offline mode"

yarnLockFile.text = yarnLockFile.text.replaceAll("https://registry.yarnpkg.com", registry)
}
args "--offline"
}
}

doLast {
logger.lifecycle "Caching node_modules_cache in {}", userNodeModulesCacheDir

FileUtil.syncDir(project, nodeModulesCacheDir, userNodeModulesCacheDir, true)

userNodeModulesCacheYarnLockFile.text = yarnLockFile.text
}
}

wrapper {
Expand Down

0 comments on commit a1f1517

Please sign in to comment.