Gradle plugin used to apply credential information defined in Maven config files to Maven repositories used in Gradle builds - both for upload and download
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)
See https://plugins.gradle.org/plugin/digital.fino.build.gradle-maven-auth for details on how to apply the plugin.
Applying the plugin does a number of things:
-
Creates an extension object
org.hibernate.build.publish.auth.maven.MavenRepoAuthExtension
and makes it available asmavenRepoAuth
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
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>
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
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'
}
}
}
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'
}
}
}