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

3

8

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 :/

Snuffbox answered 12/1, 2016 at 23:54 Comment(0)
S
7

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

Snuffbox answered 13/1, 2016 at 19:23 Comment(1)
the solution works for me. At result it show 403 error. But in artifactory all files are presentedSatisfy
I
1

In Grails 3.0.11, I use the gradle target publishToMavenLocal for my local development. There is also another target publishMavenPublicationToMavenRepository. This seems to come from the gradle plugin:

apply plugin: 'maven-publish'

Seems to be in the standard plugin build.gradle.

(Edit: Adding notes on using local maven).

After re-reading your question and comment below, I don't think that is what you are looking for. It sounds like you want a normal publish to a repository on your system. publishMavenPublicationToMavenRepository may handle that. What I described above is using the local Maven cache to hold a snapshot of a plugin that you can use on your machine in an application.

This works for me when developing a plugin used in my application.

I did not create a local repository. The gradle plugin above (maven-publish) has a task publishToMavenLocal that will publish the Grails plugin to the local maven cache for local development.

It stores the plugin's .zip file in the .m2 cache directory:

C:\Users\xyz\.m2\repository\org\whatever\plugins\pluginName\0.3-SNAPSHOT

Then, you can use the plugin in a Grails application on your machine.

Insouciant answered 13/1, 2016 at 15:38 Comment(0)
I
-3

In grails 2.x BuildConfig.groovy

grails.project.dependency.distribution = {
    remoteRepository(id: '<repo name>',    url: '<url to your nexus repo>')
}

Then:

grails clean

grails compile 

grails maven-deploy --repository=repo name

In grails 3.x+:

buildscript {
    repositories {
        mavenLocal()
        ...
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
    }
}
publishing {
    repositories {
        maven {
            credentials {
                username "xyz"
                password "xyz"
            }
            url "http://example.com/nexus/content/repositories/nfb"
        }
    }
}

and finally

gradle publish

Illdefined answered 13/1, 2016 at 11:35 Comment(1)
grails 3 does not have a BuildConfig.groovySnuffbox

© 2022 - 2024 — McMap. All rights reserved.