slachiewicz opened a new pull request, #1275: URL: https://github.com/apache/maven-javadoc-plugin/pull/1275
## Problem The `excludePackageNames` parameter with trailing wildcard patterns like `org.example.*` was only matching direct subpackages (one level deep), but not nested subpackages. This caused builds to fail when using wildcards to exclude package hierarchies, particularly noticeable with Java 25. For example, with `<excludePackageNames>org.example.*</excludePackageNames>`: - ✅ Correctly excluded: `org.example.sub1`, `org.example.sub2` - ❌ **Not** excluded: `org.example.sub2.subsub`, `org.example.sub1.deep.nested` This was inconsistent with the javadoc `-exclude` option behavior, which according to Oracle's documentation "unconditionally excludes the specified packages and their subpackages." ## Root Cause The regex pattern conversion in `JavadocUtil.getExcludedPackages()` was treating all non-leading wildcards the same way, converting `*` to `[^/]+` which matches exactly one directory level. This meant: - `org.example.*` → `org/example/[^/]+` (matches only one level) - Should be: `org.example.*` → `org/example/.+` (matches one or more levels) ## Solution Updated the wildcard-to-regex conversion logic to distinguish between: 1. **Leading wildcards** (`*.internal`) → `.+` - matches one or more package segments 2. **Trailing wildcards** (`org.example.*`) → `.+` - matches one or more package segments (all subpackages) 3. **Middle wildcards** (`org.*.sub1`) → `[^/]+` - matches exactly one package segment This ensures trailing wildcards correctly exclude all subpackages at any depth, aligning with javadoc's `-exclude` option behavior. ## Changes - **JavadocUtil.java**: Fixed regex pattern generation to handle trailing wildcards with `.+` instead of `[^/]+` - **AbstractJavadocMojo.java**: Updated documentation with clearer examples showing wildcard behavior - **JavadocUtilTest.java**: Added comprehensive test coverage for wildcard patterns including nested subpackages ## Example With this fix, `<excludePackageNames>org.example.*</excludePackageNames>` now correctly excludes: - `org.example.sub1` - `org.example.sub2` - `org.example.sub2.subsub` ✨ (previously missed) - `org.example.sub1.deep.nested` ✨ (previously missed) Fixes issue where excludePackageNames with wildcards stopped working correctly in recent Java versions. -- 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]
