I created a gradle plugin in kotlin but I cant see...
# gradle
d
I created a gradle plugin in kotlin but I cant seem to get it working. When the I compile the plugin to a jar and use it in another project to test it I get
Build cache type 'com.drost.buildcache.minio.MinioPlugin' has not been registered.
I have the gradle-plugins file in meta inf with
implementation-class=com.drost.buildcache.minio.MinioPlugin
which I set with the
java-gradle-plugin
b
Is your setup similar to the
gradle-plugin
sample? https://github.com/gradle/kotlin-dsl/tree/develop/samples/gradle-plugin
d
I dont have a consumer project to that uses the plugin
b
When … I … use it in another project to test it
That would be the consumer, right?
I’m not very familiar with the BuildCache API internals but I think the registration is happening too late:
buildCache.registerBuildCacheService(MinioBuildCache::class.java, MinioBuildCacheServiceFactory::class.java
That has to happen during initialization (
settings.gradle
time)
d
Copy code
buildscript {

    dependencies {
        classpath files('libs/minio-buildcache-1.0-SNAPSHOT.jar')
    }
}

apply plugin: 'com.drost.minio-buildcache'
this is in the test project in the
settings.gradle
b
That won’t bring its dependencies such as
io.minio:minio:3.0.10
Because there’s no metadata, just a jar
Publish the plugin to a local repository
Then add the local repository to the
buildscript
in the consuming project
Plus
jcenter()
If it continues to fail, run the build with
--debug
d
will try that tomorrow thx for the help
b
Sure thing, let me know how it goes
d
Okay I published the plugin to the local maven repo and no the plugin gets initialized but I still the following error.
Copy code
* Where:
Settings file '/Users/dylan/projects/buildcachetest/settings.gradle' line: 20

* What went wrong:
A problem occurred evaluating settings 'buildcachetest'.
> Could not generate a proxy class for class com.drost.gradle.buildcache.minio.MinioBuildCache.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at <https://help.gradle.org>
Copy code
settings.gradle
buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }

    dependencies {
        classpath 'com.drost.gradle:minio-buildcache:1.0-SNAPSHOT'
    }
}

apply plugin: 'com.drost.gradle.minio-buildcache'

ext.isCiServer = System.getenv().containsKey("CI")

buildCache {
    local {
        enabled = !isCiServer
    }
    remote(com.drost.gradle.buildcache.minio.MinioBuildCache) {
        endpoint='****'
        accessKey='****'
        secretKey='****'
        bucket='test-gradle'
    }
}

rootProject.name = 'buildcachetest'
Figured it out
com.drost.gradle.buildcache.minio.MinioBuildCache
need to be marked as an open class so gradle can extend the class
b
👍