Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin DSL does not compile with Gradle 5.0-rc-3 #274

Closed
credmond-git opened this issue Nov 16, 2018 · 1 comment · Fixed by #275
Closed

Kotlin DSL does not compile with Gradle 5.0-rc-3 #274

credmond-git opened this issue Nov 16, 2018 · 1 comment · Fixed by #275
Labels
gradle compatibility Compatibility issues with Gradle

Comments

@credmond-git
Copy link

credmond-git commented Nov 16, 2018

I am building with the new Kotlin DSL and it works fine on
gradle-4.10.2
but when i switch to
gradle-5.0-rc-3
it fails with the following error:

FAILURE: Build failed with an exception.

  • Where:
    Build file 'D:\repo\cls\kotlin.poc\build.gradle.kts' line: 76

  • What went wrong:
    class com.google.protobuf.gradle.ProtobufConfiguratorExtsKt$plugins$1 tried to access private method org.gradle.kotlin.dsl.NamedDomainObjectContainerScope.(Lorg/gradle/api/NamedDomainObjectContainer;)V (com.google.protobuf.gradle.ProtobufConfiguratorExtsKt$plugins$1 is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @63d58557; org.gradle.kotlin.dsl.NamedDomainObjectContainerScope is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @4cc0edeb)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Here is my whole settings.gradle.kts file:

pluginManagement{
    repositories {
        mavenLocal()
        maven("https://plugins.gradle.org/m2/")
    }
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == "com.google.protobuf") {
                useModule("com.google.protobuf:protobuf-gradle-plugin:${requested.version}")
            }
        }
    }
}
rootProject.name = "com.ea.kotlin.poc"

and my build.gradle.kts file:

import com.google.protobuf.gradle.*
import org.gradle.kotlin.dsl.provider.gradleKotlinDslOf

plugins {
    java
    idea
    application
    kotlin("jvm") version "1.3.10"
    id("com.google.protobuf") version "0.8.7"
}

group = "KotlinPOC"
version = "1.0-SNAPSHOT"

application {
    mainClassName = "kotlin.poc.main"
}

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

repositories {
    mavenCentral()
    jcenter()
    listOf("http://dl.bintray.com/kotlin/kotlin-eap",
        "https://dl.bintray.com/kotlin/ktor",
        "https://dl.bintray.com/kotlin/kotlinx",
        "https://plugins.gradle.org/m2/")
        .forEach { maven { url = uri(it) }
        }
}

val kotlinVersion = "1.3.10"

val ktorVersion = "1.0.0-rc"
val junitVersion = "5.3.1"
val grpcVersion = "1.15.1"
val protobufVersion = "3.6.1"
val log4j2Version = "2.11.1"


dependencies {
    compile(kotlin("stdlib-jdk8"))
    compile("io.ktor:ktor-server-netty:${ktorVersion}")
    compile("io.ktor:ktor-html-builder:${ktorVersion}")

    compile("com.google.protobuf:protobuf-java:${protobufVersion}")
    compile("io.grpc:grpc-netty:${grpcVersion}")
    compile("io.grpc:grpc-protobuf:${grpcVersion}")
    compile("io.grpc:grpc-stub:${grpcVersion}")
    compile("com.zaxxer:HikariCP:3.2.0")

    runtime("mysql:mysql-connector-java:8.0.13")
    if (JavaVersion.current().isJava9Compatible) {
        // Workaround for @javax.annotation.Generated
        // see: https://github.com/grpc/grpc-java/issues/3633
        compile("javax.annotation:javax.annotation-api:1.3.1")
    }

    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1")

    implementation("org.apache.logging.log4j:log4j-api:${log4j2Version}")
    implementation("org.apache.logging.log4j:log4j-core:${log4j2Version}")

    testCompile("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}

protobuf {
    protoc {
        // The artifact spec for the Protobuf Compiler
        artifact = "com.google.protobuf:protoc:3.6.1"
    }
    plugins {
        // Optional: an artifact spec for a protoc plugin, with "grpc" as
        // the identifier, which can be referred to in the "plugins"
        // container of the "generateProtoTasks" closure.
        id("grpc") {
            artifact = "io.grpc:protoc-gen-grpc-java:1.15.1"
        }
    }
    generateProtoTasks {
        ofSourceSet("main").forEach {
            it.plugins {
                // Apply the "grpc" plugin whose spec is defined above, without
                // options.  Note the braces cannot be omitted, otherwise the
                // plugin will not be added. This is because of the implicit way
                // NamedDomainObjectContainer binds the methods.
                id("grpc")
            }
        }
    }
}
@marcoferrer
Copy link
Contributor

marcoferrer commented Nov 16, 2018

Thanks for reporting this. I figured there would need to be changes to the api as Gradle 5.0 started nearing release. It looks like there have been some visibility changes between 4.10.2 and the latest rc. I’ll try to submit pr for updating the kotlin dsl version soon

@zhangkun83 zhangkun83 added the gradle compatibility Compatibility issues with Gradle label Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gradle compatibility Compatibility issues with Gradle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants