Hi everyone, does anyone know how to publish a gra...
# gradle
g
Hi everyone, does anyone know how to publish a gradle plugin to an internal artifactory repository? I was able to upload the jar to it but I think it is missing some gradle metadata. My
build.gradle.kts
looks like this
Copy code
gradlePlugin {
    plugins {
        create("customPlugin") {
            id = "${project.group}.kotlin"
            implementationClass = "${project.group}.kotlin.KotlinPlugin"
        }
    }
}

publishing {
    publications {
        create<MavenPublication>("plugin") {
            from(components["kotlin"])
        }
    }
}

artifactory {
    setContextUrl("<https://internal.artifactory>")
    publish(closureOf<PublisherConfig> {
        repository(delegateClosureOf<GroovyObject> {
            val artifactoryUser: String? by rootProject
            val artifactoryKey: String? by rootProject
            setProperty("repoKey", "artifactoryRepoKey")
            setProperty("username", System.getenv("ARTIFACTORY_USERNAME") ?: artifactoryUser)
            setProperty("password", System.getenv("ARTIFACTORY_PASSWORD") ?: artifactoryKey)
            setProperty("maven", true)
        })
        defaults(delegateClosureOf<ArtifactoryTask> {
            publications("plugin")
            setPublishArtifacts(true)
            setProperties(mapOf("build.language" to "kotlin"))
        })
    })
}
correction, I was able to apply the plugin using the
buildscript {}
syntax but not the
plugins {}
one. Does anyone know why?
o
you need to publish the plugin markers, it's another maven publication. https://github.com/EngineHub/gradle-codecov-plugin/blob/master/build.gradle.kts#L108
g
It worked, thanks!!