mark-vieira / gradle-maven-settings-plugin

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

Trouble applying the plugin to multi module project. #16

Open LucasRouckhout opened 6 years ago

LucasRouckhout commented 6 years ago

Long story short I use the maven-settings plugin so that I can instruct my gradle builld to use the repositories and credentials in the settings.xml file configured in the different Jenkins slaves we use. This works fine in single module projects but I have an issues with applying it to a multi module project.

I'm using gradle 4.6 and applying the plugin with the plugins block.

plugins {
    id "net.linguica.maven-settings" version "0.5" apply true
}

allprojects {
...
}

subprojects {
...
}

mavenSettings {
    userSettingsFileName "$System.env.HOME/.m2/settings.xml"
}
// Leaving this out gives the same error (thus using the default path to the settings file).

Running ./gradlew assemble causes the first module to throw a: Cannot resolve external dependency ... because no repositories are defined. for all my dependencies. These projects come from both in house nexus repo's and the maven central repository.

I know this is a problem with the plugin since removing it and manually adding the repo's runs the build just fine. This is not an option though since I need the credentials in the settings.xml file for publishing artifacts.

Am I being an idiot for missing something? Or have other people encountered the same issue.

cwensel commented 6 years ago

I have a multi-module project also, and the values in settings.xml are not honored as well.

really unsure if this is the issue or not, but additional log messages may help to diagnose.

mark-vieira commented 6 years ago

@LucasRouckhout @cwensel if you are using a multi-project build you need to apply the plugin (and configure it) on all subprojects, not just the root project. Something like this:

plugins {
    id "net.linguica.maven-settings" version "0.5" apply false
}

allprojects {
    apply plugin: "net.linguica.maven-settings"

    mavenSettings {
        userSettingsFileName "$System.env.HOME/.m2/settings.xml"
    }
}