mark-vieira / gradle-maven-settings-plugin

Gradle Maven settings plugin
Apache License 2.0
60 stars 27 forks source link

Plugin is not compatible with repositories in dependencyResolutionManagement #27

Open nnegi79 opened 1 year ago

nnegi79 commented 1 year ago

When migrating repository declaration to settings.gradle, maven authentication to Azure Artifact Feed for downloading maven dependency package stop working.

Steps to replicate the issue:

01) Comment repository declaration from build.gradle file ... plugins { id “net.linguica.maven-settings” version “0.5” } ... / allprojects { repositories { maven { url ‘[https://pkgs.dev.azure.com/XYZ/_packaging/My-demo-Feed/maven/v1’] name ‘My-demo-Feed’ authentication { basic(BasicAuthentication) } } } } / ...

02) No changes done on app/build.gradle

… … apply plugin: ‘net.linguica.maven-settings’ …

03) Updated settings.gradle file to centralize the repositories without using cross-project configuration,

include ‘:app’

dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories {

maven { url ‘https://pkgs.dev.azure.com/Suchkan/_packaging/My-demo-Feed/maven/v1’ name ‘My-demo-Feed’ authentication { basic(BasicAuthentication) } }

} }

04) Here is the exception, Could not resolve all dependencies for configuration ‘:app:ktlint’. You cannot configure authentication schemes for this repository type if no credentials are provided.

Can you let me know how to make this plugin working with dependencyResolutionManagement.

thiemf commented 1 year ago

Hello,

ran into the same issue. It seems this plugin is only adjusting the credentials of the repositories declared under repositories in the project in build.gradle, see: https://github.com/mark-vieira/gradle-maven-settings-plugin/blob/1b0ea218088f4e0a8d9a82ad4918eca697cee867/src/main/groovy/net/linguica/gradle/maven/settings/MavenSettingsPlugin.groovy#L64

So it wouldn't work with the repositories under dependencyResolutionManagement.repositories in settings.xml.

So I declared repositories directly in the build.gradle and it started working 🤷‍♂️