ascheman commented on PR #996:
URL: https://github.com/apache/maven-enforcer/pull/996#issuecomment-6725986586

   Good catch — and it turns out you were pointing at a real bug, just not the 
one you suspected.
   
   The Java 8 part is already handled: `readModuleInfo` only calls 
`requireJava9Runtime()` *after* it has found a `module-info.class`, and that 
throws an `EnforcerRuleException` naming the running Java version rather than 
letting `ModuleDescriptor.read` fail obscurely. So a Java 8 runtime can never 
reach the reflective reader.
   
   But the Moditect scenario broke the rule for a different reason, and on 
every JDK. `add-module-info` injects the descriptor into the packaged JAR with 
ASM; it never writes into `${project.build.outputDirectory}`. The rules only 
inspected that directory, so for a Moditect project `requireExplicitModules` 
reported "not an explicit Java module" even though the shipped artifact *is* a 
proper named module. A false failure, independent of the Java version.
   
   Fixed in 9709b89: since the rule exists to stop the *artifact* resolving as 
an automatic module downstream, a descriptor present in the packaged artifact 
now counts — `module-info.class`, or `META-INF/versions/<n>/module-info.class` 
for a multi-release JAR. That requires the rule to be bound after `package`, so 
the failure message now says so.
   
   Two deliberate limits:
   
   - The fallback applies only to the classic one-module layout. In a Maven 4 
module source hierarchy the main artifact cannot stand for several modules, so 
an artifact level check would be ambiguous; there is a test pinning that 
boundary.
   - An artifact that cannot be read as an archive counts as non-modular, 
keeping the stricter outcome.
   
   Four new unit tests cover it: injected descriptor, multi-release variant, 
artifact without a descriptor still fails, and the hierarchy boundary. 
`enforcer-rules` is green at 333 tests.
   


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