Hello guys, I have a Kotlin-JVM lib published on B...
# gradle
d
Hello guys, I have a Kotlin-JVM lib published on Bintray ( let’s call it
myLib
) and a Gradle plugin. Plugin got
myLib
as dependency and
example
is using the Plugin, but I got
Copy code
> Failed to apply plugin [id 'studio.forface.easy-publish']
   > Could not create an instance of type studio.forface.easygradle.publish.EasyPublishExtension.
      > Could not generate a decorated class for type EasyPublishExtension.
         > studio/forface/easygradle/internal/ConfigReadWriteProperty
ConfigReadWriteProperty
is part of
myLib
and
EasyPublishExtension
is something like:
Copy code
abstract class EasyPublishExtension @Inject constructor(project: Project) {

    var username by project("", propertyName = "bintray.user")
    
    private operator fun <T : Any> Project.invoke(
        default: T,
        propertyName: String? = null,
        envName: String? = null
    ) = object : ConfigReadWriteProperty<EasyPublishExtension, T>(
    ....

}
What is the problem here?
n
does it work if you remove
project
from the extension constructor?
d
I think that’s not the problem, I followed this template https://github.com/cortinico/kotlin-gradle-plugin-template/blob/master/plugin-build/plugin/src/main/java/com/ncorti/kotlin/gradle/template/plugin/TemplateExtension.kt And error explicitly mention
studio/forface/easygradle/internal/ConfigReadWriteProperty
👌 1
n
i see. how are you instantiating the extension? can you post a full stacktrace?
d
Ouch. There’s a ClassNotFoundException actually
Here’s my full code, if can help https://github.com/4face-studi0/EasyGradle/tree/2.0
n
in which project is the plugin?
and in which project is the error?
d
example
n
how does sample include the plugin?
d
Actually from Gradle Portal
( sorry for late replies, for some reason I don’t get notifications )
n
ah, so it is already published to gradle portal? is the library project that the sample depends on also published there?
d
*the plugin depends on Yes, it is published - I was not able to test it locally, it is my first Plugin, it was shipped as a library intended to be included in buildSrc, and it was working properly, so I was too confident 🙂 - The library it depends on is on Bintray
n
it seems like you are using the dsl project as both an included build and using the jar directly. it is not published to bintray from what i can see
🙏 1
i would recommend making
dsl
a part of the plugin module first and then try separating it later
i would also recommend following the structure of Nicola Corti's project
d
Oh yes, you're right! I've included it as a jar! That's the reason! That's not exactly what I wanted to do, I've just not been able to include as conventional way
Copy code
implementation(project(":dsl"))
Is there any way to achieve that? Also what's the difference in my structure? 🤔
n
your example/sample is a composite build, whereas in Nicola's project it is a regular part of the build.
d
Before the publishing was included there, now I'm separating and shipping as regular plugin, regarding the publishing side
your example/sample is a composite build, whereas in Nicola's project it is a regular part of the build.
I did in that way just because I wanted to showcase also how to use
dsl
, by including it in its buildSrc. But I think that's not a big issues, as I would use the plugin in a completely different project 🙂
FYI: replaced the jar with the version from Bintray and it works flawlessly 🙂 Thank you
👍 1