Java Gradle Plugin Publication Names

plugins

(Alex) #1

I am trying to convert a plugin to use the new plugin mechanism and I use Artifactory.

The way i do my publishing (maybe this could be improved) is

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}

artifactoryPublish {
    dependsOn jar
    publications('mavenJava')
}

I think all i need to do is add the gradlePlugin publication to the artifactoryPublish but I can’t find anywhere what that might be called. Here is my gradlePlugin section

gradlePlugin {
    plugins {
        myPlugin {
            id = "my.plugin"
            implementationClass = "my.plugin.Class"
        }
    }
}

i’ve tried gradlePlugin & myPlugin but i get a warning from artifactory plugin saying 'Publication named ‘blah’ does not exist.

The plugin descriptors are being generated and are correct because when i do tasks.build.dependsOn tasks.publishToMavenLocal it all seems to get generated.


(Alex) #2

TL;DR

artifactoryPublish {
    dependsOn jar
    doLast {
        publications('mavenJava', '<myPlugin>PluginMarkerMaven')
    }
}

should match the name of your closure inside gradlePlugins { plugins { myPlugin

After locating the artifactory source code I was able to create a task to list the available plugins in my project.

task show << {
    project.extensions.findByType(PublishingExtension.class).getPublications().each {println it.name}
}