diff --git a/build.gradle.kts b/build.gradle.kts index 69d69276231..dd8afa6f1cb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -162,7 +162,7 @@ extra["IntellijCoreDependencies"] = "log4j", "picocontainer", "snappy-in-java-0.5.1", - "streamex-0.6.2", + "streamex", "trove4j", "xpp3-1.1.4-min", "xstream-1.4.8") diff --git a/buildSrc/prepare-deps/intellij-sdk/build.gradle.kts b/buildSrc/prepare-deps/intellij-sdk/build.gradle.kts index 9d78efd589a..3c074e3641c 100644 --- a/buildSrc/prepare-deps/intellij-sdk/build.gradle.kts +++ b/buildSrc/prepare-deps/intellij-sdk/build.gradle.kts @@ -12,8 +12,8 @@ val intellijUltimateEnabled: Boolean by rootProject.extra val intellijRepo: String by rootProject.extra val intellijReleaseType: String by rootProject.extra val intellijVersion = rootProject.extra["versions.intellijSdk"] as String -val androidStudioRelease = rootProject.extra["versions.androidStudioRelease"] as String? -val androidStudioBuild = rootProject.extra["versions.androidStudioBuild"] as String? +val androidStudioRelease = if (rootProject.extra.has("versions.androidStudioRelease")) rootProject.extra["versions.androidStudioRelease"] as String else null +val androidStudioBuild = if (rootProject.extra.has("versions.androidStudioBuild")) rootProject.extra["versions.androidStudioBuild"] as String else null val intellijSeparateSdks: Boolean by rootProject.extra val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks val installIntellijUltimate = intellijUltimateEnabled @@ -64,8 +64,8 @@ dependencies { if (installIntellijUltimate) { intellijUltimate("com.jetbrains.intellij.idea:ideaIU:$intellijVersion") } - sources("com.jetbrains.intellij.idea:ideaIC:$intellijVersion:sources@jar") } + sources("com.jetbrains.intellij.idea:ideaIC:$intellijVersion:sources@jar") `jps-standalone`("com.jetbrains.intellij.idea:jps-standalone:$intellijVersion") `jps-build-test`("com.jetbrains.intellij.idea:jps-build-test:$intellijVersion") `intellij-core`("com.jetbrains.intellij.idea:intellij-core:$intellijVersion") @@ -74,7 +74,9 @@ dependencies { } } -fun Task.configureExtractFromConfigurationTask(sourceConfig: Configuration, extractor: (Configuration) -> Any) { +fun Task.configureExtractFromConfigurationTask(sourceConfig: Configuration, + pathRemap: (String) -> String = { it }, + extractor: (Configuration) -> Any) { dependsOn(sourceConfig) inputs.files(sourceConfig) val targetDir = File(repoDir, sourceConfig.name) @@ -83,11 +85,26 @@ fun Task.configureExtractFromConfigurationTask(sourceConfig: Configuration, extr project.copy { from(extractor(sourceConfig)) into(targetDir) + eachFile { + path = pathRemap(path) + } } } } -val unzipIntellijSdk by tasks.creating { configureExtractFromConfigurationTask(intellij) { zipTree(it.singleFile) } } +fun removePathPrefix(path: String): String { + if (androidStudioRelease == null) return path + val slashes = if (studioOs == "mac") 2 else 1 + var result = path + repeat(slashes) { + result = result.substringAfter('/') + } + return result +} + +val unzipIntellijSdk by tasks.creating { + configureExtractFromConfigurationTask(intellij, pathRemap = { removePathPrefix(it) }) { zipTree(it.singleFile) } +} val unzipIntellijUltimateSdk by tasks.creating { configureExtractFromConfigurationTask(intellijUltimate) { zipTree(it.singleFile) } } @@ -96,9 +113,7 @@ val unzipIntellijCore by tasks.creating { configureExtractFromConfigurationTask( val unzipJpsStandalone by tasks.creating { configureExtractFromConfigurationTask(`jps-standalone`) { zipTree(it.singleFile) } } val copyIntellijSdkSources by tasks.creating { - if (androidStudioRelease == null) { - configureExtractFromConfigurationTask(sources) { it.singleFile } - } + configureExtractFromConfigurationTask(sources) { it.singleFile } } val copyJpsBuildTest by tasks.creating { configureExtractFromConfigurationTask(`jps-build-test`) { it.singleFile } } diff --git a/buildSrc/src/main/kotlin/intellijDependencies.kt b/buildSrc/src/main/kotlin/intellijDependencies.kt index 9c5ba34cc0b..5691942185e 100644 --- a/buildSrc/src/main/kotlin/intellijDependencies.kt +++ b/buildSrc/src/main/kotlin/intellijDependencies.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + @file:Suppress("unused") // usages in build scripts are not tracked properly import org.gradle.api.GradleException @@ -6,6 +22,7 @@ import org.gradle.api.artifacts.ModuleDependency import org.gradle.kotlin.dsl.extra import org.gradle.api.artifacts.dsl.RepositoryHandler import org.gradle.api.artifacts.repositories.IvyArtifactRepository +import org.gradle.kotlin.dsl.DependencyHandlerScope private fun Project.intellijRepoDir() = File("${project.rootDir.absoluteFile}/buildSrc/prepare-deps/intellij-sdk/build/repo") @@ -36,10 +53,17 @@ fun Project.intellijUltimateDep() = intellijDep("intellij") fun Project.intellijUltimatePluginDep(plugin: String) = intellijDep(plugin) -fun ModuleDependency.includeJars(vararg names: String) { +fun ModuleDependency.includeJars(vararg names: String, rootProject: Project? = null) { names.forEach { + var baseName = it.removeSuffix(".jar") + if (rootProject != null && rootProject.extra.has("ignore.jar.$baseName")) { + return@forEach + } + if (rootProject != null && rootProject.extra.has("versions.jar.$baseName")) { + baseName += "-${rootProject.extra["versions.jar.$baseName"]}" + } artifact { - name = it.removeSuffix(".jar") + name = baseName type = "jar" extension = "jar" } @@ -47,10 +71,10 @@ fun ModuleDependency.includeJars(vararg names: String) { } fun ModuleDependency.includeIntellijCoreJarDependencies(project: Project) = - includeJars(*(project.rootProject.extra["IntellijCoreDependencies"] as List).toTypedArray()) + includeJars(*(project.rootProject.extra["IntellijCoreDependencies"] as List).toTypedArray(), rootProject = project.rootProject) fun ModuleDependency.includeIntellijCoreJarDependencies(project: Project, jarsFilterPredicate: (String) -> Boolean) = - includeJars(*(project.rootProject.extra["IntellijCoreDependencies"] as List).filter { jarsFilterPredicate(it) }.toTypedArray()) + includeJars(*(project.rootProject.extra["IntellijCoreDependencies"] as List).filter { jarsFilterPredicate(it) }.toTypedArray(), rootProject = project.rootProject) fun Project.isIntellijCommunityAvailable() = !(rootProject.extra["intellijUltimateEnabled"] as Boolean) || rootProject.extra["intellijSeparateSdks"] as Boolean @@ -65,3 +89,8 @@ fun Project.intellijUltimateRootDir() = else throw GradleException("intellij ultimate SDK is not available") +fun DependencyHandlerScope.excludeInAndroidStudio(rootProject: Project, block: DependencyHandlerScope.() -> Unit) { + if (!rootProject.extra.has("versions.androidStudioRelease")) { + block() + } +} \ No newline at end of file diff --git a/idea/build.gradle.kts b/idea/build.gradle.kts index 6f5474dc673..4245bbd215f 100644 --- a/idea/build.gradle.kts +++ b/idea/build.gradle.kts @@ -36,8 +36,8 @@ dependencies { compileOnly(intellijCoreDep()) { includeJars("intellij-core") } compileOnly(intellijDep()) { - includeJars("annotations", "openapi", "idea", "velocity", "boot", "gson-2.5", "log4j", "asm-all", - "swingx-core-1.6.2", "forms_rt", "util", "jdom", "trove4j", "guava-21.0") + includeJars("annotations", "openapi", "idea", "velocity", "boot", "gson", "log4j", "asm-all", + "swingx-core-1.6.2", "forms_rt", "util", "jdom", "trove4j", "guava-21.0", rootProject = rootProject) } compileOnly(commonDep("com.google.code.findbugs", "jsr305")) compileOnly(intellijPluginDep("IntelliLang")) diff --git a/idea/idea-android/build.gradle.kts b/idea/idea-android/build.gradle.kts index b920043dc6e..e229b723588 100644 --- a/idea/idea-android/build.gradle.kts +++ b/idea/idea-android/build.gradle.kts @@ -1,3 +1,4 @@ + import org.jetbrains.kotlin.gradle.tasks.KotlinCompile apply { plugin("kotlin") } @@ -21,7 +22,7 @@ dependencies { compile(androidDxJar()) - compileOnly(intellijDep()) { includeJars("openapi", "idea", "extensions", "util", "guava-21.0") } + compileOnly(intellijDep()) { includeJars("openapi", "idea", "extensions", "util", "guava-21.0", "android-base-common", rootProject = rootProject) } compileOnly(intellijPluginDep("android")) { includeJars("android", "android-common", "sdk-common", "sdklib", "sdk-tools", "layoutlib-api") } diff --git a/idea/idea-android/idea-android-output-parser/build.gradle.kts b/idea/idea-android/idea-android-output-parser/build.gradle.kts index 0247c144bff..bb6cd4f6ebd 100644 --- a/idea/idea-android/idea-android-output-parser/build.gradle.kts +++ b/idea/idea-android/idea-android-output-parser/build.gradle.kts @@ -4,8 +4,8 @@ apply { plugin("kotlin") } dependencies { compile(project(":compiler:util")) compileOnly(intellijCoreDep()) { includeJars("intellij-core") } - compileOnly(intellijDep()) { includeJars("guava-21.0") } - compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api-3.5") } + compileOnly(intellijDep()) { includeJars("guava-21.0", "android-base-common", rootProject = rootProject) } + compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api", rootProject = rootProject) } compileOnly(intellijPluginDep("android")) { includeJars("android", "android-common", "sdk-common") } } diff --git a/idea/idea-core/build.gradle.kts b/idea/idea-core/build.gradle.kts index 0be9627ead1..d01889321eb 100644 --- a/idea/idea-core/build.gradle.kts +++ b/idea/idea-core/build.gradle.kts @@ -1,3 +1,4 @@ + apply { plugin("kotlin") } dependencies { @@ -18,7 +19,7 @@ dependencies { compile(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-jdk8")) { isTransitive = false } compileOnly(intellijCoreDep()) { includeJars("intellij-core") } compileOnly(intellijDep()) { includeJars("util", "openapi", "idea", "asm-all", "jdom", "annotations", "trove4j", "guava-21.0") } - compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api-3.5", "gradle") } + compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api", "gradle", rootProject = rootProject) } } sourceSets { diff --git a/idea/idea-gradle/build.gradle.kts b/idea/idea-gradle/build.gradle.kts index ce5db43631d..4ed220b5bb9 100644 --- a/idea/idea-gradle/build.gradle.kts +++ b/idea/idea-gradle/build.gradle.kts @@ -1,3 +1,4 @@ + apply { plugin("kotlin") } val androidSdk by configurations.creating @@ -17,14 +18,14 @@ dependencies { compile(project(":js:js.frontend")) compileOnly(intellijDep()) { includeJars("openapi", "idea", "external-system-rt", "forms_rt", "extensions", "jdom", "util") } - compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api-3.5", "gradle", "gradle-base-services-3.5") } + compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api", "gradle", "gradle-base-services", rootProject = rootProject) } compileOnly(intellijPluginDep("Groovy")) { includeJars("Groovy") } compileOnly(intellijPluginDep("junit")) { includeJars("idea-junit") } testCompile(projectTests(":idea")) testCompile(project(":idea:idea-test-framework")) - testCompile(intellijPluginDep("gradle")) { includeJars("gradle-wrapper-3.5", "gradle-base-services-3.5", "gradle-tooling-extension-impl", "gradle-tooling-api-3.5", "gradle") } + testCompile(intellijPluginDep("gradle")) { includeJars("gradle-wrapper", "gradle-base-services", "gradle-tooling-extension-impl", "gradle-tooling-api", "gradle", rootProject = rootProject) } testCompileOnly(intellijPluginDep("Groovy")) { includeJars("Groovy") } testCompileOnly(intellijDep()) { includeJars("groovy-all-2.4.6", "idea_rt") } diff --git a/idea/idea-jvm/build.gradle.kts b/idea/idea-jvm/build.gradle.kts index f33097eff58..965ad235819 100644 --- a/idea/idea-jvm/build.gradle.kts +++ b/idea/idea-jvm/build.gradle.kts @@ -5,8 +5,8 @@ dependencies { compile(project(":idea")) compile(project(":compiler:light-classes")) compile(project(":compiler:frontend.java")) - compileOnly(intellijDep()) { includeJars("annotations", "openapi", "idea", "extensions", "util", "velocity", "boot", "gson-2.5", - "swingx-core-1.6.2", "forms_rt", "jdom", "log4j", "guava-21.0", "asm-all") } + compileOnly(intellijDep()) { includeJars("annotations", "openapi", "idea", "extensions", "util", "velocity", "boot", "gson", + "swingx-core-1.6.2", "forms_rt", "jdom", "log4j", "guava-21.0", "asm-all", rootProject = rootProject) } compileOnly(commonDep("com.google.code.findbugs", "jsr305")) compileOnly(intellijPluginDep("junit")) { includeJars("idea-junit") } diff --git a/idea/idea-maven/build.gradle.kts b/idea/idea-maven/build.gradle.kts index b193e94d1f4..a85b9d76dc2 100644 --- a/idea/idea-maven/build.gradle.kts +++ b/idea/idea-maven/build.gradle.kts @@ -15,14 +15,14 @@ dependencies { compile(project(":idea:idea-jvm")) compile(project(":idea:idea-jps-common")) - compileOnly(intellijDep()) { includeJars("openapi", "idea", "gson-2.5", "jdom", "extensions", "util") } - compileOnly(intellijPluginDep("maven")) { includeJars("maven", "maven-server-api") } + compileOnly(intellijDep()) { includeJars("openapi", "idea", "gson", "jdom", "extensions", "util", rootProject = rootProject) } + excludeInAndroidStudio(rootProject) { compileOnly(intellijPluginDep("maven")) { includeJars("maven", "maven-server-api") } } testCompile(projectTests(":idea")) testCompile(projectTests(":compiler:tests-common")) testCompile(project(":idea:idea-test-framework")) - testCompileOnly(intellijDep()) { includeJars("openapi", "idea", "gson-2.5", "idea_rt") } + testCompileOnly(intellijDep()) { includeJars("openapi", "idea", "gson", "idea_rt", rootProject = rootProject) } testCompileOnly(intellijPluginDep("maven")) { includeJars("maven", "maven-server-api") } testRuntime(projectDist(":kotlin-reflect")) diff --git a/idea/kotlin-gradle-tooling/build.gradle.kts b/idea/kotlin-gradle-tooling/build.gradle.kts index 384b4f17116..abcd150e8df 100644 --- a/idea/kotlin-gradle-tooling/build.gradle.kts +++ b/idea/kotlin-gradle-tooling/build.gradle.kts @@ -9,11 +9,12 @@ dependencies { compile(projectDist(":kotlin-stdlib")) compile(project(":compiler:cli-common")) compile(intellijPluginDep("gradle")) { - includeJars("gradle-tooling-api-3.5", + includeJars("gradle-tooling-api", "gradle-tooling-extension-api", "gradle", - "gradle-core-3.5", - "gradle-base-services-groovy-3.5") + "gradle-core", + "gradle-base-services-groovy", + rootProject = rootProject) } } diff --git a/plugins/allopen/allopen-ide/build.gradle.kts b/plugins/allopen/allopen-ide/build.gradle.kts index bbdbf9c23fa..1ad5dd989a3 100644 --- a/plugins/allopen/allopen-ide/build.gradle.kts +++ b/plugins/allopen/allopen-ide/build.gradle.kts @@ -15,8 +15,8 @@ dependencies { compile(project(":idea:idea-jps-common")) compile(project(":plugins:annotation-based-compiler-plugins-ide-support")) compileOnly(intellijDep()) { includeJars("openapi", "idea") } - compileOnly(intellijPluginDep("maven")) { includeJars("maven") } - compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api-3.5", "gradle") } + excludeInAndroidStudio(rootProject) { compileOnly(intellijPluginDep("maven")) { includeJars("maven") } } + compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api", "gradle", rootProject = rootProject) } } sourceSets { diff --git a/plugins/android-extensions/android-extensions-idea/build.gradle.kts b/plugins/android-extensions/android-extensions-idea/build.gradle.kts index aa5a3c9fd1d..8cad6e19f45 100644 --- a/plugins/android-extensions/android-extensions-idea/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-idea/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { compileOnly(project(":kotlin-android-extensions-runtime")) compileOnly(intellijPluginDep("android")) { includeJars("android.jar", "android-common.jar", "sdk-common.jar", "sdk-tools.jar") } compileOnly(intellijPluginDep("Groovy")) { includeJars("Groovy.jar") } - compileOnly(intellijDep()) { includeJars("extensions.jar", "openapi.jar", "util.jar", "idea.jar") } + compileOnly(intellijDep()) { includeJars("extensions.jar", "openapi.jar", "util.jar", "idea.jar", "android-base-common.jar", rootProject = rootProject) } testCompile(project(":compiler:tests-common")) testCompile(project(":compiler:cli")) diff --git a/plugins/annotation-based-compiler-plugins-ide-support/build.gradle.kts b/plugins/annotation-based-compiler-plugins-ide-support/build.gradle.kts index c0fd396b9a9..5b2b9438d81 100644 --- a/plugins/annotation-based-compiler-plugins-ide-support/build.gradle.kts +++ b/plugins/annotation-based-compiler-plugins-ide-support/build.gradle.kts @@ -12,10 +12,10 @@ dependencies { compile(project(":idea:idea-jps-common")) compile(project(":idea:idea-gradle")) compile(project(":idea:idea-maven")) - compileOnly(intellijPluginDep("maven")) { includeJars("maven.jar", "maven-server-api.jar") } - compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api-3.5.jar", "gradle.jar") } - compileOnly(intellijDep()) { includeJars("openapi.jar", "idea.jar", "extensions.jar", "jdom.jar", "util.jar") } - } + excludeInAndroidStudio(rootProject) { compileOnly(intellijPluginDep("maven")) { includeJars("maven.jar", "maven-server-api.jar") } } + compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api", "gradle", rootProject = rootProject) } + compileOnly(intellijDep()) { includeJars("openapi.jar", "idea.jar", "extensions.jar", "jdom.jar", "util.jar") } + } sourceSets { "main" { projectDefault() } diff --git a/plugins/kapt3/kapt3-idea/build.gradle.kts b/plugins/kapt3/kapt3-idea/build.gradle.kts index d677a7133e8..b2039e81181 100644 --- a/plugins/kapt3/kapt3-idea/build.gradle.kts +++ b/plugins/kapt3/kapt3-idea/build.gradle.kts @@ -10,7 +10,7 @@ dependencies { compile(project(":idea:kotlin-gradle-tooling")) compile(project(":kotlin-annotation-processing")) compileOnly(intellijDep()) { includeJars("openapi", "external-system-rt", "util") } - compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-core-3.5", "gradle-tooling-api-3.5", "gradle") } + compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-core", "gradle-tooling-api", "gradle", rootProject = rootProject) } compileOnly(intellijPluginDep("android")) { includeJars("android", "android-common", "sdklib", "sdk-common", "sdk-tools") } } diff --git a/plugins/noarg/noarg-ide/build.gradle.kts b/plugins/noarg/noarg-ide/build.gradle.kts index 30958f58643..abd19a750ce 100644 --- a/plugins/noarg/noarg-ide/build.gradle.kts +++ b/plugins/noarg/noarg-ide/build.gradle.kts @@ -16,9 +16,9 @@ dependencies { compile(project(":idea:idea-jps-common")) compile(project(":plugins:annotation-based-compiler-plugins-ide-support")) compileOnly(intellijDep()) { includeJars("openapi.jar", "idea.jar") } - compileOnly(intellijPluginDep("maven")) { includeJars("maven.jar") } - compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api-3.5.jar", "gradle.jar") } - } + excludeInAndroidStudio(rootProject) { compileOnly(intellijPluginDep("maven")) { includeJars("maven.jar") } } + compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api", "gradle", rootProject = rootProject) } +} sourceSets { "main" { projectDefault() } diff --git a/versions.gradle.kts b/versions.gradle.kts index 802bfc192b3..65edae0eeab 100644 --- a/versions.gradle.kts +++ b/versions.gradle.kts @@ -2,3 +2,33 @@ extra["versions.intellijSdk"] = "173.4127.27" extra["versions.androidBuildTools"] = "r23.0.1" extra["versions.idea.NodeJS"] = "172.3757.32" +//extra["versions.intellijSdk"] = "173.3942.27" +//extra["versions.androidStudioRelease"] = "3.1.0.5" +//extra["versions.androidStudioBuild"] = "173.4506631" + +val gradleJars = listOf( + "gradle-tooling-api", "gradle-base-services", "gradle-wrapper", "gradle-core", "gradle-base-services-groovy" +) + +val platform = extra["versions.intellijSdk"].toString().substringBefore('.') +if (platform == "173") { + extra["versions.jar.streamex"] = "0.6.5" + extra["versions.jar.gson"] = "2.8.2" + for (jar in gradleJars) { + extra["versions.jar.$jar"] = "4.0" + } + extra["ignore.jar.lombok-ast-0.2.3"] = true +} +else { + extra["versions.jar.streamex"] = "0.6.2" + extra["versions.jar.gson"] = "2.5" + for (jar in gradleJars) { + extra["versions.jar.$jar"] = "3.5" + } +} + +if (!extra.has("versions.androidStudioRelease")) { + extra["ignore.jar.android-base-common"] = true +} + +