mavenpom.xmlmaven-plugindependency-managementparent-pom

Does maven dependecyManagement impact pluginManagement transitive dependencies?


I understand that <dependencyManagement> config impacts to <dependencies> and transitive dependencies there. But also affects plugins under <pluginManagement> or <plugins>?

I have a case where is not happening, but just want to confirm if is a general behavior or something is wrong in my config.

Let's say that I need to use the-plugin, that has as dependency dep-a:1.0. But I need to make that the-plugin uses dep-a:1.1 instead.

Is the following pom correctly configured to achieve this?

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>group-a</groupId>
                <artifactId>dep-a</artifactId>
                <version>1.1</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>group-plugin</groupId>
                    <artifactId>the-plugin</artifactId>
                    <version>1.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

I tested the above pom but is not working, I had to do the following to make it work as I need. Is this the correct configuration?

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>group-a</groupId>
                <artifactId>dep-a</artifactId>
                <version>1.1</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>group-plugin</groupId>
                    <artifactId>the-plugin</artifactId>
                    <version>1.0</version>
                    <dependencies>
                        <dependency>
                            <groupId>group-a</groupId>
                            <artifactId>dep-a</artifactId>
                            <version>1.1</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

Solution

  • The dependencyManagement is intended for dependencies of your project and NOT for dependencies of plugins. These are two different things.

    In other words the given dependencyManagement can not influence the dependency of a plugin.

    If a plugin needs a different version there are the following options: