InvalidPluginException when running gradle

Hi team, I am very new to gradle so sorry if my question seems easy.
I am following this tutorial: Smithy Server and Client Generator for TypeScript (Developer Preview) | AWS DevOps Blog which shows how to use smithy.
Here is the repo they have in the project which I cloned: https://github.com/aws-samples/smithy-server-generator-typescript-sample.
After cloning, I ran the command

./gradlew build

But I am getting the following error:

Could not find implementation class 'software.amazon.smithy.gradle.SmithyPlugin' for plugin 'software.amazon.smithy' specified in jar:file:/Users/<my-user-folder>/.gradle/caches/jars-9/022b97b49ec9b69ec2bcb4f44810206a/FinplifyModel-0.6.0.jar!/META-INF/gradle-plugins/software.amazon.smithy.properties.

I think that this might be some caching issue because the jar mentioned in the error:

 FinplifyModel-0.6.0.jar!

Is not even part of this project. It is an old project I built on my machine couple of weeks ago. I am not sure why it’s cache is getting involved in this new project build.

Here is the build.gradle.kts for the FinplifyModel package that was built some weeks ago:

gradlePlugin {
    plugins {
        create("software.amazon.smithy") {
            id = "software.amazon.smithy"
            displayName = "Smithy Gradle Plugin"
            description = "This project integrates Smithy with Gradle. This plugin can build artifacts " +
                    "from Smithy models, generate JARs that contain Smithy models found in Java " +
                    "projects, and generate JARs that contain filtered *projections* of Smithy " +
                    "models."
            implementationClass = "software.amazon.smithy.gradle.SmithyPlugin"
        }
    }
}

pluginBundle {
    website = "https://github.com/awslabs/smithy"
    vcsUrl = "https://github.com/awslabs/smithy"
    tags = listOf("smithy", "api", "building")
}

Here is the build.gradle for the new project:


import software.amazon.smithy.gradle.tasks.SmithyBuild

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath "software.amazon.smithy.demo:string-wizard-model:1.0-SNAPSHOT";
        classpath "software.amazon.smithy.typescript:smithy-typescript-codegen:0.11.0";
        classpath "software.amazon.smithy.typescript:smithy-aws-typescript-codegen:0.11.0";
        classpath "software.amazon.smithy:smithy-model:1.19.0";
        classpath "software.amazon.smithy:smithy-openapi:1.19.0";
        classpath "software.amazon.smithy:smithy-aws-traits:1.19.0";
        classpath "software.amazon.smithy:smithy-aws-apigateway-openapi:1.19.0";
        classpath "software.amazon.smithy:smithy-cli:1.19.0";
    }
}

plugins {
    id "software.amazon.smithy"
}
dependencies {
    implementation "software.amazon.smithy:smithy-aws-traits:1.19.0"
    implementation "software.amazon.smithy:smithy-aws-apigateway-openapi:1.19.0"
    implementation "software.amazon.smithy.demo:string-wizard-model:1.0-SNAPSHOT"
}

repositories {
    mavenLocal()
    mavenCentral()
}

jar.enabled = false
smithyBuildJar.enabled = false

task generateServer(type: SmithyBuild) {}

build.dependsOn generateServer

Does anyone has an idea of what could be going wrong?

You declared in your FinplifyModel project that it contains / builds the plugin software.amazon.smithy.
Then you probably published it to mavenLocal which then also publishes the marker artifact software.amazon.smithy:software.amazon.smithy.gradle.plugin:<version> that is used to resolve plugin IDs to actual code artifacts.

That other project you try to build now has mavenLocal most probably also defined as plugin repository, so the plugin is resolved to your older project publication which then misses the class that is not there.

Actually using mavenLocal at all is a very bad idea as it is broken by design as also documented in the Gradle userguide. It should definitely not be used unconditionally and as first repository in the list and without content filter, that is very bad practice and can easily lead to a couple of more problems than you already hit.

Thanks, I was able to fix the issue by removing the mavenLocal and deleting all cache related to this

1 Like