Hello Maven experts,

sorry to jump on board of this mail alias directly with what seems to be a 
relatively hard question as my very first post… 😉

Short introduction about myself: I am a senior Java developer/technical 
architect at a mid-sized project at Deutsche Bahn/DB Energie, where we are in 
the process of migrating from Java EE 8 to Jakarta EE 10 (JBoss EAP) plus 
Spring Boot 2.7 to Spring Boot 3.x (3.3 or 3.4).

As we have a parent “root” POM (not really a BoM POM yet!) and ~ 20 subproject 
POMs dealing with the different standards flavors (Java/Jakarta EE, Spring 
Boot), we do currently already include an awful lot of <scope>import</scope> 
BoM POM reading, but still have a setup that is very hard to maintain/keep 
track of interdependencies to determine the correct versions for our 
dependencies. We even have a number of places where it is highly relevant io 
import these dependency BoM POMs in the correct order, because (as you all 
know) the first version definition wins… ☹

My original (but not working for reasons not immediately obvious when you start 
looking into the Maven lifecycle model “naively”!) was to simplify this task by 
writing a Maven plugin that – in the original idea – should be configured to


  *   point to the Maven coordinates of related BoM POM files (e.g. 
“org.jboss.bom:jboss-eap-ee:8.0.6.GA-redhat-00006:pom” or 
“org.apache.cxf:cxf-bom:4.0.5.redhat-00001:pom”), and then
  *   read not the full “import” dependencies (including concrete versions), 
but “only” the values of the (typically “version.*”) properties as defined in 
the target BoM POMs, and
  *   make these property names and their values (typically dependency version 
numbers) available to the “calling” POM
  *   the (naïve) intention was to attach this new custom plugin to Maven 
lifecycle phases “pre-clean” and “initialize”.

Unfortunately, when trying to implement this, I found that this is a dead end, 
because Maven starts evaluating dependencies and dependency versions (from the 
POM’s <project (…)><properties>(…)</properties>(…)</project> section) much 
earlier, namely even far before the first plugin mojo is being called as part 
of the lifecycle.

So I am basically wondering:


  *   Maybe it is for a reason that a plugin doing what I was trying to achieve 
does not exist…
  *   From your expert knowledge about Maven, is there any way to evaluate and 
act on nested expressions in the values of the “version” properties (such as 
<version.org.apache.cxf>) in a POM file?
     *   Would using the “Event Spy” approach 
(https://github.com/khmarbaise/test-maven-eventspy, a viable approach to do so 
- especially a DependencyResolutionRequest (or any other Event type?) be 
appropriate to do additional evaluation and actions (such as reading properties 
containing dependency version numbers from nested BoM POMs) based on project 
property values that contain nested “expressions” (such as the BoM POM 
coordinates themselves plus the name of a property to read from this BoM POM)?
     *   If not, what would be your preferred approach to implement the above 
(if at all feasible)?

Note: In case we/I succeed in implementing some solution for this, I will 
definitely open source the resulting code, most likely on the “Codeberg” Git 
server (https://codeberg.org).

Many thanks in advance for your kind help! 😊👍

Best regards
Andreas

--
Andreas Loew
Senior Consultant Java Development
Java Enterprise Architect
E-Mail: 
andreas.a.loew-ext...@deutschebahn.com<mailto:andreas.a.loew-ext...@deutschebahn.com>

externe Fachkraft im Auftrag der
Wavestone Germany AG
Leopoldstraße 28a, D-80802 München
im Auftrag der
DB Energie GmbH (I.EFN 2)
Im Galluspark 25, D-60326 Frankfurt am Main


________________________________

Pflichtangaben anzeigen<https://www.deutschebahn.com/pflichtangaben/20250301>

Nähere Informationen zur Datenverarbeitung im DB-Konzern finden Sie hier: 
https://www.deutschebahn.com/de/konzern/datenschutz

Reply via email to