executing Toolbox Lite-Gen on JBR11

GitOrigin-RevId: 6a1ded65ec65961ddde5e117d9e2fc16cf78fff2
This commit is contained in:
Dmitriy.Panov
2019-07-16 02:05:54 +03:00
committed by intellij-monorepo-bot
parent 5fea4b0fc0
commit 9f786611dc
5 changed files with 47 additions and 13 deletions
@@ -10,7 +10,7 @@ class ExternalPluginBundler {
String targetDirectory,
String buildTaskName = pluginName) {
def dependenciesProjectDir = new File(dependenciesPath)
new GradleRunner(dependenciesProjectDir, buildContext.messages, SystemProperties.getJavaHome()).run(
new GradleRunner(dependenciesProjectDir, buildContext.paths.projectHome, buildContext.messages, SystemProperties.getJavaHome()).run(
"Downloading $pluginName plugin...", "setup${buildTaskName}Plugin")
Properties properties = new Properties()
new File(dependenciesProjectDir, "gradle.properties").withInputStream {
@@ -141,7 +141,8 @@ class BuildOptions {
/**
* Specifies Jetbrains JDK version to be used by build scripts, 8 by default.
*/
int jdkVersion = System.getProperty("intellij.build.jdk.version", "8").toInteger()
static final String JDK_VERSION_OPTION = "intellij.build.jdk.version"
int jdkVersion = System.getProperty(JDK_VERSION_OPTION, "8").toInteger()
/**
* Specifies an algorithm to build distribution checksums.
@@ -16,30 +16,47 @@
package org.jetbrains.intellij.build
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import groovy.transform.CompileStatic
import org.jetbrains.jps.model.java.JdkVersionDetector
@CompileStatic
class GradleRunner {
private final File projectDir
private final File gradleProjectDir
private final String projectDir
private final BuildMessages messages
private final String javaHome
@Lazy
private volatile GradleRunner modularGradleRunner = {
createModularRunner()
}()
GradleRunner(File projectDir, BuildMessages messages, String javaHome) {
GradleRunner(File gradleProjectDir, String projectDir, BuildMessages messages, String javaHome) {
this.messages = messages
this.projectDir = projectDir
this.gradleProjectDir = gradleProjectDir
this.javaHome = javaHome
}
/**
* Invokes Gradle tasks on {@link #projectDir} project.
* Invokes Gradle tasks on {@link #gradleProjectDir} project.
* Logs error and stops the build process if Gradle process is failed.
*/
boolean run(String title, String... tasks) {
return runInner(title, false, tasks)
}
/**
* Invokes Gradle tasks on {@link #projectDir} project.
*
* @see GradleRunner#run(java.lang.String, java.lang.String [ ])
*/
boolean runWithModularRuntime(String title, String... tasks) {
if (isModularRuntime()) return run(title, tasks)
return modularGradleRunner.run(title, tasks)
}
/**
* Invokes Gradle tasks on {@link #gradleProjectDir} project.
* Ignores the result of running Gradle.
*/
boolean forceRun(String title, String... tasks) {
@@ -67,24 +84,40 @@ class GradleRunner {
private boolean runInner(String... tasks) {
def gradleScript = SystemInfo.isWindows ? 'gradlew.bat' : 'gradlew'
List<String> command = new ArrayList()
command.add("${projectDir.absolutePath}/$gradleScript".toString())
command.add("${gradleProjectDir.absolutePath}/$gradleScript".toString())
command.add("-Djava.io.tmpdir=${System.getProperty('java.io.tmpdir')}".toString())
command.addAll(tasks)
command.add('--stacktrace')
if (System.getProperty("intellij.build.use.gradle.daemon", "false").toBoolean()) {
command.add('--daemon')
} else {
}
else {
command.add('--no-daemon')
}
def additionalParams = System.getProperty('intellij.gradle.jdk.build.parameters')
if (additionalParams != null && !additionalParams.isEmpty()) {
command.addAll(additionalParams.split(" "))
}
def processBuilder = new ProcessBuilder(command).directory(projectDir)
command.addAll(tasks)
def processBuilder = new ProcessBuilder(command).directory(gradleProjectDir)
processBuilder.environment().put("JAVA_HOME", javaHome)
def process = processBuilder.start()
process.consumeProcessOutputStream((OutputStream)System.out)
process.consumeProcessErrorStream((OutputStream)System.err)
return process.waitFor() == 0
}
private boolean isModularRuntime() {
return JdkVersionDetector.instance
.detectJdkVersionInfo(javaHome)
.@version.feature >= 11
}
private GradleRunner createModularRunner() {
if (isModularRuntime()) return this
run('Downloading JBR 11', 'setupJdks', "-D$BuildOptions.JDK_VERSION_OPTION=11")
def modularRuntime = "$projectDir/build/jdk/11"
if (SystemInfo.isMac) modularRuntime += '/Contents/Home'
modularRuntime = FileUtil.toSystemIndependentName(new File(modularRuntime).canonicalPath)
return new GradleRunner(gradleProjectDir, projectDir, messages, modularRuntime)
}
}
@@ -392,7 +392,7 @@ idea.fatal.error.notification=disabled
"-Pintellij.build.output=${buildContext.paths.buildOutputRoot}/toolbox-lite-gen",
]
buildContext.gradle.run('Run Toolbox LiteGen', liteGenArgs)
buildContext.gradle.runWithModularRuntime('Run Toolbox LiteGen', liteGenArgs)
}
}
}
@@ -65,7 +65,7 @@ class CompilationContextImpl implements CompilationContext {
def dependenciesProjectDir = new File(communityHome, 'build/dependencies')
logFreeDiskSpace(messages, projectHome, "before downloading dependencies")
def gradleJdk = toCanonicalPath(JdkUtils.computeJdkHome(messages, "jdk8Home", null, "JDK_18_x64"))
GradleRunner gradle = new GradleRunner(dependenciesProjectDir, messages, gradleJdk)
GradleRunner gradle = new GradleRunner(dependenciesProjectDir, projectHome, messages, gradleJdk)
if (!options.isInDevelopmentMode) {
setupCompilationDependencies(gradle, options)
}