From 058ef31d7a6baa348a09921d562d664d669c1205 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Mon, 15 Jan 2018 12:49:50 +0100 Subject: [PATCH] Fixes after review --- build.gradle.kts | 9 +++-- buildSrc/build.gradle.kts | 1 - .../intellij-sdk/build.gradle.kts | 4 +-- buildSrc/src/main/kotlin/dependencies.kt | 1 - compiler/build.gradle.kts | 4 +-- .../cli/jvm/compiler/KotlinCoreEnvironment.kt | 4 ++- compiler/frontend/buildLexer.xml | 2 +- .../integration/AbstractAntTaskTest.java | 8 ++--- .../android-sdk/build.gradle.kts | 1 - .../protobuf-lite/build.gradle.kts | 7 ++-- idea-runner/build.gradle.kts | 6 ++-- j2k/build.gradle.kts | 33 ++++++++----------- js/js.tests/build.gradle.kts | 8 ++--- .../src/KotlinAndroidJpsPlugin.kt | 3 +- prepare/compiler/build.gradle.kts | 1 - 15 files changed, 41 insertions(+), 51 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index dd8afa6f1cb..596f3f95673 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -80,8 +80,8 @@ dependencies { } val commonBuildDir = File(rootDir, "build") -val distDir = "$rootDir/dist" -val distKotlinHomeDir = "$distDir/kotlinc" +val distDir by extra("$rootDir/dist") +val distKotlinHomeDir by extra("$distDir/kotlinc") val distLibDir = "$distKotlinHomeDir/lib" val commonLocalDataDir = "$rootDir/local" val ideaSandboxDir = "$commonLocalDataDir/ideaSandbox" @@ -89,8 +89,7 @@ val ideaUltimateSandboxDir = "$commonLocalDataDir/ideaUltimateSandbox" val ideaPluginDir = "$distDir/artifacts/ideaPlugin/Kotlin" val ideaUltimatePluginDir = "$distDir/artifacts/ideaUltimatePlugin/Kotlin" -extra["distDir"] = distDir -extra["distKotlinHomeDir"] = distKotlinHomeDir +// TODO: use "by extra()" syntax where possible extra["distLibDir"] = project.file(distLibDir) extra["libsDir"] = project.file(distLibDir) extra["commonLocalDataDir"] = project.file(commonLocalDataDir) @@ -139,7 +138,7 @@ extra["versions.jflex"] = "1.7.0" val markdownVer = "4054 - Kotlin 1.0.2-dev-566".replace(" ", "%20") // fixed here, was last with "status:SUCCESS,tag:forKotlin" extra["markdownParserRepo"] = "https://teamcity.jetbrains.com/guestAuth/repository/download/IntelliJMarkdownParser_Build/$markdownVer/([artifact]_[ext]/)[artifact](.[ext])" -fun Project.getBooleanProperty(name: String): Boolean? = this.findProperty("intellijUltimateEnabled")?.let { +fun Project.getBooleanProperty(name: String): Boolean? = this.findProperty(name)?.let { val v = it.toString() if (v.isBlank()) true else v.toBoolean() diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 62d809332b6..c9fe51d1aa8 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -51,7 +51,6 @@ extra["intellijRepo"] = "https://www.jetbrains.com/intellij-repository" extra["intellijReleaseType"] = "releases" // or "snapshots" extra["versions.androidDxSources"] = "5.0.0_r2" -extra["customDepsRepo"] = "$rootDir/repo" extra["customDepsOrg"] = "kotlin.build.custom.deps" repositories { diff --git a/buildSrc/prepare-deps/intellij-sdk/build.gradle.kts b/buildSrc/prepare-deps/intellij-sdk/build.gradle.kts index 3c074e3641c..5541d8e4679 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 = 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 androidStudioRelease = rootProject.findProperty("versions.androidStudioRelease") as String? +val androidStudioBuild = rootProject.findProperty("versions.androidStudioBuild") as String? val intellijSeparateSdks: Boolean by rootProject.extra val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks val installIntellijUltimate = intellijUltimateEnabled diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/src/main/kotlin/dependencies.kt index afaa691d7eb..1a1f0be3ec1 100644 --- a/buildSrc/src/main/kotlin/dependencies.kt +++ b/buildSrc/src/main/kotlin/dependencies.kt @@ -69,7 +69,6 @@ val protobufLiteTask = "$protobufLiteProject:prepare" fun DependencyHandler.protobufFull(): ProjectDependency = project(protobufRelocatedProject, configuration = "default").apply { isTransitive = false } -val protobufFullTask = "$protobufLiteProject:prepare" fun File.matchMaybeVersionedArtifact(baseName: String) = name.matches(baseName.toMaybeVersionedJarRegex()) diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 93b013252e5..b45d679202a 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -86,8 +86,8 @@ projectTest { workingDir = rootDir systemProperty("kotlin.test.script.classpath", the().sourceSets.getByName("test").output.classesDirs.joinToString(File.pathSeparator)) doFirst { - systemProperty("ant.classpath", antLauncherJar.asPath) - systemProperty("ant.launcher.class", "org.apache.tools.ant.Main") + systemProperty("kotlin.ant.classpath", antLauncherJar.asPath) + systemProperty("kotlin.ant.launcher.class", "org.apache.tools.ant.Main") systemProperty("idea.home.path", intellijRootDir().canonicalPath) } } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt index 4e5bd4e725d..b5676170dae 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt @@ -527,7 +527,9 @@ class KotlinCoreEnvironment private constructor( ?: PathUtil.getResourcePathForClass(this::class.java).takeIf { it.hasConfigFile(configFilePath) } // hack for load extensions when compiler run directly from project directory (e.g. in tests) ?: File("compiler/cli/src").takeIf { it.hasConfigFile(configFilePath) } - ?: throw IllegalStateException("Unable to find extension point configuration $configFilePath (cp:\n ${(Thread.currentThread().contextClassLoader as? UrlClassLoader)?.urls?.joinToString("\n ") { it.file }})") + ?: throw IllegalStateException( + "Unable to find extension point configuration $configFilePath " + + "(cp:\n ${(Thread.currentThread().contextClassLoader as? UrlClassLoader)?.urls?.joinToString("\n ") { it.file }})") CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginRoot, configFilePath, Extensions.getRootArea()) } diff --git a/compiler/frontend/buildLexer.xml b/compiler/frontend/buildLexer.xml index 5c9c51f5427..c696ff2232d 100644 --- a/compiler/frontend/buildLexer.xml +++ b/compiler/frontend/buildLexer.xml @@ -1,7 +1,7 @@ - + diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java index edb51e95889..cb3d216988d 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java @@ -25,14 +25,14 @@ public abstract class AbstractAntTaskTest extends KotlinIntegrationTestBase { protected void doTest(String testFile) throws Exception { String testDataDir = new File(testFile).getAbsolutePath(); - String antClasspath = System.getProperty("ant.classpath"); + String antClasspath = System.getProperty("kotlin.ant.classpath"); if (antClasspath == null) { - throw new RuntimeException("Unable to get a valid classpath from 'ant.classpath' property, please set it accordingly"); + throw new RuntimeException("Unable to get a valid classpath from 'kotlin.ant.classpath' property, please set it accordingly"); } - String antLauncherClass = System.getProperty("ant.launcher.class"); + String antLauncherClass = System.getProperty("kotlin.ant.launcher.class"); if (antLauncherClass == null) { - throw new RuntimeException("Unable to get a valid class FQN from 'ant.launcher.class' property, please set it accordingly"); + throw new RuntimeException("Unable to get a valid class FQN from 'kotlin.ant.launcher.class' property, please set it accordingly"); } runJava( diff --git a/custom-dependencies/android-sdk/build.gradle.kts b/custom-dependencies/android-sdk/build.gradle.kts index 9d4da24016c..30a9d921cf1 100644 --- a/custom-dependencies/android-sdk/build.gradle.kts +++ b/custom-dependencies/android-sdk/build.gradle.kts @@ -97,7 +97,6 @@ val extractAndroidJar by tasks.creating { inputs.files(androidPlatform) val targetFile = File(libsDestDir, "android.jar") outputs.files(targetFile) - outputs.upToDateWhen { targetFile.exists() } // TODO: consider more precise check, e.g. hash-based doFirst { project.copy { from(zipTree(androidPlatform.singleFile).matching { include("**/android.jar") }.files.first()) diff --git a/custom-dependencies/protobuf-lite/build.gradle.kts b/custom-dependencies/protobuf-lite/build.gradle.kts index d5d779d1cff..49293815dd7 100644 --- a/custom-dependencies/protobuf-lite/build.gradle.kts +++ b/custom-dependencies/protobuf-lite/build.gradle.kts @@ -21,10 +21,7 @@ dependencies { } task("prepare") { - // TODO: find out why it doesn't work without explicit dependsOn - dependsOn(":custom-dependencies:protobuf-relocated:prepare") - val inputJar = relocatedProtobuf.files.single() - inputs.files(inputJar) + inputs.files(relocatedProtobuf) // this also adds a dependency outputs.file(outputJarPath) doFirst { File(outputJarPath).parentFile.mkdirs() @@ -49,7 +46,7 @@ task("prepare") { return result } - val allFiles = loadAllFromJar(File(inputJar)) + val allFiles = loadAllFromJar(File(relocatedProtobuf.singleFile)) val keepClasses = arrayListOf() diff --git a/idea-runner/build.gradle.kts b/idea-runner/build.gradle.kts index 0a5c08a6095..c3bb706f7f0 100644 --- a/idea-runner/build.gradle.kts +++ b/idea-runner/build.gradle.kts @@ -58,8 +58,10 @@ afterEvaluate { "-Dapple.laf.useScreenMenuBar=true", "-Dapple.awt.graphics.UseQuartz=true", "-Dsun.io.useCanonCaches=false", - "-Dkotlin.internal.mode.enabled=true", - "-Didea.ProcessCanceledException=disabled" + "-Dkotlin.internal.mode.enabled=true" ) + if (project.hasProperty("noPCE")) { + jvmArgs("-Didea.ProcessCanceledException=disabled") + } } } diff --git a/j2k/build.gradle.kts b/j2k/build.gradle.kts index ca44fb19155..132e73c5064 100644 --- a/j2k/build.gradle.kts +++ b/j2k/build.gradle.kts @@ -1,22 +1,6 @@ apply { plugin("kotlin") } -val usedIntellijPlugins = arrayOf( - "properties", - "gradle", - "Groovy", - "coverage", - "maven", - "android", - "junit", - "testng", - "IntelliLang", - "testng", - "copyright", - "properties", - "java-i18n", - "java-decompiler") - dependencies { testRuntime(intellijCoreDep()) { includeJars("intellij-core") } testRuntime(intellijDep()) @@ -41,9 +25,20 @@ dependencies { testRuntime(project(":sam-with-receiver-ide-plugin")) testRuntime(project(":allopen-ide-plugin")) testRuntime(project(":noarg-ide-plugin")) - usedIntellijPlugins.forEach { - testRuntime(intellijPluginDep(it)) - } + testRuntime(intellijPluginDep("properties")) + testRuntime(intellijPluginDep("gradle")) + testRuntime(intellijPluginDep("Groovy")) + testRuntime(intellijPluginDep("coverage")) + testRuntime(intellijPluginDep("maven")) + testRuntime(intellijPluginDep("android")) + testRuntime(intellijPluginDep("junit")) + testRuntime(intellijPluginDep("testng")) + testRuntime(intellijPluginDep("IntelliLang")) + testRuntime(intellijPluginDep("testng")) + testRuntime(intellijPluginDep("copyright")) + testRuntime(intellijPluginDep("properties")) + testRuntime(intellijPluginDep("java-i18n")) + testRuntime(intellijPluginDep("java-decompiler")) } sourceSets { diff --git a/js/js.tests/build.gradle.kts b/js/js.tests/build.gradle.kts index 9177bfea6c5..3334ab160b3 100644 --- a/js/js.tests/build.gradle.kts +++ b/js/js.tests/build.gradle.kts @@ -62,8 +62,8 @@ projectTest { dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray()) workingDir = rootDir doFirst { - systemProperty("ant.classpath", antLauncherJar.asPath) - systemProperty("ant.launcher.class", "org.apache.tools.ant.Main") + systemProperty("kotlin.ant.classpath", antLauncherJar.asPath) + systemProperty("kotlin.ant.launcher.class", "org.apache.tools.ant.Main") } } @@ -74,8 +74,8 @@ projectTest("quickTest") { workingDir = rootDir systemProperty("kotlin.js.skipMinificationTest", "true") doFirst { - systemProperty("ant.classpath", antLauncherJar.asPath) - systemProperty("ant.launcher.class", "org.apache.tools.ant.Main") + systemProperty("kotlin.ant.classpath", antLauncherJar.asPath) + systemProperty("kotlin.ant.launcher.class", "org.apache.tools.ant.Main") } } diff --git a/plugins/android-extensions/android-extensions-jps/src/KotlinAndroidJpsPlugin.kt b/plugins/android-extensions/android-extensions-jps/src/KotlinAndroidJpsPlugin.kt index 820548f19fc..ecdf408efa2 100644 --- a/plugins/android-extensions/android-extensions-jps/src/KotlinAndroidJpsPlugin.kt +++ b/plugins/android-extensions/android-extensions-jps/src/KotlinAndroidJpsPlugin.kt @@ -62,7 +62,6 @@ class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider { val module = moduleBuildTarget.module if (!hasAndroidJpsPlugin() || !isAndroidModuleWithoutGradle(module)) return emptyList() - val inJar = File(PathUtil.getJarPathForClass(this::class.java)).isFile val manifestFile = getAndroidManifest(moduleBuildTarget.module) return if (manifestFile != null) { @@ -74,7 +73,7 @@ class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider { compilerPluginJar = File("dist/kotlinc/lib/$JAR_FILE_NAME") } else { // Inside Kotlin/jps directory (Kotlin plugin) - val libDirectory = File(PathUtil.getJarPathForClass(this::class.java)).parentFile.parentFile + val libDirectory = jpsPluginJar.parentFile.parentFile compilerPluginJar = File(libDirectory, JAR_FILE_NAME) } diff --git a/prepare/compiler/build.gradle.kts b/prepare/compiler/build.gradle.kts index 3202c6cc8d4..ae681e3cb6b 100644 --- a/prepare/compiler/build.gradle.kts +++ b/prepare/compiler/build.gradle.kts @@ -90,7 +90,6 @@ val packCompiler by task { configurations = listOf(fatJar) duplicatesStrategy = DuplicatesStrategy.EXCLUDE destinationDir = File(buildDir, "libs") - dependsOn(protobufFullTask) setupPublicJar("before-proguard") from(fatJarContents)