grailsgrails-plugingrails-3.0

How do I publish a grails 3 plugin to my local nexus repo?


Running grails publish-plugin doesn't seem to do anything, and the only documentation I could find was about publishing to bintray.

[edit:]

I can publish the plugin via gradle publish, but wondered if there was a grails-y way to do it, and wonder what grails publish-plugin actually does :/


Solution

  • I figured it out with help from Ryan Vanderwerf at http://rvanderwerf.blogspot.com/2015/07/how-to-publish-grails-3-plugin.html who writes that there are a bunch of spring-boot dependencies that don't have versions in them and that causes gradle to freak out. To workaround it, strip out all dependencies in the pom that doesn't have versions:

    publishing {
        publications {
            mavenJar(MavenPublication) {
                pom.withXml {
                    def pomNode = asNode()
                    pomNode.dependencyManagement.replaceNode {}
    
                    // simply remove dependencies without a version
                    // version-less dependencies are handled with dependencyManagement
                    // see https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/8 for more complete solutions
                    pomNode.dependencies.dependency.findAll {
                        it.version.text().isEmpty()
                    }.each {
                        it.replaceNode {}
                    }
                }
                from components.java
            }
        }
        repositories {
            maven {
                credentials {
                    username "username"
                    password "password"
                }
                url "http://localhost/repo"
            }
        }
    }
    

    then you can use grails publish-plugin or gradle publish to publish your plugin

    related SO question: Grails 3 - How to publish to Artifactory