How to upgrade version on sibling dependent module using Maven Plugin Version

I have a problem updating the dependent version of dependent sibling projects.

My simplified project setup is as follows.

root
|--parent
|--tool-core
|--tool
|--functional-tests

The parent project contains all global properties and dependency management. Function tests depend on the tool, and the tool depends on the tool core. Root agents pom.xml(determines whether functional tests are enabled), and the parent project is the parent for all projects. I do not know if this is trivial, but the parent is not included in the aggregation, although it is already the parent for each child project.

Now my problem is that I am changing the version of the tool with versions:set. The version of the tool has been changed, but there is no dependence on this tool. How should I do it? I already tried more or less randomly to use other goals, and I tried to read the manual.

I have already tried using the section <dependencyManagement>and using the property for the version in the parent, but they are not updated in the new version.

Any help really appreciated.

Adding

I get the message "Ignoring the dependence of the reactor: com.tool: tool: jar: null: 1.2.3" in the best case. This is when I try versions:use-latest-releases. However, it versions:display-dependency-updatesshows that there is an update of "local dependency" (functional tests depend on the tool).

Update

, Maven , , , . , .

, . , .

. functional-tests tool parent. tool-core, tool.

<groupId>com.somecompany</groupId>
<artifactId>x-reactor</artifactId>
<packaging>pom</packaging>
<version>1.0</version>

<profiles>
    <profile>
        <id>cli</id>
        <modules>
            <module>tool</module>
        </modules>
    </profile>
    <profile>
        <id>deploy</id>
        <modules>
            <module>tool</module>
            <module>functional-tests</module>
        </modules>
    </profile>
</profiles>

:

<groupId>com.somecompany</groupId>
<artifactId>x-parent</artifactId>
<packaging>pom</packaging>
<version>1.0</version>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.somecompany</groupId>
            <artifactId>tool</artifactId>
            <version>3.2.3</version>
        </dependency>
    </dependencies>
</dependencyManagement>

:

<parent>
    <groupId>com.somecompany</groupId>
    <artifactId>x-parent</artifactId>
    <version>1.0</version>
    <relativePath>../parent/pom.xml</relativePath>
</parent>

<groupId>com.somecompany</groupId>
<artifactId>tool</artifactId>
<packaging>jar</packaging>
<version>3.2.3</version>

:

<parent>
    <groupId>com.somecompany</groupId>
    <artifactId>x-parent</artifactId>
    <version>1.0</version>
    <relativePath>../parent/pom.xml</relativePath>
</parent>

<groupId>functional-tests</groupId>
<artifactId>functional-tests</artifactId>
<version>0.1</version>
<packaging>pom</packaging>

<dependencies>
    <dependency>
        <groupId>com.somecompany</groupId>
        <artifactId>tool</artifactId>
    </dependency>
</dependencies>
+3
2

-, versions:use-latest-versions , , pom.xml. , . , , . , () , , . , .

script :

#!/bin/bash

if [[ $# -lt 1 ]]; then
    echo "Usage: $0 [version number]"
    exit 1
fi

function revert_version() {
    mvn -Pall versions:revert > /dev/null
    echo "ERROR: Failed updating the version"
    cat mvn_out.txt
    exit 1
}

v=$1
profile=cli
echo "Updating the version to $v..."
mvn -P$profile versions:set -DnewVersion=$v -DartifactId=tool -q
[ $? -eq 0 ] || revert_version

echo "Building the tool..."
mvn -P$profile install > /dev/null
[ $? -eq 0 ] || revert_version

echo "Updating the dependencies..."
mvn versions:use-latest-versions -Dincludes=com.somecompany:* -f parent/pom.xml -q
[ $? -eq 0 ] || revert_version
mvn -Pall versions:commit -q
[ $? -eq 0 ] || revert_version
+2

"-" , ( ?) " excludeReactor = false"!: -)

+6

Source: https://habr.com/ru/post/1762407/


All Articles