Skip to content

Gradle plugin for managing authentication to maven repositories

Notifications You must be signed in to change notification settings

fino-digital/gradle-maven-auth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Repository Auth Plugin for Gradle

Gradle plugin used to apply credential information defined in Maven config files to Maven repositories used in Gradle builds - both for upload and download

Why this fork?

The original repository has been neglected by the owner and not received any updates for more than 3 years, pull requests do not recieve any feedback.

This fork brings these changes over the original:

  • use JVM 17 in the code, the updated plugin also requires Java 17

  • all dependencies have been updated to latest version

  • for projects that do not publish any artifacts now work with this plugin without also applying the publishing plugin.

  • remove support for legacy "maven" plugin (removed with gradle 7)

Applying plugin

Applying the plugin does a number of things:

  • Creates an extension object org.hibernate.build.publish.auth.maven.MavenRepoAuthExtension and makes it available as mavenRepoAuth for configuration of the plugin behavior. At the moment it just exposes the list of credential providers. Projects could theoretically add additional credential providers, but such use is not supported

  • Finds all maven repository definitions in the project and applies the "matching" credentials. A match is determined based on the name used in the Gradle build and the server id in the Maven config

Examples

Let’s assume we use a Maven repository located at the URL http://repository.average.joes.com and that this repo is password protected. Our Maven settings.xml file contains:

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

Downloads

To download artifacts from the repository, we configure it in the Gradle build like so:

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

Because the name applied to the repo in the Gradle build matches the id of the server as configured in the Maven settings.xml the plugin will apply the credentials from the Maven settings

Publishing

Gradle also defines a proper DSL for "publications", which is also supported by the plugin:

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

Limitations

The plugin does not yet work with buildscript repositories. In the following case, the credentials will not get applied:

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

Gradle Wrapper

To upgrade Gradle Wrapper to a new version, run

sh ./gradlew wrapper --gradle-version NEW_VERSION

About

Gradle plugin for managing authentication to maven repositories

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%