``` mport org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.kotlin.gradle.tasks.KotlinCompil...
s
Copy code
mport 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"
    )
}
g
What kind error you have?
s
FAILURE: Build failed with an exception. * Where: Build file '/home/samyak/gsoc/kotlin/kotlin-1.3.30/kotlin-1.3.30/libraries/tools/kotlin-gradle-plugin/build.gradle' line: 60 * What went wrong: A problem occurred evaluating project ':kotlin-gradle-plugin'.
Could not find method projectRuntimeJar() for arguments [:kotlin-compiler-embeddable] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
runtime(projectRuntimeJar(":kotlin-compiler-embeddable"))
It couldn't parse this.
g
but this is build.gradle, not build.gradle.kts
I also dont’t think that projectRuntimeJar is something standard. It looks as some custom configuration
s
Yes, I tried to link it with the function call
runtime(Dependencieskt.projectRuntimeJar(":kotlin-compiler-embeddable"))
I checked the builtSrc files and I saw it is defined in dependencies.kt files.
g
It’s correct
s
Here:fun DependencyHandler.projectRuntimeJar(name: String): ProjectDependency = project(mapOf<String,String>> fun DependencyHandler.projectArchives(name: String): ProjectDependency = project(mapOf<String,String>(">
Copy code
fun customProjectTests(dependencyHandler:DependencyHandler,name: String): ProjectDependency {return dep>
fun customProjectRuntimeJar(dependencyHandler:DependencyHandler,name: String): ProjectDependency {retur>
Any sugesstion, how can we convert these? (If my question is feasible?)
g
I mean it’s feasable of course, but I think it’s the smallest problem which you possible could get by converting build system of huge project to 3 year old build system + converting all build config files 🤷‍♂️
s
Almost all the files are working fine now, it's just problem with kotlin-gradle-plugin-* (If I get this to build) we can upload kotlin into Debian.
Here's all the changes if you wanna take a quick look: https://salsa.debian.org/samyak-jn/kotlin-1.3.30/
g
What is the goal of bundling some custom build of Kotlin of old version to OS distribution?
s
Here's the case, The Gradle version present in Debian is 4.4.1, and rest higher version are heavily dependent on kotlin (therefore we need kotlin first to update the Gradle package). But On the way to package kotlin we encountered that we have to make it compatible to older gradle version, otherwise we will stuck in a circular dependencies.
g
Looks that
runtime(projectRuntimeJar(":kotlin-compiler-embeddable")
is the same as:
Copy code
runtime(project(path: ":kotlin-compiler-embeddable", configuration: "runtimeJar")
in Groovy
s
Once we are able to update gradle with this version of kotlin, we can update the kotlin with the newer gradle, hence making it consistent. (I hope I didn't confuse you :D)
g
Crazy stuff, one of the reason why it’s not always good idea to bundle something But I’m not really in OS development, probably it’s usual problem of OS distributions Good luck with it Try snippet above, it should be the same as this extension from Kotlin DSL
The Gradle version present in Debian is 4.4.1
But why do you depend on this Gradle version? Wouldn’t be possible just use Gradle wrapper, let it download required Gradle and build. The only real Gradle dependency is Java version, but you need also Java to build Kotlin anyway
s
> Project with path ':kotlin-compiler-embeddable' could not be found in project ':kotlin-gradle-plugin'.
It is not able to find it. I think we have to change the paths I guess 😕
No, we can't use graddle wrapper. The problem being, we can't upload prebuilt binaries (jar files et al) to the archive it's against the license. These binaries are generated within the package build system.
We can't use which fetch anything from upstream.
it’s not always good idea to bundle something
pretty much
g
think we have to change the paths I guess
Hmm, this is just a name of some of modules in the project
s
yes it exists in libraries/tools/kotlin-compiler-embeddable
I managed to remove one of the error the reason it wasn't building was because of it was removed from settings.gradle