kelemen commented on issue #932:
URL: https://github.com/apache/poi/issues/932#issuecomment-3549654225

   I have seen that you were looking for simpler automatic validation for this 
issue on the dev list:
   
   An incomplete, but simple validation is if you have a dummy project with 
`module-info.java` and only requiring `poi-ooxml` but using a core class from 
`poi` relying on a transitive dependency (this is how I noticed this issue).
   
   If you just want to check for the presence of `module-info` and assume it is 
correct, if it is there (which is most likely the case), then you can have 
something like this:
   
   ```groovy
   abstract class VerifyModuleInfoIsPresent extends DefaultTask {
       @InputFile
       abstract RegularFileProperty getVerifiedJar()
   
       @TaskAction
       void verifyModuleInfo() {
           def jar = verifiedJar.get().asFile
           new ZipFile(jar).withCloseable { zip ->
               def moduleInfo9Present = 
zip.getEntry("META-INF/versions/9/module-info.class") != null
               def moduleInfoRootPresent = zip.getEntry("module-info.class") != 
null
               if (moduleInfo9Present) {
                   if (moduleInfoRootPresent) {
                       throw new VerificationException("Duplicate module-info 
in $jar")
                   }
               } else if (!moduleInfoRootPresent) {
                   throw new VerificationException("Missing module-info in 
$jar")
               }
           }
       }
   }
   
   def verifyModuleInfoPresentRef = tasks.register("verifyModuleInfoPresent", 
VerifyModuleInfoIsPresent) {
       verifiedJar = tasks.named("jar").flatMap { it.archiveFile }
   }
   
   tasks.named("check") {
       dependsOn(verifyModuleInfoPresentRef)
   }
   ```
   
   Of course, you should factor this out into some common script (or plugin) 
applied to all projects.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to