Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Goal Proposal]: add-mdep to add or update dependencies into the dependencyManagement XML tag #21

Open
dearrudam opened this issue Apr 8, 2023 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed proposal Idea proposal question Further information is requested
Milestone

Comments

@dearrudam
Copy link
Contributor

dearrudam commented Apr 8, 2023

What is the purpose of the new goal?

Today, the add-dep add or update dependencies into the default profile, which means, into the project/dependencies XML node.

Many projects are managing their dependencies by using the project/dependencyManagement/dependencies XML nodes and then they're declaring the dependencies at project/dependencies XML nodes as needed.

Let's create a new goal called add-mdep to add or update managed dependencies to the project/dependencyManagement/dependencies XML node.

What is the expected behavior and output of the new goal?

Goal syntax:

$ mvn pom-editor:add-mdep -Dgav=<DEPENDENCY COORDINATES> -Dscope=<SCOPE> -Dtype=<TYPE> -Dclassifier=<CLASSIFIER>

New inputs:

Property Description
gav define the dependency to be add/update following the pattern groupId:artifactId:version
scope define the scope for the given dependency. Default value is compile. Must follow the default Maven Dependency Scope
type define the dependency type. Default value is jar
classifier define the dependency classifier. Default value is empty

⚠️ Warning

This execution causes a side-effect into the target POM, then the backup process must keeping working.

Expected behavior and outcomes:

Scenario 01:

  • Given the necessity to add or update a given dependency into a given POM without the dependencyManagement/dependencies XML node defined
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.github.arrudalabs</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</project>
  • When the add-mdep goal is executed with a given dependency
$ mvn pom-editor:add-mdep -Dgav='a:a:1.0'
  • Then the add-mdep goal should add or update the given dependency into the project/dependencyManagement/dependencies XML node from the target profile;
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.github.arrudalabs</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>a</groupId>
                <artifactId>a</artifactId>
                <version>1.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

Scenario 02:

  • Given the necessity to add or update a given dependency into a given POM with the dependencyManagement/dependencies XML node defined already
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.github.arrudalabs</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>b</groupId>
                <artifactId>b</artifactId>
                <version>3.4</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>
  • When the add-mdep goal is executed with a given dependency
$ mvn pom-editor:add-mdep -Dgav='a:a:1.3'
  • Then the add-mdep goal should add or update the given dependency into the project/dependencyManagement/dependencies XML node from the target profile;
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.github.arrudalabs</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencyManagement>
        <dependencies>
            <dependency> <!-- added dependency-->
                <groupId>a</groupId>
                <artifactId>a</artifactId>
                <version>1.3</version>.
            </dependency>
            <dependency>
                <groupId>b</groupId>
                <artifactId>b</artifactId>
                <version>3.4</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>
@dearrudam dearrudam added enhancement New feature or request help wanted Extra attention is needed question Further information is requested proposal Idea proposal labels Apr 8, 2023
@dearrudam dearrudam added this to the 0.0.4 milestone Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed proposal Idea proposal question Further information is requested
Projects
Development

No branches or pull requests

1 participant