MelleD opened a new pull request, #3627:
URL: https://github.com/apache/tika/pull/3627
## Problem
`tika-bom` is not usable together with `spring-boot-starter-parent` (or any
project that wants to control its own third-party versions).
`tika-bom` inherits from `tika-parent`. The `flatten-maven-plugin`
configured in `tika-parent` uses `flattenMode=resolveCiFriendliesOnly`, so the
published `tika-bom` still declares `tika-parent` as its parent. `tika-parent`
imports a number of third-party BOMs, for example:
```xml
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>${netty.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
```
When a consumer imports `tika-bom`, Maven resolves its parent chain and all
of these managed versions (netty, jackson, jetty, grpc, log4j, ...) leak into
the consumer's `dependencyManagement`, overriding versions managed by e.g.
Spring Boot.
### Steps to reproduce
```xml
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.7</version>
</parent>
<groupId>x</groupId>
<artifactId>consumer</artifactId>
<version>1</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-bom</artifactId>
<version>${tika.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
</dependency>
</dependencies>
</project>
```
Run `mvn help:effective-pom` or `mvn dependency:tree`:
| | `netty-codec-http` version |
|---|---|
| without this PR | `4.2.20.Final` (from Tika's `netty-bom`) |
| with this PR | `4.1.128.Final` (managed by Spring Boot, as expected) |
## Fix
Same approach as Apache Jena
([apache/jena#4107](https://github.com/apache/jena/issues/4107), commit
[e1211db](https://github.com/apache/jena/commit/e1211dbd88649a374fc46cb61efe161b4df1a9f7)):
- Override `flatten-maven-plugin` in `tika-bom/pom.xml` with
`flattenMode=bom` and `properties=remove`. The flattened (published) BOM no
longer has a `<parent>` and only contains Tika's own `dependencyManagement`.
- Use `${project.version}` instead of `${revision}` for the BOM entries.
Because properties are removed, `${revision}` would not be resolvable for
consumers, while `${project.version}` resolves to the BOM's own version (as in
`jena-bom`).
The plugin version is already managed in `tika-parent`, so no other change
is needed.
### Verification
- `tika-bom/.flattened-pom.xml` contains no `<parent>`, no `<properties>`
and no `<scope>import</scope>`. It has only the 90 `org.apache.tika` entries
with `${project.version}`.
- The consumer project above resolves Spring Boot's Netty version after the
change and Tika's version before it. `tika-core` still resolves to the Tika
version.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]