flatten-maven-plugin
flatten-maven-plugin copied to clipboard
Not able to produce a BOM with ${revision} resolved for dependencies
I have a project like this:
myproject-parent
- myproject-bom
- myproject-artifact1
- myproject-artifact2 ...
Wo using ${revisiion} it quite simple. I use ${project.version} to address inter module dependencies and in the BOM i use resolved versions (AS YOU CANNOT USE project.version when inheriting a bom for coordinates) outside the project. The artifacts in the project also inherit the BOM.
Following this guide maven-ci-friendly I cannot create a working BOM that has resolved ${revision} for PROJECT dependencies. The BOM version has ${revision} replace but not the dependencies listed in it. When using flattenMode =resolveCIFriendlyOnly i get the following bom produced:
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.myproject</groupId>
<artifactId>myproject-parent</artifactId>
<version>16.0.0-651-SNAPSHOT</version>
</parent>
<groupId>com.myproject</groupId>
<artifactId>myproject-bom</artifactId>
<version>16.0.0-651-SNAPSHOT</version>
<packaging>pom</packaging>
<name>myproject-bom</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.myprojectr</groupId>
<artifactId>myproject-artifact1</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
...this works as long as the project inheriting this bom dont rely on ${revision}. I know the above linked guide mentions you shouldnt use ${revision} for project artifact coordinates - but project.version is useless for a BOM made for inheritance. There should be flattenMode that replaces ${revision} throughout.
Ie for revision=1.2.3-FEATURE-456-SNAPSHOT. The BOM i want my project to produce should look like this (with resolved project dependency versions) :
<dependency>
<groupId>com.myprojectr</groupId>
<artifactId>myproject-artifact1</artifactId>
<version>1.2.3-FEATURE-456-SNAPSHOT</version>
</dependency>
...
i have the same problem, Have you solved the problem?
Sorry for late answer. Nope. Havent solved this. Makes $[revision] + flatten sort of useless.
i'm having the same problem i created a little reproducer: https://github.com/a1dutch/flatten-revision
this is the output of the flatterned pom using resolveCiFriendliesOnly flatten mode
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>uk.co.a1dutch</groupId>
<artifactId>flatten-revision-build</artifactId>
<version>0.9.1-SNAPSHOT</version>
</parent>
<groupId>uk.co.a1dutch</groupId>
<artifactId>flatten-revision-dependencies</artifactId>
<version>0.9.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<should-be-flattened>${revision}</should-be-flattened>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>uk.co.a1dutch</groupId>
<artifactId>flatten-revision-dependent</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
its not swapping out dependency management or properties
We've able to solve this by replacing both this maven-flatten-plugin and the release plugin we used.
-
ci-friendly flatten plugin https://medium.com/outbrain-engineering/faster-release-with-maven-ci-friendly-versions-and-a-customised-flatten-plugin-fe53f0fcc0df
-
(optional maybe) https://github.com/aleksandr-m/gitflow-maven-plugin
Its been working absolutely great on multiple projects.
just user this:
mvn clean deploy -Drevision=1.2.3-FEATURE-456-SNAPSHOT