does this also validate that the module-info file is IN the jar file?  or 
merely present on the classpath.

i think this is a two part issue from what i've read in the chain.

1) validating the file exists
2) validating it's making its way into the jar assembly.

so basically a combo unit test and integration test.

Stanton Fisque
principal technologist
latticeware.com
portland, oregon

> On Nov 18, 2025, at 14:15 PM, kelemen (via GitHub) <[email protected]> wrote:
> 
> 
> 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]
> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to