Hiteshsai007 opened a new pull request, #1644:
URL: https://github.com/apache/maven-mvnd/pull/1644

   ## Problem
   
   Closes #1555
   
   When a project contains a Maven plugin with a `-SNAPSHOT` version (i.e., a 
reactor plugin), subsequent `mvnd` invocations do not reload the changed 
plugin. This means stale plugin metadata — e.g., thread-safety flags from 
`@Mojo(threadSafe = ...)` annotations — is used in subsequent builds, violating 
the principle of least surprise and diverging from standard `mvn` behaviour.
   
   **Steps to reproduce:**
   1. Have a Maven project that builds a custom `-SNAPSHOT` Mojo plugin (e.g., 
`threadSafe = false`)
   2. Run `mvnd verify` → see the thread-safe warning
   3. Change the Mojo to `threadSafe = true`
   4. Run `mvnd verify` again → Mojo is **still** treated as not thread-safe 
(stale cache)
   
   ## Root Cause
   
   `InvalidatingRealmCacheEventSpy` correctly evicts `PluginRealmCache` entries 
for artifacts under the `multiModuleProjectDirectory`. However, the 
`PluginDescriptorCache` and `PluginArtifactsCache` were **never evicted**, so 
even after the plugin jar was reloaded into a new realm, Maven would look up 
the stale descriptor from the cache and use it without re-parsing the plugin's 
annotations.
   
   ## Fix
   
   At the end of each `MavenExecutionResult` event, additionally evict all 
entries in the:
   - `PluginDescriptorCache` — keyed entries whose `toString()` contains 
`-SNAPSHOT`
   - `PluginArtifactsCache` — keyed entries whose `toString()` contains 
`-SNAPSHOT`
   
   The `PluginRealmCache` is also extended to immediately evict SNAPSHOT 
entries (short-circuit in `shouldEvict()`), in addition to the existing 
path-based eviction logic.
   
   This ensures that `-SNAPSHOT` plugins are always reloaded fresh on the next 
build, consistent with the behaviour of standard `mvn`.
   
   ## Changes
   
   **`InvalidatingRealmCacheEventSpy.java`**:
   - Inject `InvalidatingPluginDescriptorCache` and 
`InvalidatingPluginArtifactsCache` via constructor
   - On `MavenExecutionResult`: evict all `-SNAPSHOT` entries from both caches
   - `shouldEvict()` for `PluginRealmCache`: return `true` immediately if key 
contains `-SNAPSHOT`


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