Skip to content

Latest commit

 

History

History
87 lines (68 loc) · 3.96 KB

publishing-binaries-using-maven-publish-plugin.md

File metadata and controls

87 lines (68 loc) · 3.96 KB

Publishing binaries using maven-publish plugin

See also "How Shipkit Works" documentation index. Please help us with docs and submit a PR with improvements!

You have the code but your users need compiled and tested binaries so that they can use your code!

Intro

Shipkit will automatically publish binaries to Bintray repository. There is also an option to publish your artifacts to your internal Maven repository using Maven Publish Plugin.

Nitty gritty

Applying org.shipkit.java Gradle plugin will automatically apply org.shipkit.bintray plugin what is not expected in this case. Instead of applying org.shipkit.java you can apply following plugins in your build.gradle:

apply plugin: "java"
apply plugin: "maven-publish"
apply plugin: "org.shipkit.travis"
apply plugin: "org.shipkit.github-pom-contributors"
apply plugin: "org.shipkit.release-notes"
apply plugin: "org.shipkit.compare-publications"

Now you can configure maven-publish plugin as described in Maven Publish Plugin official documentation.

publishing {
    repositories {
        maven {
            credentials {
                username "your-user"
                password "your-password"
            }
            url "url-to-your-nexus"
        }
    }
}

You need also set a few task properties, e.g.:

tasks.updateReleaseNotes.publicationRepository = "https://bintray.com/shipkit/examples/basic/"
tasks.updateReleaseNotesOnGitHub.publicationRepository = "https://bintray.com/shipkit/examples/basic/"
tasks.downloadPreviousReleaseArtifacts.previousSourcesJarUrl = "customUrl" + tasks.fetchReleaseNotes.previousVersion + "-sources.jar"

The first two properties are for generating a badge like: Bintray (taken from Mockito) in release notes file and GitHub release page. This Badge can be a clickable link to the released version of your library in your Maven repository - you only need to set a proper link. Shipkit will add a version at the end of the link. If you can't expose a link to your repository you can set an empty string.

The last setting is similar, but it needs point to the previous released source jar. E.g. if shipkit-example version 0.16.22 is build Shipkit is trying to download previous jar from: https://bintray.com/shipkit/examples/download_file?file_path=org/mockito/shipkit-example/impl/0.16.21/impl-0.16.21-sources.jar. So you can build here a proper URL to the previous *-sources.jar. If you leave this setting empty, Shipkit will be not able to compare publications and will consider it as changed. More info about comparing publications in Avoiding unnecessary releases.

And the last necessary configuration:

allprojects {
    plugins.withId("maven-publish") {
        tasks.performRelease.dependsOn(tasks.publish)
    }
}

This means that performRelease task (from Shipkit) depends on all publish tasks (from maven-publish plugin).

Afterword

Shipkit for now doesn't support maven-publish plugin out of the box, because it wasn't a main goal at the beginning of the development. For now described hacks are needed to make it work with maven-publish plugin. Pull Request are welcome!

Thank you for reading! Questions or feedback? Start discussion by opening a ticket in GitHub!