GithubHelp home page GithubHelp logo

gunnarmorling / gradle-maven-publish-auth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hibernate/gradle-maven-publish-auth

0.0 3.0 0.0 209 KB

Gradle plugin for managing authentication of upload tasks

Groovy 9.14% Shell 15.48% Java 75.39%

gradle-maven-publish-auth's Introduction

Version 2.0

Gradle plugin facilitating publishing to authenticated Maven repositories without adding credential information directly in the build file or in random properties files. Support for applying authentication information from Maven's settings.xml file is provided out-of-the-box.

Applying plugin

To apply the plugin, simply specify:

apply plugin: 'maven-publish-auth'

The plugin class is org.hibernate.build.gradle.publish.auth.maven.AuthenticationManager, whose purpose is really just to create an instance each of

  • org.hibernate.build.gradle.publish.auth.maven.LegacyAuthenticationHandler
  • org.hibernate.build.gradle.publish.auth.maven.PublishingAuthenticationHandler

These handlers get attached to tasks of type org.gradle.api.tasks.Upload and org.gradle.api.publish.maven.tasks.PublishToMavenRepository, respectively.

But in either case, both ultimately delegate to any org.hibernate.build.gradle.publish.auth.maven.CredentialsProvider instances configured with the org.hibernate.build.gradle.publish.auth.maven.CredentialsProviderRegistry. Currently there is only one supported implementation, org.hibernate.build.gradle.publish.auth.maven.SettingsXmlCredentialsProvider which parses the Maven settings.xml file and makes those authentication credentials available to Gradle. This includes support for Maven "encrypted" passwords as outlined at http://maven.apache.org/guides/mini/guide-encryption.html.

By default, settings.xml is loaded from its default location (~/.m2/settings.xml). You can alter this by specifying -Dmaven.settings=your/path.

Support for the new Gradle Publication DSL

One of the new (and still ongoing and incubating) developments in Gradle is the new Publication DSL as the means for declaring how your project artifacts are pulished. See the Gradle UserGuide for more information.

The "bridge" between Maven authentication credentials and Gradle is the repository id. For an example, lets assume you have a Maven settings.xml that defines the following credentials:

<settings>
    <servers>
        <server>
            <id>dogdeball-repo</id>
            <username>average-joes</username>
            <password>dodgethis</password>
         </server>
    </servers>
</settings>

As you can see, we have credentials associated with a repository server with the identifier of "dogdeball-repo". This is the information we need supply in order for the plugin to make the connection. In the Publication DSL, this corelates to the name attribute of the repository configuration:

publishing {
    repositories {
        maven {
            name = 'dogdeball-repo'
            url 'http://repository.average.joes.com'
        }
    }
}

Support for legacy Gradle publishing (Upload task)

If you prefer to stick with the legacy publishing DSL, I have left support of that in place for the time being too. Again, the bridge is the repository id.

uploadArchives {
    repositories.mavenDeployer {
        ...
        repository(id: 'dogdeball-repo', url: 'http://repository.average.joes.com')
    }
}

gradle-maven-publish-auth's People

Contributors

sebersole avatar szpak avatar adammurdoch avatar

Watchers

Gunnar Morling avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.