This is an automated email from the ASF dual-hosted git repository. centic9 pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/poi.git
commit e27a1434533962e8f5e84d4a0f88e9e15c3838e1 Author: Dominik Stadler <[email protected]> AuthorDate: Fri Nov 21 18:48:36 2025 +0100 Add check for module-class-files --- build.gradle | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/build.gradle b/build.gradle index 3604a9ccea..e94d020177 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,7 @@ import org.w3c.dom.NodeList import javax.xml.xpath.XPath import javax.xml.xpath.XPathConstants import javax.xml.xpath.XPathFactory +import java.util.zip.ZipFile buildscript { repositories { @@ -96,6 +97,31 @@ allprojects { version = '6.0.0-SNAPSHOT' } +abstract class VerifyModuleInfoIsPresent extends DefaultTask { + @InputFile + abstract RegularFileProperty getVerifiedJar() + + @TaskAction + void verifyModuleInfo() { + def jar = verifiedJar.get().asFile + if (jar.getName().contains('poi-integration') || jar.getName().contains('poi-fuzz')) { + return + } + + 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") + } + } + } +} + /** Define things that are only necessary in sub-projects, but not in the master-project itself */ @@ -320,6 +346,15 @@ subprojects { } } + // Verify if module-info is present in the jar-file + def verifyModuleInfoPresentRef = tasks.register("verifyModuleInfoPresent", VerifyModuleInfoIsPresent) { + verifiedJar = tasks.named("jar").flatMap { it.archiveFile } + } + + tasks.named("check") { + dependsOn(verifyModuleInfoPresentRef) + } + javadocJar { // if javadocs and binaries are in the same directory, JPMS complaints about duplicated modules // in the module-path --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
