Commit aa5270e7 authored by Dmitriy.Panov's avatar Dmitriy.Panov
Browse files

JBR-1295: JBR layout with top level directories (jbr, jbrsdk) support

parent 9060dc1c
Showing with 67 additions and 42 deletions
+67 -42
......@@ -63,18 +63,23 @@ def createJbreTasks(String defaultBuild, int version, String targetOs, String pr
}
}
@SuppressWarnings("GrMethodMayBeStatic")
def jreUrl() {
// base url of TeamCity build to download JRE from
System.getProperty('intellij.jre.teamcity.build.url') ?: 'https://cache-redirector.jetbrains.com/intellij-jbr'
}
def createDownloadJbreTask(String artifactName, String build, boolean doRepackage) {
def outputDir = "$project.buildDir/jbre"
def suffix = doRepackage ? '_origin' : ''
def outputFile = "$outputDir/${artifactName}${suffix}.tar.gz"
task("download${artifactName.capitalize()}") {
def jdkRepo = 'https://cache-redirector.jetbrains.com/intellij-jbr'
inputs.property('build', build)
outputs.file(outputFile)
doLast {
logger.info("Downloading $artifactName to $outputFile")
download {
src "$jdkRepo/${artifactName}.tar.gz"
src "${jreUrl()}/${artifactName}.tar.gz"
dest outputFile
tempAndMove true
timeout TimeUnit.MINUTES.toMillis(30).toInteger()
......
import org.gradle.internal.os.OperatingSystem
import java.nio.file.Files
import java.nio.file.Paths
import java.util.concurrent.TimeUnit
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
......@@ -96,9 +98,25 @@ def unpackJdk(jdkArchive, outputDir) {
else {
exec { commandLine 'mkdir', '-p', outputDir }
exec { commandLine 'tar', 'xpf', "$jdkArchive.absolutePath", '--directory', outputDir }
if (currentOs.isMacOsX() && file("${outputDir}/jdk/Contents").exists()) {
exec { commandLine 'mv', "${outputDir}/jdk/Contents", outputDir }
exec { commandLine 'rm', '-rf', "${outputDir}/jdk" }
}
def rootDirs = ['jbrsdk', 'jbr', 'jdk']
if (file(outputDir).list()?.any { rootDirs.contains(it) }) {
// unpack top level jbrsdk/jbr/jdk directory
file(outputDir).listFiles().findAll { rootDirs.contains(it.name) }.each { rootDir ->
rootDir.listFiles().each { File file ->
if (currentOs.isWindows()) {
Files.move(Paths.get(file.absolutePath), Paths.get(outputDir).resolve(file.name))
}
else {
exec { commandLine 'mv', file, outputDir }
}
}
if (currentOs.isWindows()) {
rootDir.deleteDir()
}
else {
exec { commandLine 'rm', '-rf', rootDir }
}
}
}
}
......
......@@ -128,6 +128,11 @@ class BuildOptions {
*/
String bundledJreBuild = System.getProperty("intellij.build.bundled.jre.build")
/**
* If {@code true} then JRE top directory was renamed to JBR, see JBR-1295
*/
boolean bundledJreRenamedToJbr = Boolean.parseBoolean(System.getProperty('intellij.build.bundled.jreRenamedToJbr'))
/**
* Directory path to unpack Jetbrains JDK builds into
*/
......
......@@ -52,7 +52,6 @@ class BundledJreManager {
return version
}
@CompileDynamic
String extractSecondJre(String osName, String secondJreBuild) {
String targetDir = "$baseDirectoryForJre/secondJre.${osName}_${JvmArchitecture.x64}"
if (new File(targetDir).exists()) {
......@@ -73,20 +72,7 @@ class BundledJreManager {
String destination = "$targetDir/jre64"
def destinationDir = new File(destination)
if (destinationDir.exists()) destinationDir.deleteDir()
if (SystemInfo.isWindows) {
buildContext.ant.untar(src: archive.absolutePath, dest: destination, compression: 'gzip')
}
else {
//'tar' command is used instead of Ant task to ensure that executable flags will be preserved
buildContext.ant.mkdir(dir: destination)
buildContext.ant.exec(executable: "tar", dir: archive.parent) {
arg(value: "-xf")
arg(value: archive.name)
arg(value: "--directory")
arg(value: destination)
}
}
untar(archive, destination)
}
return targetDir
}
......@@ -125,8 +111,6 @@ class BundledJreManager {
return "jre-for-${buildContext.buildNumber}.tar.gz"
}
@CompileDynamic
private String extractJre(String osName, JvmArchitecture arch = JvmArchitecture.x64, JreVendor vendor = JreVendor.JetBrains) {
String vendorSuffix = vendor == JreVendor.Oracle ? ".oracle" : ""
String targetDir = arch == JvmArchitecture.x64 ?
......@@ -147,29 +131,41 @@ class BundledJreManager {
destination = "$targetDir/jre32"
}
buildContext.messages.progress("Extracting JRE from '$archive.name' archive")
if (SystemInfo.isWindows) {
buildContext.ant.untar(src: archive.absolutePath, dest: destination, compression: 'gzip') {
if (!buildContext.isBundledJreModular()) {
cutdirsmapper(dirs: 1)
}
untar(archive, destination)
}
return targetDir
}
/**
* @param archive linux or windows JRE archive
*/
@CompileDynamic
private def untar(File archive, String destination) {
// jbr8 with `jre` top level directory
def unpackTopLevelDir = !buildContext.isBundledJreModular() ||
// or jbr11+ with `jbr` top level directory
buildContext.options.bundledJreRenamedToJbr
if (SystemInfo.isWindows) {
buildContext.ant.untar(src: archive.absolutePath, dest: destination, compression: 'gzip') {
if (unpackTopLevelDir) {
cutdirsmapper(dirs: 1)
}
}
else {
//'tar' command is used instead of Ant task to ensure that executable flags will be preserved
buildContext.ant.mkdir(dir: destination)
buildContext.ant.exec(executable: "tar", dir: archive.parent) {
arg(value: "-xf")
arg(value: archive.name)
if (!buildContext.isBundledJreModular()) {
arg(value: "--strip")
arg(value: "1")
}
arg(value: "--directory")
arg(value: destination)
}
else {
// 'tar' command is used instead of Ant task to ensure that executable flags will be preserved
buildContext.ant.mkdir(dir: destination)
buildContext.ant.exec(executable: "tar", dir: archive.parent) {
arg(value: "-xf")
arg(value: archive.name)
if (unpackTopLevelDir) {
arg(value: "--strip")
arg(value: "1")
}
arg(value: "--directory")
arg(value: destination)
}
}
return targetDir
}
private File dependenciesDir() {
......
......@@ -104,13 +104,14 @@ class MacDmgBuilder {
def zipRoot = MacDistributionBuilder.getZipRoot(buildContext, customizer)
String suffix = "-no-jdk", javaExePath = null
def topLevelDir = buildContext.options.bundledJreRenamedToJbr ? 'jbr' : 'jdk'
if (secondJreArchive != null) {
suffix = "-jbr${buildContext.bundledJreManager.getSecondJreVersion()}"
javaExePath = "../jdk/Contents/Home/bin/java"
javaExePath = "../${topLevelDir}/Contents/Home/bin/java"
}
else if (jreArchivePath != null) {
suffix = buildContext.bundledJreManager.jreSuffix()
javaExePath = "../jdk/Contents/Home/${buildContext.isBundledJreModular() ? '' : 'jre/'}bin/java"
javaExePath = "../${topLevelDir}/Contents/Home/${buildContext.isBundledJreModular() ? '' : 'jre/'}bin/java"
}
def productJsonDir = new File(buildContext.paths.temp, "mac.dist.product-info.json.dmg$suffix").absolutePath
MacDistributionBuilder.generateProductJson(buildContext, productJsonDir, javaExePath)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment