gnodet commented on issue #12304:
URL: https://github.com/apache/maven/issues/12304#issuecomment-4738567506

   ## Root Cause Analysis
   
   ### The POM pattern
   
   The parent POM (`activemq-protobuf-pom`) declares `<dependencyManagement>` 
using `${version}`:
   
   ```xml
   <dependencyManagement>
     <dependencies>
       <dependency>
         <groupId>org.apache.activemq.protobuf</groupId>
         <artifactId>activemq-protobuf</artifactId>
         <version>${version}</version>
       </dependency>
     </dependencies>
   </dependencyManagement>
   ```
   
   The child module `activemq-protobuf-test` then declares a dependency without 
`<version>`, relying on the parent's `<dependencyManagement>` to provide it:
   
   ```xml
   <dependency>
     <groupId>org.apache.activemq.protobuf</groupId>
     <artifactId>activemq-protobuf</artifactId>
     <!-- no version — expects dependencyManagement to provide it -->
   </dependency>
   ```
   
   ### Why Maven 3 accepted this
   
   In Maven 3, `${version}` was a valid (though deprecated) alias for 
`${project.version}`. The `<dependencyManagement>` version resolved to 
`1.2-SNAPSHOT`, and the child's dependency inherited that version.
   
   ### Why Maven 4 rejects it
   
   Maven 4 no longer supports the bare `${version}` property as a built-in 
alias for `${project.version}`. When the model validator processes the child's 
dependency, it tries to resolve the version from `<dependencyManagement>`, but 
the managed version is the literal unresolved string `${version}` (which 
evaluates to null/empty). So the dependency effectively has no version.
   
   The error message says the version "is missing" because after property 
interpolation, `${version}` resolves to nothing — the dependency management 
entry provides no usable version.
   
   ### Verdict: **Project bug**, not a Maven 4 regression
   
   The project uses the deprecated `${version}` shorthand instead of 
`${project.version}`. This was a bad practice even in Maven 3 (it was 
deprecated since Maven 2.x). Maven 4 correctly drops support for this 
deprecated alias.
   
   ### Fix (project-side)
   
   Replace `${version}` with `${project.version}` in the parent POM's 
`<dependencyManagement>`:
   
   ```xml
   <version>${project.version}</version>
   ```
   
   Or better yet, since this is a simple reactor with all modules sharing the 
same version, just use `${project.version}` everywhere.
   
   _Claude Code on behalf of Guillaume Nodet_


-- 
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]

Reply via email to