pom-editor-maven-plugin
pom-editor-maven-plugin copied to clipboard
[Enhancement Goal Proposal]: add-dep to specific profile
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: 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-depgoal is executed with a given dependency info plus the-Dprofile=profileAproperty
$ mvn pom-editor:add-dep -Dprofile='profileA' -Dgav='a:a:1.1'
- Then the
add-depgoal 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-depgoal is executed with a given dependency info plus the-Dprofile=profileAonly
$ 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-depgoal is executed with a given dependency info plus the-Dprofile=profileAproperty, and-Dforce=trueproperty
$ 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>
Can I be assigned to work on it?
@luiguip, are you working on it?