Change maven dependency version using different maven profiles

I have two projects, project A depends on project B, so as a rule, I will have the following section in my project A / pom.xml:

<dependency> <artifactId>projectB</artifactId> <groupId>blabla</groupId> <version>version1</version> </dependency> 

What I'm trying to achieve is very straightforward if the maven profile does something like this to me:

 if(profileA) { <version>version1</version> } else { <version>version2</version> } 
+4
source share
1 answer

Yes, it can be done (put activeByDefault depending on which profile you need by default).

 <dependency> <artifactId>projectB</artifactId> <groupId>blabla</groupId> <version>${dependency.version}</version> </dependency> ... <profiles> <profile> <id>first</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <dependency.version>1.2.3</dependency.version> </properties> </profile> <profile> <id>second</id> <properties> <dependency.version>2.3.4</dependency.version> </properties> </profile> </profiles> 
+5
source

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


All Articles