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

[Enhancement Goal Proposal]: add-dep to specific profile #20

Open
dearrudam opened this issue Apr 8, 2023 · 2 comments
Open

[Enhancement Goal Proposal]: add-dep to specific profile #20

dearrudam opened this issue Apr 8, 2023 · 2 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

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 using profiles for many purposes, but such profiles are allowed to manage their own dependencies.

With that, it's needed to enhance the add-dep to add or update dependencies into a specific profile.

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

Goal syntax:

$ mvn pom-editor:add-dep -Dprofile=<TARGET PROFILE> -Dforce=true -Dgav=<DEPENDENCY COORDINATES>

New inputs:

Property Description
profile the target profile that the dependency should be added
force force to create the target profile if it doesn't exist at the target POM

⚠️ 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 an existent profile in a given POM
<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>
    <profiles>
        <profile>
            <id>profileA</id>
            <dependencies>
                <dependency>
                    <groupId>a</groupId>
                    <artifactId>a</artifactId>
                    <version>1.0</version>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
  • When the add-dep goal is executed with a given dependency info plus the -Dprofile=profileA property
$ mvn pom-editor:add-dep -Dprofile='profileA' -Dgav='a:a:1.1'
  • Then the add-dep goal should add or update the given dependency into the 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>
    <profiles>
        <profile>
            <id>profileA</id>
            <dependencies>
                <dependency>
                    <groupId>a</groupId>
                    <artifactId>a</artifactId>
                    <version>1.1</version> <!-- updated version -->
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>

Scenario 02:

  • Given the necessity to add or update a given dependency into a profile that doesn't exist in the target POM
<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-dep goal is executed with a given dependency info plus the -Dprofile=profileA only
$ mvn pom-editor:add-dep -Dprofile='profileA' -Dgav='a:a:1.1'
  • Then the goal should alert an error explaining that the provided profile doesn't exist.
[ERROR] error to add or update the dependency: {groupId='a', artifactId='a', version='1.1'} in the "profileA" profile's dependencies into the pom: pom.xml: "profileA" profile doesn't exist.

Scenario 03:

  • Given the necessity to add or update a given dependency into a profile that doesn't exist in the target POM
<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-dep goal is executed with a given dependency info plus the -Dprofile=profileA property, and -Dforce=true property
$ mvn pom-editor:add-dep -Dprofile='profileA' -Dforce=true -Dgav='a:a:1.1'
  • Then the goal should create the target profile with the provided dependency into its dependencies XML node
<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>
    <profiles>
        <profile>
            <id>profileA</id> <!-- profile was created -->
            <dependencies>
                <dependency>
                    <groupId>a</groupId>
                    <artifactId>a</artifactId>
                    <version>1.1</version> 
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</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 changed the title [Improvement Goal Proposal]: add-dep to specific profile [Enhance Goal Proposal]: add-dep to specific profile Apr 8, 2023
@dearrudam dearrudam changed the title [Enhance Goal Proposal]: add-dep to specific profile [Enhancement Goal Proposal]: add-dep to specific profile Apr 8, 2023
@dearrudam dearrudam added this to the 0.0.4 milestone Apr 21, 2023
@luiguip
Copy link
Contributor

luiguip commented Sep 25, 2023

Can I be assigned to work on it?

@dearrudam
Copy link
Contributor Author

@luiguip, are you working on it?

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

2 participants