How to publish custom gradle plugin to private nexus

plugins

(Björn Pipiorke) #1

Hi,

I wrote a custom gradle java based plugin for gradle version 4.5.1 and I try to publish it to a private nexus via the new gradle publish plugin.

// gradle plugin configuration 
group = 'com.mycompany.gradle'
gradlePlugin {
  plugins {
    MyGradlePlugin {
      id = 'com.mycompany.gradle.myFirstPlugin'
      implementationClass = 'com.mycompany.gradle.myFirstPlugin.GradlePlugin'
    }
  }
}

// and configuring the plugin task

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            credentials {
                username "$nexusUsername"
                password "$nexusPassword"
            }

            if(project.version.endsWith('-SNAPSHOT')) {
                url "${nexusUrl}${relativePathSnapshots}"
            } else {
                url "${nexusUrl}${relativePathReleases}"
            }
        }
    }
}

During the build I can see that there are 3 poms generated
build/publications/pluginMaven/pom-default.xml
build/publications/mavenJava/pom-default.xml
build/publications/MyPluginNameMarkerMaven/pom-default.xml

Where the pluginMaven and the mavenJava pom are equal.
So during the publish tasks it trys to upload the artefact twice, which is by default disabled for releaseRepositories in our nexus.

So I think I have misconfigured the publish task.
I’m not sure how the java-gradle-plugin and the publish plugin work together and how to configure the pom generation.

Can somebody point me in the right direction?


(Björn Pipiorke) #2

Solved it by myself, this block makes the trouble, just deleting it and it works :wink: