alexgorbatchev

Tuesday, November 8, 2016

Publishing Grails 3 plugins to Nexus Repository OSS using Gradle

To publish a Grails 3 plugin to Nexus Repository OSS is extremely simple because the necessary Gradle plugin is already included in the build.gradle file by default. Just add a publishing closure to the build.gradle file and you are ready to push to your private Nexus Repository OSS server.

As in the Grails application publishing example, the NEXUS_USERNAME and NEXUS_PASSWORD keywords are parameters that you store in gradle.properties and can overwrite with command line parameters, such as

** Edit **

Per Amad's comments, the grailsPublish closure may be required. I modified the attributes in the closure supplied by the create-plugin script as follows:

4 comments:

  1. can you share your full build.gradle, because in my build.gradle, i have

    apply plugin: "org.grails.grails-plugin-publish"

    and when i try to publish-plugin i get error saying i am missing grailsPublish closure.

    ReplyDelete
    Replies
    1. From the error message, it sounds like you deleted the default grailsPublish closure block. If that is the case, please try the grailsPublish block above and see if that resolves your issue. From looking at the source code, it appears that block is required even if you are not using it (https://github.com/grails/grails-core/blob/master/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsCentralPublishGradlePlugin.groovy).

      Delete
  2. Hi David,

    I did add the closure and the error goes away - however when i try to publish the generated POM has no dependencies included.

    ReplyDelete
    Replies
    1. Are all the dependencies you want included in the plugin specified with 'compile' or 'runtime'? Unfortunately, I don't have access to my build.gradle at the moment to post it.

      Delete