gnodet opened a new issue, #13459:
URL: https://github.com/apache/maven/issues/13459

   ## Summary
   
   In Maven 3, plugin parameters annotated with `@Parameter` on complex objects 
(nested configuration classes like `<archive>`) are injected by Plexus's 
`EnhancedComponentConfigurator` via reflection. This configurator requires 
either **public fields** or **public setters** on the target class, because it 
runs in a different classloader/module and cannot access package-private 
members without `setAccessible(true)`.
   
   This forces plugin authors to either expose public fields (which violates 
typical checkstyle `VisibilityModifier` rules) or write boilerplate 
getters/setters with no real API value.
   
   ## Context
   
   While refactoring `maven-jar-plugin` to remove its `maven-archiver` 
dependency (PR 
[apache/maven-jar-plugin#618](https://github.com/apache/maven-jar-plugin/pull/618)),
 we introduced a local `ArchiveConfiguration` class holding plugin config. 
Martin Kanters suggested making inner classes package-private with no 
getters/setters — a reasonable design for an implementation-internal config 
class. However, this is currently not feasible because 
`EnhancedComponentConfigurator` cannot inject into package-private fields.
   
   ## Proposal
   
   For **Maven 4 API plugins** (those depending on `maven-api-plugin` / using 
the new `@Mojo` from `org.apache.maven.api.plugin.annotations`), the mojo 
parameter configurator should support injecting into **package-private fields** 
— either by:
   
   1. Calling `field.setAccessible(true)` before reflective access (already 
done for private fields in some configurators), or
   2. Providing a dedicated, type-safe parameter binding mechanism that doesn't 
rely on reflection visibility rules.
   
   This would allow Maven 4 API plugins to write clean, encapsulated config 
classes without public boilerplate:
   
   ```java
   // Current (forced by Plexus configurator):
   public class ArchiveConfiguration {
       private boolean compress = true;
       public boolean isCompress() { return compress; }
       public void setCompress(boolean compress) { this.compress = compress; }
       // ... 15 more getters/setters
   }
   
   // Desired (package-private, no boilerplate):
   class ArchiveConfiguration {
       boolean compress = true;
       // used directly within the plugin package
   }
   ```
   
   ## Target
   
   Maven 4.1.0


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