Skip to content

NoClassDefFoundError when applying Gradle plugin from Gradle Plugin Portal #112

@gabrielhuff

Description

@gabrielhuff

How to reproduce

The following minimal build.gradle:

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.61'
    id "com.google.protobuf" version "0.8.12"
    id "com.github.marcoferrer.kroto-plus" version "0.6.1"
    id "idea"
}

krotoPlus {
    config {
        main {}
    }
}

Will throw an exception (I'm using Gradle 5.6). Specifically, running this:

$ ./gradlew

Will throw this:

...
Caused by: java.lang.NoClassDefFoundError: com/google/protobuf/MessageOrBuilder
        at com.github.marcoferrer.krotoplus.gradle.compiler.CompilerConfigWrapper.<init>(CompilerConfigWrapper.kt:46)
        at com.github.marcoferrer.krotoplus.gradle.KrotoPlusPluginExtension$config$1.create(KrotoPlusPluginExtension.kt:31)
        at com.github.marcoferrer.krotoplus.gradle.KrotoPlusPluginExtension$config$1.create(KrotoPlusPluginExtension.kt:26)
        at org.gradle.api.internal.FactoryNamedDomainObjectContainer.doCreate(FactoryNamedDomainObjectContainer.java:106)
 ...

What fixes it

Getting the buildscript dependency from maven central instead of the Gradle plugin portal will fix the problem:

buildscript { // <-- add this
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.github.marcoferrer.krotoplus:kroto-plus-gradle-plugin:0.6.1"
    }
}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.61'
    id "com.google.protobuf" version "0.8.12"
    id "idea"
}

apply plugin: 'com.github.marcoferrer.kroto-plus' // <-- and this

krotoPlus {
    config {
        main {}
    }
}

Why this is happening

The plugin has a runtime dependency to com.google.protobuf:protobuf-java:3.9.0, which is not available on the Gradle Plugin Portal.


I just discovered this repo. You've done an amazing job! I've heard that Google is working on an official Kotlin API, but honestly it's going to be hard for them to catch up to this project :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions