mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
build/jdk made configurable to prevent cleanup on branch change (for Cherry-Pick robot): property name fix, fail when starting Gradle not on Java 1.8
This commit is contained in:
@@ -6,7 +6,7 @@ cleanSetupJdks.dependsOn('cleanSetupJdk18', 'cleanSetupJdk16', 'cleanDownloadJdk
|
||||
|
||||
def jdkRepo = 'https://cache-redirector.jetbrains.com'
|
||||
|
||||
def jdkDir = System.getProperty('jdk.dir')?.with {
|
||||
def jdkDir = System.getProperty('intellij.build.jdks.target.dir')?.with {
|
||||
def jdkDir = new File(it)
|
||||
jdkDir.mkdirs()
|
||||
jdkDir
|
||||
|
||||
@@ -125,4 +125,10 @@ class BuildOptions {
|
||||
* Specifies JRE build to be bundled with distributions. If {@code null} then jdkBuild from gradle.properties will be used.
|
||||
*/
|
||||
String bundledJreBuild = System.getProperty("intellij.build.bundled.jre.build")
|
||||
|
||||
/**
|
||||
* Directory path to unpack Jetbrains JDK builds into
|
||||
*/
|
||||
static final String JDKS_TARGET_DIR_OPTION = "intellij.build.jdks.target.dir"
|
||||
String jdksTargetDir = System.getProperty(JDKS_TARGET_DIR_OPTION)
|
||||
}
|
||||
@@ -69,9 +69,6 @@ class GradleRunner {
|
||||
List<String> command = new ArrayList()
|
||||
command.add("${projectDir.absolutePath}/$gradleScript".toString())
|
||||
command.add("-Djava.io.tmpdir=${System.getProperty('java.io.tmpdir')}".toString())
|
||||
System.getProperty('jdk.dir')?.with {
|
||||
command.add("-Djdk.dir=$it".toString())
|
||||
}
|
||||
command.addAll(tasks)
|
||||
command.add('--stacktrace')
|
||||
if (System.getProperty("intellij.build.use.gradle.daemon", "false").toBoolean()) {
|
||||
|
||||
+12
-14
@@ -65,24 +65,20 @@ class CompilationContextImpl implements CompilationContext {
|
||||
|
||||
def dependenciesProjectDir = new File(communityHome, 'build/dependencies')
|
||||
logFreeDiskSpace(messages, projectHome, "before downloading dependencies")
|
||||
def gradleJdk = toCanonicalPath(JdkUtils.computeJdkHome(messages, "jdk8Home", "", "JDK_18_x64", false))
|
||||
def gradleJdk = toCanonicalPath(JdkUtils.computeJdkHome(messages, "jdk8Home", "", "JDK_18_x64"))
|
||||
GradleRunner gradle = new GradleRunner(dependenciesProjectDir, messages, gradleJdk)
|
||||
if (!options.isInDevelopmentMode) {
|
||||
setupCompilationDependencies(gradle)
|
||||
setupCompilationDependencies(gradle, options)
|
||||
}
|
||||
else {
|
||||
gradle.run('Setting up Kotlin plugin', 'setupKotlinPlugin')
|
||||
}
|
||||
|
||||
projectHome = toCanonicalPath(projectHome)
|
||||
def jdk8Home = toCanonicalPath(JdkUtils.computeJdkHome(messages, "jdk8Home", "${jdkDir(projectHome)}/1.8", "JDK_18_x64"))
|
||||
def jdk8Home = toCanonicalPath(JdkUtils.computeJdkHome(messages, "jdk8Home", "${jdkDir(projectHome, options)}/1.8", "JDK_18_x64"))
|
||||
def kotlinHome = toCanonicalPath("$communityHome/build/dependencies/build/kotlin/Kotlin")
|
||||
|
||||
if (!JdkVersionDetector.instance.detectJdkVersionInfo(gradleJdk).version.contains("1.8.")) {
|
||||
gradle = new GradleRunner(dependenciesProjectDir, messages, jdk8Home)
|
||||
}
|
||||
|
||||
def model = loadProject(projectHome, jdk8Home, kotlinHome, messages, ant)
|
||||
def model = loadProject(projectHome, jdk8Home, kotlinHome, messages, options, ant)
|
||||
def oldToNewModuleName = loadModuleRenamingHistory(projectHome, messages) + loadModuleRenamingHistory(communityHome, messages)
|
||||
def context = new CompilationContextImpl(ant, gradle, model, communityHome, projectHome, jdk8Home, kotlinHome, messages, oldToNewModuleName,
|
||||
buildOutputRootEvaluator, options)
|
||||
@@ -91,8 +87,8 @@ class CompilationContextImpl implements CompilationContext {
|
||||
return context
|
||||
}
|
||||
|
||||
private static String jdkDir(String projectHome) {
|
||||
System.getProperty('jdk.dir')?.with {
|
||||
private static String jdkDir(String projectHome, BuildOptions options) {
|
||||
options.jdksTargetDir?.with {
|
||||
new File(it).exists() ? it : null
|
||||
} ?: "$projectHome/build/jdk"
|
||||
}
|
||||
@@ -135,7 +131,7 @@ class CompilationContextImpl implements CompilationContext {
|
||||
paths.kotlinHome, messages, oldToNewModuleName, buildOutputRootEvaluator, options)
|
||||
}
|
||||
|
||||
private static JpsModel loadProject(String projectHome, String jdkHome, String kotlinHome, BuildMessages messages, AntBuilder ant) {
|
||||
private static JpsModel loadProject(String projectHome, String jdkHome, String kotlinHome, BuildMessages messages, BuildOptions options, AntBuilder ant) {
|
||||
//we need to add Kotlin JPS plugin to classpath before loading the project to ensure that Kotlin settings will be properly loaded
|
||||
ensureKotlinJpsPluginIsAddedToClassPath(kotlinHome, ant, messages)
|
||||
|
||||
@@ -144,7 +140,7 @@ class CompilationContextImpl implements CompilationContext {
|
||||
pathVariablesConfiguration.addPathVariable("KOTLIN_BUNDLED", "$kotlinHome/kotlinc")
|
||||
pathVariablesConfiguration.addPathVariable("MAVEN_REPOSITORY", FileUtil.toSystemIndependentName(new File(SystemProperties.getUserHome(), ".m2/repository").absolutePath))
|
||||
|
||||
JdkUtils.defineJdk(model.global, "IDEA jdk", JdkUtils.computeJdkHome(messages, "jdkHome", "${jdkDir(projectHome)}/1.6", "JDK_16_x64"))
|
||||
JdkUtils.defineJdk(model.global, "IDEA jdk", JdkUtils.computeJdkHome(messages, "jdkHome", "${jdkDir(projectHome, options)}/1.6", "JDK_16_x64"))
|
||||
JdkUtils.defineJdk(model.global, "1.8", jdkHome)
|
||||
|
||||
def pathVariables = JpsModelSerializationDataService.computeAllPathVariables(model.global)
|
||||
@@ -154,10 +150,12 @@ class CompilationContextImpl implements CompilationContext {
|
||||
}
|
||||
|
||||
static boolean dependenciesInstalled
|
||||
static void setupCompilationDependencies(GradleRunner gradle) {
|
||||
static void setupCompilationDependencies(GradleRunner gradle, BuildOptions options) {
|
||||
if (!dependenciesInstalled) {
|
||||
dependenciesInstalled = true
|
||||
gradle.run('Setting up compilation dependencies', 'setupJdks', 'setupKotlinPlugin')
|
||||
String[] args = ['setupJdks', 'setupKotlinPlugin']
|
||||
if (options.jdksTargetDir != null) args += "-D$BuildOptions.JDKS_TARGET_DIR_OPTION=$options.jdksTargetDir".toString()
|
||||
gradle.run('Setting up compilation dependencies', args)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class CompilationTasksImpl extends CompilationTasks {
|
||||
return
|
||||
}
|
||||
|
||||
CompilationContextImpl.setupCompilationDependencies(context.gradle)
|
||||
CompilationContextImpl.setupCompilationDependencies(context.gradle, context.options)
|
||||
|
||||
context.messages.progress("Compiling project")
|
||||
JpsCompilationRunner runner = new JpsCompilationRunner(context)
|
||||
|
||||
@@ -23,7 +23,7 @@ class JdkUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static String computeJdkHome(BuildMessages messages, String propertyName, String defaultDir, String envVarName, boolean requireJdk8 = true) {
|
||||
static String computeJdkHome(BuildMessages messages, String propertyName, String defaultDir, String envVarName) {
|
||||
String jdkDir = System.getProperty(propertyName)
|
||||
if (jdkDir != null) {
|
||||
return jdkDir
|
||||
@@ -42,13 +42,8 @@ class JdkUtils {
|
||||
jdkDir = getCurrentJdk()
|
||||
def jdkInfo = JdkVersionDetector.instance.detectJdkVersionInfo(jdkDir)
|
||||
if (propertyName.contains("8") && !jdkInfo.version.contains("1.8.")) {
|
||||
def msg = "JDK 1.8 is required to compile the project, but '$propertyName' property and '$envVarName' environment variable" +
|
||||
" aren't defined and default JDK $jdkDir ($jdkInfo) cannot be used as JDK 1.8"
|
||||
if (requireJdk8) {
|
||||
messages.error(msg)
|
||||
return null
|
||||
}
|
||||
messages.warning(msg)
|
||||
messages.error("JDK 1.8 is required to compile the project, but '$propertyName' property and '$envVarName' environment variable" +
|
||||
" aren't defined and default JDK $jdkDir ($jdkInfo) cannot be used as JDK 1.8")
|
||||
}
|
||||
messages.info("'$envVarName' isn't defined and '$defaultDir' doesn't exist, $propertyName set to $jdkDir")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user