From: Samyak Jain <samyak.jn11@gmail.com>
Date: Sat, 11 Jul 2020 01:24:39 +0530
Subject: libraries//kotlin-gradle-plugin: Convert kts to groovy
Forwarded: not-needed
Last-Update: 2021-04-22

---
 libraries/tools/kotlin-gradle-plugin/build.gradle  | 161 ++++++++++++++++++
 .../tools/kotlin-gradle-plugin/build.gradle.kts    | 181 ---------------------
 2 files changed, 161 insertions(+), 181 deletions(-)
 create mode 100644 libraries/tools/kotlin-gradle-plugin/build.gradle
 delete mode 100644 libraries/tools/kotlin-gradle-plugin/build.gradle.kts

diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle b/libraries/tools/kotlin-gradle-plugin/build.gradle
new file mode 100644
index 0000000..4346945
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin/build.gradle
@@ -0,0 +1,161 @@
+//import org.jetbrains.dokka.gradle.DokkaTask
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+import org.jetbrains.kotlin.pill.PillExtension
+
+plugins {
+    id("java")
+	id("org.jetbrains.kotlin.jvm")
+	id("java-gradle-plugin")
+//    id("org.jetbrains.dokka")
+    id("jps-compatible")
+}
+
+//publish()
+
+// todo: make lazy
+def jar= tasks.jar
+
+ArtifactsKt.customRuntimeJar(project, EmbeddableKt.rewriteDepsToShadedCompiler(project, jar, {}), {})
+
+
+ArtifactsKt.customSourcesJar(project,"main",{})
+
+/*
+pill {
+    variant = PillExtension.Variant.FULL
+}
+*/
+
+dependencies {
+    compile project (":kotlin-gradle-plugin-api")
+    compile project (":kotlin-gradle-plugin-model")
+    compileOnly project (":compiler")
+    compileOnly project (":compiler:incremental-compilation-impl")
+    compileOnly project (":compiler:daemon-common")
+
+    compile(DependenciesKt.customKotlinStdlib(project,null))
+    compile project (":kotlin-native:kotlin-native-utils")
+    compileOnly project (":kotlin-reflect-api")
+    compileOnly project (":kotlin-android-extensions")
+    compileOnly project (":kotlin-build-common")
+    compileOnly project (":kotlin-compiler-runner")
+    compileOnly project (":kotlin-annotation-processing")
+    compileOnly project (":kotlin-annotation-processing-gradle")
+    compileOnly project (":kotlin-scripting-compiler")
+    compileOnly project (":kotlin-compiler-embeddable")
+
+    compileOnly("com.android.tools.build:gradle:2.0.0")
+    compileOnly("com.android.tools.build:gradle-core:2.0.0")
+    compileOnly("com.android.tools.build:builder:2.0.0")
+    compileOnly("com.android.tools.build:builder-model:2.0.0")
+    compileOnly("org.codehaus.groovy:groovy-all:2.4.12")
+    compileOnly(gradleApi())
+
+    compileOnly(IntellijDependenciesKt.customIntellijCoreDep(project)) { IntellijDependenciesKt.customIncludeJars(it,["intellij-core"],null) }
+
+    runtime (DependenciesKt.customProjectRuntimeJar(it,":kotlin-compiler-embeddable"))
+    runtime (DependenciesKt.customProjectRuntimeJar(it,":kotlin-annotation-processing-gradle"))
+    runtime (DependenciesKt.customProjectRuntimeJar(it,":kotlin-android-extensions"))
+    runtime (DependenciesKt.customProjectRuntimeJar(it,":kotlin-compiler-runner"))
+    runtime (DependenciesKt.customProjectRuntimeJar(it,":kotlin-scripting-compiler-embeddable"))
+    runtime project (":kotlin-reflect")
+
+    // com.android.tools.build:gradle has ~50 unneeded transitive dependencies
+    compileOnly("com.android.tools.build:gradle:3.0.0") { setTransitive(false) }
+    compileOnly("com.android.tools.build:gradle-core:3.0.0") { setTransitive(false) }
+    compileOnly("com.android.tools.build:builder-model:3.0.0") { setTransitive(false) }
+
+    testCompileOnly project(":compiler")
+    testCompile(DependenciesKt.customProjectTests(dependencies,":kotlin-build-common"))
+    testCompile project(":kotlin-android-extensions")
+    testCompile project(":kotlin-compiler-runner")
+//    testCompile project(":kotlin-test::kotlin-test-junit")
+    testCompile ("junit:junit:4.12")
+    testCompileOnly project(":kotlin-reflect-api")
+    testCompileOnly project(":kotlin-annotation-processing")
+    testCompileOnly project(":kotlin-annotation-processing-gradle")
+}
+
+tasks.withType(project.compileKotlin.class){
+        kotlinOptions.jdkHome = rootProject.ext["JDK_18"] as String
+        kotlinOptions.languageVersion = "1.2"
+        kotlinOptions.apiVersion = "1.2"
+        kotlinOptions.freeCompilerArgs += ["-Xskip-metadata-version-check"]
+
+   project.processResources {
+        def propertiesToExpand = [projectVersion : project.version]
+        propertiesToExpand.each {
+		expand -> inputs.property(expand.key, expand.value)
+        }
+        filesMatching("project.properties") {
+            expand("projectVersion" : project.version)
+        }
+    }
+
+    project.jar {
+		CommonUtilKt.customCallGroovy(project,"manifestAttributes", [manifest, project, "Main", true])
+    }
+
+    validateTaskProperties {
+        failOnWarning = true
+    }
+
+}
+
+TasksKt.customProjectTest(project, "test", {
+    it.executable = "${rootProject.ext["JDK_18"]}/bin/java"
+    it.dependsOn(validateTaskProperties)
+})
+
+/*
+pluginBundle {
+    fun create(name: String, id: String, display: String) {
+        (plugins).create(name) {
+            this.id = id
+            this.displayName = display
+            this.description = display
+        }
+    }
+
+    create(
+        name = "kotlinJvmPlugin",
+        id = "org.jetbrains.kotlin.jvm",
+        display = "Kotlin JVM plugin"
+    )
+//    create(
+//        name = "kotlinJsPlugin",
+//        id = "org.jetbrains.kotlin.js",
+//        display = "Kotlin JS plugin"
+//    )
+    create(
+        name = "kotlinMultiplatformPlugin",
+        id = "org.jetbrains.kotlin.multiplatform",
+        display = "Kotlin Multiplatform plugin"
+    )
+    create(
+        name = "kotlinAndroidPlugin",
+        id = "org.jetbrains.kotlin.android",
+        display = "Android"
+    )
+    create(
+        name = "kotlinAndroidExtensionsPlugin",
+        id = "org.jetbrains.kotlin.android.extensions",
+        display = "Kotlin Android Extensions plugin"
+    )
+    create(
+        name = "kotlinKaptPlugin",
+        id = "org.jetbrains.kotlin.kapt",
+        display = "Kotlin Kapt plugin"
+    )
+    create(
+        name = "kotlinScriptingPlugin",
+        id = "org.jetbrains.kotlin.plugin.scripting",
+        display = "Gradle plugin for kotlin scripting"
+    )
+    create(
+        name = "kotlinNativeCocoapodsPlugin",
+        id = "org.jetbrains.kotlin.native.cocoapods",
+        display = "Kotlin Native plugin for CocoaPods integration"
+    )
+}
+*/
diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts
deleted file mode 100644
index b9a675d..0000000
--- a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts
+++ /dev/null
@@ -1,181 +0,0 @@
-
-import org.jetbrains.dokka.gradle.DokkaTask
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-import org.jetbrains.kotlin.pill.PillExtension
-
-plugins {
-    java
-    kotlin("jvm")
-    `java-gradle-plugin`
-    id("org.jetbrains.dokka")
-    id("jps-compatible")
-}
-
-publish()
-
-// todo: make lazy
-val jar: Jar by tasks
-val jarContents by configurations.creating
-
-sourcesJar()
-javadocJar()
-
-repositories {
-    google()
-}
-
-pill {
-    variant = PillExtension.Variant.FULL
-}
-
-dependencies {
-    compile(project(":kotlin-gradle-plugin-api"))
-    compile(project(":kotlin-gradle-plugin-model"))
-    compileOnly(project(":compiler"))
-    compileOnly(project(":compiler:incremental-compilation-impl"))
-    compileOnly(project(":compiler:daemon-common"))
-
-    compile(kotlinStdlib())
-    compile(project(":kotlin-native:kotlin-native-utils"))
-    compileOnly(project(":kotlin-reflect-api"))
-    compileOnly(project(":kotlin-android-extensions"))
-    compileOnly(project(":kotlin-build-common"))
-    compileOnly(project(":kotlin-compiler-runner"))
-    compileOnly(project(":kotlin-annotation-processing"))
-    compileOnly(project(":kotlin-annotation-processing-gradle"))
-    compileOnly(project(":kotlin-scripting-compiler"))
-
-    compileOnly("com.android.tools.build:gradle:2.0.0")
-    compileOnly("com.android.tools.build:gradle-core:2.0.0")
-    compileOnly("com.android.tools.build:builder:2.0.0")
-    compileOnly("com.android.tools.build:builder-model:2.0.0")
-    compileOnly("org.codehaus.groovy:groovy-all:2.4.12")
-    compileOnly(gradleApi())
-
-    compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
-
-    runtime(projectRuntimeJar(":kotlin-compiler-embeddable"))
-    runtime(projectRuntimeJar(":kotlin-annotation-processing-gradle"))
-    runtime(projectRuntimeJar(":kotlin-android-extensions"))
-    runtime(projectRuntimeJar(":kotlin-compiler-runner"))
-    runtime(projectRuntimeJar(":kotlin-scripting-compiler-embeddable"))
-    runtime(project(":kotlin-reflect"))
-
-    jarContents(compileOnly(intellijDep()) {
-        includeJars("asm-all", rootProject = rootProject)
-    })
-
-    // com.android.tools.build:gradle has ~50 unneeded transitive dependencies
-    compileOnly("com.android.tools.build:gradle:3.0.0") { isTransitive = false }
-    compileOnly("com.android.tools.build:gradle-core:3.0.0") { isTransitive = false }
-    compileOnly("com.android.tools.build:builder-model:3.0.0") { isTransitive = false }
-
-    testCompileOnly (project(":compiler"))
-    testCompile(projectTests(":kotlin-build-common"))
-    testCompile(project(":kotlin-android-extensions"))
-    testCompile(project(":kotlin-compiler-runner"))
-    testCompile(project(":kotlin-test::kotlin-test-junit"))
-    testCompile("junit:junit:4.12")
-    testCompileOnly(project(":kotlin-reflect-api"))
-    testCompileOnly(project(":kotlin-annotation-processing"))
-    testCompileOnly(project(":kotlin-annotation-processing-gradle"))
-}
-
-runtimeJar(rewriteDepsToShadedCompiler(jar)) {
-    dependsOn(jarContents)
-
-    from {
-        jarContents.asFileTree.map {
-            if (it.endsWith(".jar")) zipTree(it) 
-            else it
-        }
-    }
-}
-
-tasks {
-    withType<KotlinCompile> {
-        kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String
-        kotlinOptions.languageVersion = "1.2"
-        kotlinOptions.apiVersion = "1.2"
-        kotlinOptions.freeCompilerArgs += listOf("-Xskip-metadata-version-check")
-    }
-
-    named<ProcessResources>("processResources") {
-        val propertiesToExpand = mapOf("projectVersion" to project.version)
-        for ((name, value) in propertiesToExpand) {
-            inputs.property(name, value)
-        }
-        filesMatching("project.properties") {
-            expand("projectVersion" to project.version)
-        }
-    }
-
-    named<Jar>("jar") {
-        callGroovy("manifestAttributes", manifest, project)
-    }
-
-    named<ValidateTaskProperties>("validateTaskProperties") {
-        failOnWarning = true
-    }
-
-    named<DokkaTask>("dokka") {
-        outputFormat = "markdown"
-        includes = listOf("$projectDir/Module.md")
-    }
-}
-
-projectTest {
-    executable = "${rootProject.extra["JDK_18"]!!}/bin/java"
-    dependsOn(tasks.named("validateTaskProperties"))
-}
-
-pluginBundle {
-    fun create(name: String, id: String, display: String) {
-        (plugins).create(name) {
-            this.id = id
-            this.displayName = display
-            this.description = display
-        }
-    }
-
-    create(
-        name = "kotlinJvmPlugin",
-        id = "org.jetbrains.kotlin.jvm",
-        display = "Kotlin JVM plugin"
-    )
-//    create(
-//        name = "kotlinJsPlugin",
-//        id = "org.jetbrains.kotlin.js",
-//        display = "Kotlin JS plugin"
-//    )
-    create(
-        name = "kotlinMultiplatformPlugin",
-        id = "org.jetbrains.kotlin.multiplatform",
-        display = "Kotlin Multiplatform plugin"
-    )
-    create(
-        name = "kotlinAndroidPlugin",
-        id = "org.jetbrains.kotlin.android",
-        display = "Android"
-    )
-    create(
-        name = "kotlinAndroidExtensionsPlugin",
-        id = "org.jetbrains.kotlin.android.extensions",
-        display = "Kotlin Android Extensions plugin"
-    )
-    create(
-        name = "kotlinKaptPlugin",
-        id = "org.jetbrains.kotlin.kapt",
-        display = "Kotlin Kapt plugin"
-    )
-    create(
-        name = "kotlinScriptingPlugin",
-        id = "org.jetbrains.kotlin.plugin.scripting",
-        display = "Gradle plugin for kotlin scripting"
-    )
-    create(
-        name = "kotlinNativeCocoapodsPlugin",
-        id = "org.jetbrains.kotlin.native.cocoapods",
-        display = "Kotlin Native plugin for CocoaPods integration"
-    )
-}
