This is an automated email from the ASF dual-hosted git repository.

luigidemasi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kit.git

commit ed7b84c07d1915490e3278aaaf0bdcae4be813ea
Author: Luigi De Masi <[email protected]>
AuthorDate: Tue Dec 1 12:36:02 2026 +0100

    Check declared licenses across routine dependency upgrades
    
    Compare the effective Maven licenses for reviewed Apache-2.0 dependencies,
    including the selected alternatives and the resolved version. Keep exact
    version checks for supplemental notices. Preserve the contributor guide's
    published definition of done anchor.
    
    Co-authored-by: OpenAI Codex <[email protected]>
---
 CLAUDE.md                                          |   2 +-
 docs/modules/ROOT/pages/contributing.adoc          |  21 +++--
 docs/releasing.md                                  |   6 +-
 kit/camel-jbang-plugin-kit/pom.xml                 |   4 +
 .../src/main/legal/dependencies.tsv                |  20 ++--
 kit/camel-kit-ship-resolver/pom.xml                |   4 +
 .../src/main/legal/dependencies.tsv                |  12 +--
 knowledge/mcp/pom.xml                              |   4 +
 knowledge/mcp/src/main/legal/dependencies.tsv      | 102 ++++++++++-----------
 pom.xml                                            |  21 +++++
 tools/BundleLicenses.java                          |  47 +++++++++-
 tools/pom-licenses.ftl                             |   6 ++
 tools/test_bundle_licenses.py                      |  28 +++++-
 13 files changed, 195 insertions(+), 82 deletions(-)

diff --git a/CLAUDE.md b/CLAUDE.md
index ae596988..8caaee26 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -88,7 +88,7 @@ Work is finished only when all of these hold:
 
 1. `./mvnw test -B` passes in every touched module; `./mvnw clean install -B` 
from
    root when changes span modules or touch 
skills/templates/`distribution.properties`.
-   When a bundled runtime dependency changes, review the notices and version 
records in the module's `src/main/legal/`.
+   When a bundled runtime dependency changes, review the POM license 
declarations and version-pinned supplemental terms in the module's 
`src/main/legal/`.
    At `prepare-package`, `tools/BundleLicenses.java` assembles these with the 
licensing files from the runtime JARs.
    After a full build, run `python3 tools/verify_bundle_licenses.py` and, for 
the plugin, `python3 tools/verify_installed_plugin.py`.
 2. `./mvnw -Psourcecheck validate -B` passes (CI format gate).
diff --git a/docs/modules/ROOT/pages/contributing.adoc 
b/docs/modules/ROOT/pages/contributing.adoc
index cc6530d9..5b7cc30a 100644
--- a/docs/modules/ROOT/pages/contributing.adoc
+++ b/docs/modules/ROOT/pages/contributing.adoc
@@ -57,7 +57,6 @@ does not acquire an Aesh interactive terminal. JLine/TamboUI 
still own standalon
 the host's terminal. `camel.cli.version` and `aesh.version` pin the CLI 
host/parser separately from
 `camel.main.version`, which controls generated integration defaults. See 
xref:getting-started.adoc#cli-host[host compatibility].
 
-[[done]]
 === Licensing bundled dependencies
 
 The parent POM puts the project `LICENSE` and `NOTICE` in each module JAR.
@@ -68,18 +67,26 @@ original licensing files and collects their notices. The 
runner ships the result
 
 When adding or upgrading a bundled dependency, check the exact upstream 
release,
 including native libraries, embedded code and model conversions. If its JAR 
lacks
-a nonempty primary LICENSE or COPYING file, record the Maven coordinate, 
version
-and applicable license section in the module's 
`src/main/legal/dependencies.tsv`.
-Use `Apache-2.0` for dependencies covered by the project license, or reproduce
-the upstream terms in `src/main/legal/LICENSE` and name the section in the 
table.
-A section can use `\{version}` to match the reviewed release.
-Record dependencies that need supplementary terms even when their JAR ships a 
license.
+a nonempty primary LICENSE or COPYING file, record its Maven coordinate and 
licensing
+in the module's `src/main/legal/dependencies.tsv`.
+For a dependency covered by the project license, mark the version column `*` 
and
+list `Apache-2.0` plus any reviewed alternative licenses. Maven reads the
+effective POM, including inherited licenses. A version bump passes when the 
resolved
+version declares the same licenses. Missing declarations or a changed license 
set
+stop packaging. A new dependency without a license file still needs its own 
row.
+
+For dependencies with supplementary terms, pin the reviewed artifact version,
+reproduce the terms in `src/main/legal/LICENSE` and name the section in the 
table.
+A section can use `\{version}` to match the reviewed release. DJL, for example,
+declares Apache-2.0 in its POM and also bundles native code with additional 
terms.
+Record these dependencies even when the JAR ships a primary license.
 Keep upstream attributions in `src/main/legal/NOTICE` and any referenced files
 in `src/main/resources`. Include the pack's own license in external pack JARs.
 
 Run `./mvnw -B clean install`, then `python3 tools/verify_bundle_licenses.py`
 to check the files in the archives that users receive.
 
+[[done]]
 == Definition of done
 
 A change is finished when all of the following hold:
diff --git a/docs/releasing.md b/docs/releasing.md
index b5e9cf02..ced334d8 100644
--- a/docs/releasing.md
+++ b/docs/releasing.md
@@ -28,11 +28,13 @@ runner and results in `docs/modules/ROOT/pages/mcp.adoc` 
and update the unreleas
 Generated integration pins are independent.
 
 Build the full reactor and run `python3 tools/verify_bundle_licenses.py`. 
Inspect the candidate
-JARs against the runtime dependencies and versioned records in each bundle's
+JARs against the runtime dependencies and license records in each bundle's
 `src/main/legal/dependencies.tsv`. The plugin and Ship Resolver ship their 
generated
 license and notice under `META-INF/`. The Knowledge runner ships `LICENSE.txt` 
and
 `NOTICE.txt` at its root. The contributor guide describes how to update the 
inputs
-to `tools/BundleLicenses.java` when a dependency or bundled model changes.
+to `tools/BundleLicenses.java` when a dependency or bundled model changes. 
Plain Apache-2.0
+records check the resolved version's effective POM declarations. Supplemental 
terms require
+the exact version reviewed.
 
 For a Knowledge release, include the Windows native libraries and their 
linkage in the
 Camel PMC's review of the release candidate. DJL Tokenizers loads 
`libwinpthread-1.dll`,
diff --git a/kit/camel-jbang-plugin-kit/pom.xml 
b/kit/camel-jbang-plugin-kit/pom.xml
index 0cb692eb..26475057 100644
--- a/kit/camel-jbang-plugin-kit/pom.xml
+++ b/kit/camel-jbang-plugin-kit/pom.xml
@@ -64,6 +64,10 @@
 
     <build>
         <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>license-maven-plugin</artifactId>
+            </plugin>
             <plugin>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
diff --git a/kit/camel-jbang-plugin-kit/src/main/legal/dependencies.tsv 
b/kit/camel-jbang-plugin-kit/src/main/legal/dependencies.tsv
index fa7ec2e0..b3e8fc82 100644
--- a/kit/camel-jbang-plugin-kit/src/main/legal/dependencies.tsv
+++ b/kit/camel-jbang-plugin-kit/src/main/legal/dependencies.tsv
@@ -1,18 +1,18 @@
-# Maven coordinate     Reviewed version        License or section of the 
binary LICENSE
-com.ethlo.time:itu     1.14.0  Apache-2.0
+# Maven coordinate     Reviewed version (* checks POM licensing)       License 
or section of the binary LICENSE
+com.ethlo.time:itu     *       Apache-2.0
 com.github.freva:ascii-table   1.9.0   ascii-table {version}
-com.github.javaparser:javaparser-core  3.26.4  Apache-2.0
-com.networknt:json-schema-validator    2.0.4   Apache-2.0
+com.github.javaparser:javaparser-core  *       Apache-2.0 | GNU Lesser General 
Public License <http://www.gnu.org/licenses/lgpl-3.0.html>
+com.networknt:json-schema-validator    *       Apache-2.0
 dev.tamboui:tamboui-annotations        0.1.0   TamboUI {version}
 dev.tamboui:tamboui-core       0.1.0   TamboUI {version}
 dev.tamboui:tamboui-image      0.1.0   TamboUI {version}
 dev.tamboui:tamboui-jline3-backend     0.1.0   TamboUI {version}
 dev.tamboui:tamboui-tui        0.1.0   TamboUI {version}
 dev.tamboui:tamboui-widgets    0.1.0   TamboUI {version}
-io.smallrye.common:smallrye-common-annotation  2.12.2  Apache-2.0
-io.smallrye.reactive:mutiny    2.9.2   Apache-2.0
+io.smallrye.common:smallrye-common-annotation  *       Apache-2.0
+io.smallrye.reactive:mutiny    *       Apache-2.0
 org.antlr:antlr4-runtime       4.11.1  ANTLR 4 runtime {version}
-org.jboss.logging:jboss-logging        3.6.1.Final     Apache-2.0
-org.jctools:jctools-core       4.0.5   Apache-2.0
-org.tomlj:tomlj        1.1.1   Apache-2.0
-org.yaml:snakeyaml     2.7     Apache-2.0
+org.jboss.logging:jboss-logging        *       Apache-2.0
+org.jctools:jctools-core       *       Apache-2.0
+org.tomlj:tomlj        *       Apache-2.0
+org.yaml:snakeyaml     *       Apache-2.0
diff --git a/kit/camel-kit-ship-resolver/pom.xml 
b/kit/camel-kit-ship-resolver/pom.xml
index cba30ccb..7e96c2ba 100644
--- a/kit/camel-kit-ship-resolver/pom.xml
+++ b/kit/camel-kit-ship-resolver/pom.xml
@@ -48,6 +48,10 @@
 
     <build>
         <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>license-maven-plugin</artifactId>
+            </plugin>
             <plugin>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
diff --git a/kit/camel-kit-ship-resolver/src/main/legal/dependencies.tsv 
b/kit/camel-kit-ship-resolver/src/main/legal/dependencies.tsv
index 3d334d7d..971cc8a3 100644
--- a/kit/camel-kit-ship-resolver/src/main/legal/dependencies.tsv
+++ b/kit/camel-kit-ship-resolver/src/main/legal/dependencies.tsv
@@ -1,10 +1,10 @@
-# Maven coordinate     Reviewed version        License or section of the 
binary LICENSE
-com.google.code.gson:gson      2.13.2  Apache-2.0
-com.google.errorprone:error_prone_annotations  2.41.0  Apache-2.0
-javax.inject:javax.inject      1       Apache-2.0
-org.codehaus.plexus:plexus-interpolation       1.29    Apache-2.0
+# Maven coordinate     Reviewed version (* checks POM licensing)       License 
or section of the binary LICENSE
+com.google.code.gson:gson      *       Apache-2.0
+com.google.errorprone:error_prone_annotations  *       Apache-2.0
+javax.inject:javax.inject      *       Apache-2.0
+org.codehaus.plexus:plexus-interpolation       *       Apache-2.0
 org.eclipse.sisu:org.eclipse.sisu.inject       0.9.0.M4        Eclipse Sisu 
Inject {version}
 org.ow2.asm:asm        9.9     ASM {version}
-org.slf4j:jcl-over-slf4j       1.7.36  Apache-2.0
+org.slf4j:jcl-over-slf4j       *       Apache-2.0
 org.slf4j:slf4j-api    1.7.36  SLF4J {version}
 org.slf4j:slf4j-nop    1.7.36  SLF4J {version}
diff --git a/knowledge/mcp/pom.xml b/knowledge/mcp/pom.xml
index 37154427..bb7a677b 100644
--- a/knowledge/mcp/pom.xml
+++ b/knowledge/mcp/pom.xml
@@ -95,6 +95,10 @@
 
     <build>
         <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>license-maven-plugin</artifactId>
+            </plugin>
             <plugin>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
diff --git a/knowledge/mcp/src/main/legal/dependencies.tsv 
b/knowledge/mcp/src/main/legal/dependencies.tsv
index 8fd6bd71..e728d670 100644
--- a/knowledge/mcp/src/main/legal/dependencies.tsv
+++ b/knowledge/mcp/src/main/legal/dependencies.tsv
@@ -1,4 +1,4 @@
-# Maven coordinate     Reviewed version        License or section of the 
binary LICENSE
+# Maven coordinate     Reviewed version (* checks POM licensing)       License 
or section of the binary LICENSE
 ai.djl.huggingface:tokenizers  0.36.0  DJL {version}
 ai.djl:api     0.36.0  DJL {version}
 com.aayushatharva.brotli4j:brotli4j    1.16.0  Google Brotli in Brotli4j 
{version}
@@ -13,9 +13,9 @@ com.aayushatharva.brotli4j:native-osx-x86_64  1.16.0  Google 
Brotli in Brotli4j {v
 com.aayushatharva.brotli4j:native-windows-aarch64      1.16.0  Google Brotli 
in Brotli4j {version}
 com.aayushatharva.brotli4j:native-windows-x86_64       1.16.0  Google Brotli 
in Brotli4j {version}
 com.aayushatharva.brotli4j:service     1.16.0  Google Brotli in Brotli4j 
{version}
-com.github.victools:jsonschema-generator       4.38.0  Apache-2.0
-com.google.code.gson:gson      2.13.2  Apache-2.0
-com.google.errorprone:error_prone_annotations  2.48.0  Apache-2.0
+com.github.victools:jsonschema-generator       *       Apache-2.0
+com.google.code.gson:gson      *       Apache-2.0
+com.google.errorprone:error_prone_annotations  *       Apache-2.0
 com.microsoft.onnxruntime:onnxruntime  1.19.0  ONNX Runtime {version}
 io.netty:netty-buffer  4.1.132.Final   Netty {version}
 io.netty:netty-codec   4.1.132.Final   Netty {version}
@@ -31,52 +31,52 @@ io.netty:netty-resolver     4.1.132.Final   Netty {version}
 io.netty:netty-resolver-dns    4.1.132.Final   Netty {version}
 io.netty:netty-transport       4.1.132.Final   Netty {version}
 io.netty:netty-transport-native-unix-common    4.1.132.Final   Netty {version}
-io.quarkiverse.mcp:quarkus-mcp-server-core     1.10.5  Apache-2.0
-io.quarkiverse.mcp:quarkus-mcp-server-http     1.10.5  Apache-2.0
-io.quarkiverse.mcp:quarkus-mcp-server-sse-client       1.10.5  Apache-2.0
-io.quarkiverse.mcp:quarkus-mcp-server-stdio    1.10.5  Apache-2.0
-io.quarkus.security:quarkus-security   2.3.2   Apache-2.0
-io.quarkus:quarkus-fs-util     1.3.0   Apache-2.0
-io.smallrye.certs:smallrye-private-key-pem-parser      0.9.2   Apache-2.0
-io.smallrye.common:smallrye-common-annotation  2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-classloader 2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-constraint  2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-cpu 2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-expression  2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-function    2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-io  2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-net 2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-os  2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-ref 2.17.0  Apache-2.0
-io.smallrye.common:smallrye-common-vertx-context       2.17.0  Apache-2.0
-io.smallrye.config:smallrye-config     3.16.0  Apache-2.0
-io.smallrye.config:smallrye-config-common      3.16.0  Apache-2.0
-io.smallrye.config:smallrye-config-core        3.16.0  Apache-2.0
-io.smallrye.reactive:mutiny    3.1.1   Apache-2.0
-io.smallrye.reactive:mutiny-smallrye-context-propagation       3.1.1   
Apache-2.0
-io.smallrye.reactive:smallrye-mutiny-vertx-auth-common 3.21.6  Apache-2.0
-io.smallrye.reactive:smallrye-mutiny-vertx-bridge-common       3.21.6  
Apache-2.0
-io.smallrye.reactive:smallrye-mutiny-vertx-core        3.21.6  Apache-2.0
-io.smallrye.reactive:smallrye-mutiny-vertx-runtime     3.21.6  Apache-2.0
-io.smallrye.reactive:smallrye-mutiny-vertx-uri-template        3.21.6  
Apache-2.0
-io.smallrye.reactive:smallrye-mutiny-vertx-web 3.21.6  Apache-2.0
-io.smallrye.reactive:smallrye-mutiny-vertx-web-common  3.21.6  Apache-2.0
-io.smallrye.reactive:vertx-mutiny-generator    3.21.6  Apache-2.0
-io.smallrye:smallrye-context-propagation       2.3.0   Apache-2.0
-io.smallrye:smallrye-context-propagation-api   2.3.0   Apache-2.0
-io.smallrye:smallrye-context-propagation-storage       2.3.0   Apache-2.0
-io.smallrye:smallrye-fault-tolerance-vertx     6.10.1  Apache-2.0
-io.vertx:vertx-auth-common     4.5.26  Apache-2.0
-io.vertx:vertx-bridge-common   4.5.26  Apache-2.0
-io.vertx:vertx-codegen 4.5.26  Apache-2.0
-io.vertx:vertx-core    4.5.26  Apache-2.0
-io.vertx:vertx-uri-template    4.5.26  Apache-2.0
-io.vertx:vertx-web     4.5.26  Apache-2.0
-io.vertx:vertx-web-common      4.5.26  Apache-2.0
+io.quarkiverse.mcp:quarkus-mcp-server-core     *       Apache-2.0
+io.quarkiverse.mcp:quarkus-mcp-server-http     *       Apache-2.0
+io.quarkiverse.mcp:quarkus-mcp-server-sse-client       *       Apache-2.0
+io.quarkiverse.mcp:quarkus-mcp-server-stdio    *       Apache-2.0
+io.quarkus.security:quarkus-security   *       Apache-2.0
+io.quarkus:quarkus-fs-util     *       Apache-2.0
+io.smallrye.certs:smallrye-private-key-pem-parser      *       Apache-2.0
+io.smallrye.common:smallrye-common-annotation  *       Apache-2.0
+io.smallrye.common:smallrye-common-classloader *       Apache-2.0
+io.smallrye.common:smallrye-common-constraint  *       Apache-2.0
+io.smallrye.common:smallrye-common-cpu *       Apache-2.0
+io.smallrye.common:smallrye-common-expression  *       Apache-2.0
+io.smallrye.common:smallrye-common-function    *       Apache-2.0
+io.smallrye.common:smallrye-common-io  *       Apache-2.0
+io.smallrye.common:smallrye-common-net *       Apache-2.0
+io.smallrye.common:smallrye-common-os  *       Apache-2.0
+io.smallrye.common:smallrye-common-ref *       Apache-2.0
+io.smallrye.common:smallrye-common-vertx-context       *       Apache-2.0
+io.smallrye.config:smallrye-config     *       Apache-2.0
+io.smallrye.config:smallrye-config-common      *       Apache-2.0
+io.smallrye.config:smallrye-config-core        *       Apache-2.0
+io.smallrye.reactive:mutiny    *       Apache-2.0
+io.smallrye.reactive:mutiny-smallrye-context-propagation       *       
Apache-2.0
+io.smallrye.reactive:smallrye-mutiny-vertx-auth-common *       Apache-2.0
+io.smallrye.reactive:smallrye-mutiny-vertx-bridge-common       *       
Apache-2.0
+io.smallrye.reactive:smallrye-mutiny-vertx-core        *       Apache-2.0
+io.smallrye.reactive:smallrye-mutiny-vertx-runtime     *       Apache-2.0
+io.smallrye.reactive:smallrye-mutiny-vertx-uri-template        *       
Apache-2.0
+io.smallrye.reactive:smallrye-mutiny-vertx-web *       Apache-2.0
+io.smallrye.reactive:smallrye-mutiny-vertx-web-common  *       Apache-2.0
+io.smallrye.reactive:vertx-mutiny-generator    *       Apache-2.0
+io.smallrye:smallrye-context-propagation       *       Apache-2.0
+io.smallrye:smallrye-context-propagation-api   *       Apache-2.0
+io.smallrye:smallrye-context-propagation-storage       *       Apache-2.0
+io.smallrye:smallrye-fault-tolerance-vertx     *       Apache-2.0
+io.vertx:vertx-auth-common     *       Apache-2.0 | Eclipse Public License - v 
1.0 <http://www.eclipse.org/legal/epl-v10.html>
+io.vertx:vertx-bridge-common   *       Apache-2.0 | Eclipse Public License - v 
1.0 <http://www.eclipse.org/legal/epl-v10.html>
+io.vertx:vertx-codegen *       Apache-2.0 | Eclipse Public License - v 1.0 
<http://www.eclipse.org/legal/epl-v10.html>
+io.vertx:vertx-core    *       Apache-2.0 | Eclipse Public License - v 2.0 
<http://www.eclipse.org/legal/epl-v20.html>
+io.vertx:vertx-uri-template    *       Apache-2.0 | Eclipse Public License - v 
1.0 <http://www.eclipse.org/legal/epl-v10.html>
+io.vertx:vertx-web     *       Apache-2.0 | Eclipse Public License - v 2.0 
<http://www.eclipse.org/legal/epl-v20.html>
+io.vertx:vertx-web-common      *       Apache-2.0 | Eclipse Public License - v 
1.0 <http://www.eclipse.org/legal/epl-v10.html>
 net.java.dev.jna:jna   5.8.0   JNA {version}
 org.crac:crac  1.5.0   CRaC {version}
-org.jboss.logging:jboss-logging        3.6.3.Final     Apache-2.0
-org.jboss.logmanager:jboss-logmanager  3.2.1.Final     Apache-2.0
-org.jboss.slf4j:slf4j-jboss-logmanager 2.0.2.Final     Apache-2.0
-org.jctools:jctools-core       4.0.5   Apache-2.0
-org.wildfly.common:wildfly-common      2.0.1   Apache-2.0
+org.jboss.logging:jboss-logging        *       Apache-2.0
+org.jboss.logmanager:jboss-logmanager  *       Apache-2.0
+org.jboss.slf4j:slf4j-jboss-logmanager *       Apache-2.0
+org.jctools:jctools-core       *       Apache-2.0
+org.wildfly.common:wildfly-common      *       Apache-2.0
diff --git a/pom.xml b/pom.xml
index ecd20a03..437174b3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -129,6 +129,26 @@
         </plugins>
         <pluginManagement>
             <plugins>
+                <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>license-maven-plugin</artifactId>
+                    <version>2.10.0</version>
+                    <executions>
+                        <execution>
+                            <id>resolved-pom-licenses</id>
+                            <phase>process-classes</phase>
+                            <goals><goal>add-third-party</goal></goals>
+                            <configuration>
+                                
<excludedScopes>test,provided,system</excludedScopes>
+                                
<fileTemplate>${maven.multiModuleProjectDirectory}/tools/pom-licenses.ftl</fileTemplate>
+                                
<outputDirectory>${project.build.directory}</outputDirectory>
+                                
<thirdPartyFilename>pom-licenses.tsv</thirdPartyFilename>
+                                
<addOutputDirectoryAsResourceDir>false</addOutputDirectoryAsResourceDir>
+                                <force>true</force>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
                 <plugin>
                     <artifactId>maven-antrun-plugin</artifactId>
                     <version>3.1.0</version>
@@ -150,6 +170,7 @@
                                         <arg value="${bundle.notice.path}"/>
                                         <arg value="${project.artifactId}"/>
                                         <arg 
file="${project.build.directory}/bundle-artifacts.properties"/>
+                                        <arg 
file="${project.build.directory}/pom-licenses.tsv"/>
                                     </java>
                                 </target>
                             </configuration>
diff --git a/tools/BundleLicenses.java b/tools/BundleLicenses.java
index 0c294350..22d2ee56 100644
--- a/tools/BundleLicenses.java
+++ b/tools/BundleLicenses.java
@@ -7,10 +7,12 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 import java.util.jar.JarFile;
 import java.util.regex.Pattern;
 
@@ -22,13 +24,51 @@ class BundleLicenses {
 
     private static final Pattern PRIMARY_LICENSE = 
Pattern.compile("(?i)(?:META-INF/)?(?:licen[cs]e(?:\\.(?:txt|md))?|copying(?:\\.txt)?)");
 
+    private static final Pattern APACHE_NAME = Pattern.compile("(?i)(?:the 
)?apache(?: software)?(?: license)?(?:,? version)?[- ]2\\.0");
+    private static final Pattern APACHE_URL = 
Pattern.compile("https?://(?:www\\.apache\\.org/licenses/LICENSE-2\\.0(?:\\.txt)?"
+            + "|repository\\.jboss\\.org/licenses/apache-2\\.0\\.txt)");
+
+    private static Map<String, Set<String>> declaredLicenses(Path report) 
throws IOException {
+        Map<String, Set<String>> declarations = new HashMap<>();
+        for (String line : Files.readAllLines(report)) {
+            String[] fields = line.split("\\t", -1);
+            if (fields.length != 3) {
+                throw new IllegalArgumentException("Invalid Maven license 
declaration in " + report + ": " + line);
+            }
+            String name = fields[1];
+            String url = fields[2];
+            String license = APACHE_NAME.matcher(name).matches() && 
APACHE_URL.matcher(url).matches()
+                    ? "Apache-2.0" : name + " <" + url + ">";
+            declarations.computeIfAbsent(fields[0], ignored -> new 
HashSet<>()).add(license);
+        }
+        return declarations;
+    }
+
     private record ReviewedLicense(String version, String section) {
-        String verify(String id, String[] coordinate, Path jar, String 
supplement, Path legal) {
+        String verify(String id, String[] coordinate, Path jar, String 
supplement, Path legal,
+                Map<String, Set<String>> declarations) {
             String classifier = coordinate.length == 4 ? "-" + coordinate[3] : 
"";
+            if (version.equals("*")) {
+                String filename = jar.getFileName().toString();
+                String prefix = coordinate[1] + "-";
+                String suffix = classifier + ".jar";
+                if (!filename.startsWith(prefix) || 
!filename.endsWith(suffix)) {
+                    throw new IllegalArgumentException("Unexpected filename 
for " + id + ": " + filename);
+                }
+                String resolved = filename.substring(prefix.length(), 
filename.length() - suffix.length());
+                String gav = coordinate[0] + ":" + coordinate[1] + ":" + 
resolved;
+                Set<String> expected = Set.of(section.split(" \\| "));
+                Set<String> actual = declarations.getOrDefault(gav, Set.of());
+                if (!expected.contains("Apache-2.0") || 
!actual.equals(expected)) {
+                    throw new IllegalArgumentException("Review " + legal + " 
for " + gav + ": expected POM licenses "
+                            + expected + ", found " + actual);
+                }
+                return "Apache-2.0";
+            }
             String filename = coordinate[1] + "-" + version + classifier + 
".jar";
             String heading = section.replace("{version}", version);
             if (!jar.getFileName().toString().equals(filename)
-                    || !(heading.equals("Apache-2.0") || 
supplement.contains(heading))) {
+                    || !supplement.contains(heading)) {
                 throw new IllegalArgumentException("Review " + legal + " for " 
+ id + " (" + jar.getFileName()
                         + "): expected " + filename + " and license section " 
+ heading);
             }
@@ -61,6 +101,7 @@ class BundleLicenses {
         Path legal = module.resolve("src/main/legal");
         String supplement = Files.readString(legal.resolve("LICENSE"));
         Map<String, ReviewedLicense> reviewed = readReviewedLicenses(legal);
+        Map<String, Set<String>> declarations = 
declaredLicenses(Path.of(args[7]));
         Properties artifacts = new Properties();
         try (var in = Files.newInputStream(Path.of(args[6]))) {
             artifacts.load(in);
@@ -86,7 +127,7 @@ class BundleLicenses {
             inventory.append("\n").append(path.getFileName()).append("\n");
             ReviewedLicense record = reviewed.get(id);
             if (record != null) {
-                String section = record.verify(id, parts, path, supplement, 
legal);
+                String section = record.verify(id, parts, path, supplement, 
legal, declarations);
                 inventory.append("  Reviewed license: 
").append(section).append("\n");
             }
             boolean primaryLicense = false;
diff --git a/tools/pom-licenses.ftl b/tools/pom-licenses.ftl
new file mode 100644
index 00000000..5795544f
--- /dev/null
+++ b/tools/pom-licenses.ftl
@@ -0,0 +1,6 @@
+<#list dependencyMap as entry>
+<#assign project = entry.getKey()>
+<#list project.licenses as license>
+${project.groupId}:${project.artifactId}:${project.version}    
${(license.name!"")?trim?replace(r"\s+", " ", "r")}     
${(license.url!"")?trim?replace(r"\s+", " ", "r")}
+</#list>
+</#list>
diff --git a/tools/test_bundle_licenses.py b/tools/test_bundle_licenses.py
index 577604db..0fd924a6 100644
--- a/tools/test_bundle_licenses.py
+++ b/tools/test_bundle_licenses.py
@@ -26,7 +26,7 @@ class BundleLicensesTest(unittest.TestCase):
         self.legal.mkdir(parents=True)
         (self.legal / "LICENSE").write_text("Fixture 1.0, MIT\n")
 
-    def assemble(self, files, record="", version="1.0", group="example"):
+    def assemble(self, files, record="", version="1.0", group="example", 
declarations=""):
         jar = self.root / f"fixture-{version}.jar"
         with ZipFile(jar, "w") as archive:
             for name, contents in files.items():
@@ -34,8 +34,10 @@ class BundleLicensesTest(unittest.TestCase):
         (self.legal / "dependencies.tsv").write_text(record)
         properties = self.root / "artifacts.properties"
         properties.write_text(f"{group}\\:fixture\\:jar={jar.as_posix()}\n")
+        report = self.root / "pom-licenses.tsv"
+        report.write_text(declarations)
         return subprocess.run(["java", "-cp", os.pathsep.join(map(str, 
[self.classes, jar])), "BundleLicenses",
-                               ROOT, self.root, self.root / "output", 
"LICENSE", "NOTICE", "bundle", properties],
+                               ROOT, self.root, self.root / "output", 
"LICENSE", "NOTICE", "bundle", properties, report],
                               text=True, capture_output=True)
 
     def test_requires_a_primary_license_or_reviewed_coordinate(self):
@@ -62,6 +64,28 @@ class BundleLicensesTest(unittest.TestCase):
         self.assertNotEqual(result.returncode, 0)
         self.assertIn("other:fixture", result.stderr)
 
+    def test_plain_apache_upgrade_checks_the_resolved_pom(self):
+        record = "example:fixture\t*\tApache-2.0"
+        apache = "example:fixture:2.0\tApache License, Version 
2.0\thttps://www.apache.org/licenses/LICENSE-2.0.txt\n";
+        other = 
"example:fixture:2.0\tMIT\thttps://opensource.org/license/mit\n";
+        result = self.assemble({}, record, version="2.0", declarations=apache)
+        self.assertEqual(result.returncode, 0, result.stderr)
+        for report in ("", apache.replace(":2.0", ":1.0"), other, apache + 
other,
+                       apache.replace("www.apache.org", "example.invalid")):
+            with self.subTest(declarations=report):
+                result = self.assemble({}, record, version="2.0", 
declarations=report)
+                self.assertNotEqual(result.returncode, 0)
+                self.assertIn("expected POM licenses", result.stderr)
+        dual = record + " | MIT <https://opensource.org/license/mit>"
+        result = self.assemble({}, dual, version="2.0", declarations=other + 
apache)
+        self.assertEqual(result.returncode, 0, result.stderr)
+        result = self.assemble({}, dual, version="2.0", declarations=other)
+        self.assertNotEqual(result.returncode, 0)
+        self.assertIn("expected POM licenses", result.stderr)
+        result = self.assemble({}, version="2.0", declarations=apache)
+        self.assertNotEqual(result.returncode, 0)
+        self.assertIn("has no primary license", result.stderr)
+
     def test_keeps_third_party_notice_from_a_nested_bundle(self):
         project = (ROOT / "NOTICE").read_text().strip()
         result = self.assemble({"LICENSE": "Upstream terms", "NOTICE": project 
+ "\n\nA third-party notice"})

Reply via email to