This is an automated email from the ASF dual-hosted git repository.
the-other-tim-brown pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-xtable.git
The following commit(s) were added to refs/heads/main by this push:
new 8306b3a7 [701] Keep third-party license texts out of the thin jars
(#997)
8306b3a7 is described below
commit 8306b3a7e858c644919ae2c8d8102211e067b297
Author: Tim Brown <[email protected]>
AuthorDate: Mon Nov 2 21:16:50 2026 -0500
[701] Keep third-party license texts out of the thin jars (#997)
* [701] Keep third-party license texts out of the thin jars
META-INF/licenses/ lived in src/main/resources of each shaded module, so the
thin jar shipped texts for dependencies it does not contain. The jar plugin
now
excludes it, and each text is added to the bundle by
IncludeResourceTransformer.
validate_bundled_license_texts.py now also checks the thin jars, and fails
when
a curated text never reaches the bundle.
* [701] Drop the per-module transformer comments
* [701] Rebuild the thin jar so shade never re-shades its own output
xtable-spark-runtime is shaded in place. Without clean, maven-jar-plugin
kept the
previous bundle, so shade read META-INF/licenses/ from it and also added the
same text through IncludeResourceTransformer: duplicate entry.
---
AGENTS.md | 1 +
pom.xml | 8 +++-
release/scripts/validate_bundled_license_texts.py | 25 +++++++++++
xtable-aws/pom.xml | 20 +++++++++
xtable-hive-metastore/pom.xml | 48 ++++++++++++++++++++++
.../xtable-hudi-support-extensions/pom.xml | 12 ++++++
xtable-spark-runtime/pom.xml | 4 ++
7 files changed, 116 insertions(+), 2 deletions(-)
diff --git a/AGENTS.md b/AGENTS.md
index cca34af4..34195aa9 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -156,6 +156,7 @@ Notes:
- The generator uses runtime dependency trees plus a small override table for
old artifacts with incomplete Maven license metadata.
- Category B licenses can be present in convenience binaries, but the
validator will warn so they stay visible.
- Missing bundled metadata is treated as a failure.
+- Texts under `src/main/resources/META-INF/licenses/` are kept out of the thin
jar, so each new one also needs an `IncludeResourceTransformer` in the module's
shade config; the validator fails if one is missing.
## GitHub Actions
diff --git a/pom.xml b/pom.xml
index 9802374e..dbdd278b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -683,16 +683,20 @@
<pluginManagement>
<plugins>
<!--
- LICENSE-bundled and NOTICE-bundled are shade transformer
inputs, read
- from target/classes; packaging them too duplicated each
jar's LICENSE (#701).
+ LICENSE-bundled, NOTICE-bundled and META-INF/licenses are
shade transformer
+ inputs, read from target/classes; packaging them too put the
bundle's
+ licensing in the thin jar, which bundles nothing (#701).
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
+ <!-- Shade replaces xtable-spark-runtime's jar in
place; never feed that back in. -->
+ <forceCreation>true</forceCreation>
<excludes>
<exclude>META-INF/LICENSE-bundled</exclude>
<exclude>META-INF/NOTICE-bundled</exclude>
+ <exclude>META-INF/licenses/**</exclude>
</excludes>
</configuration>
</plugin>
diff --git a/release/scripts/validate_bundled_license_texts.py
b/release/scripts/validate_bundled_license_texts.py
index 78851a4f..1c385b2c 100644
--- a/release/scripts/validate_bundled_license_texts.py
+++ b/release/scripts/validate_bundled_license_texts.py
@@ -66,6 +66,8 @@ EMBEDDED_TEXTS = {"LICENSE.datanucleus-asm.txt":
"org.datanucleus:datanucleus-co
# One canonical LICENSE and NOTICE per jar, and META-INF/licenses as the only
home for texts (#701).
CANONICAL = ("META-INF/LICENSE", "META-INF/NOTICE")
NOT_PACKAGED = ("META-INF/LICENSE-bundled", "META-INF/NOTICE-bundled")
+# The texts this project curates; shade adds each to the bundle, never the
thin jar.
+CURATED_TEXTS = pathlib.Path("src/main/resources/META-INF/licenses")
LICENSE_LIKE = re.compile(r"licen[cs]e|notice", re.IGNORECASE)
# Shade cannot merge module descriptors, so it drops them from every
dependency.
@@ -309,6 +311,12 @@ def check(module: pathlib.Path, jar_path: pathlib.Path) ->
dict[str, list]:
"partial": [],
"stale_includes": [],
"layout": layout_problems(names),
+ # A curated text whose IncludeResourceTransformer was forgotten.
+ "not_shaded": sorted(
+ f"META-INF/licenses/{text.name}"
+ for text in (module / CURATED_TEXTS).glob("*")
+ if f"META-INF/licenses/{text.name}" not in names
+ ),
}
bundled = []
for group, artifact, version, classifier in coords:
@@ -368,6 +376,7 @@ REPORTS = [
("unresolved", "dependencies that could not be resolved or have no
license"),
("stale_includes", "shade <include> entries that no longer exist in the
runtime dependency tree"),
("layout", "license files outside one canonical LICENSE, NOTICE and
META-INF/licenses/"),
+ ("not_shaded", "curated license texts with no IncludeResourceTransformer
in the module's pom"),
]
# Published shaded modules; xtable-utilities is not published yet (see
AGENTS.md).
@@ -386,6 +395,7 @@ def module_jars(module: pathlib.Path) -> list[pathlib.Path]:
def main() -> None:
"""Check every bundled jar, or only those named on the command line."""
jars = [pathlib.Path(a) for a in sys.argv[1:]]
+ thin = []
unbuilt = []
if not jars:
for module in shade_modules():
@@ -393,6 +403,9 @@ def main() -> None:
continue
found = module_jars(module)
jars += found
+ # The unshaded jar published beside the bundle; none where shade
replaces it.
+ thin += [jar for jar in (module /
"target").glob(f"{module.name}*.jar")
+ if not jar.name.endswith(NOT_BUNDLES) and jar not in
found]
if not found:
unbuilt.append(module.relative_to(ROOT))
if not jars:
@@ -418,6 +431,18 @@ def main() -> None:
print(f" - {entry}")
if not failed:
print(f"OK {jar_path.name}: {result['count']} bundled
non-Apache-2.0 dependencies, all with license texts.")
+ for jar_path in thin:
+ with zipfile.ZipFile(jar_path) as jar:
+ names = [name for name in jar.namelist() if not name.endswith("/")]
+ # It bundles nothing, so it carries none of the bundle's texts either.
+ problems = layout_problems(names) + [n for n in names if
n.startswith("META-INF/licenses/")]
+ if problems:
+ status = 1
+ print(f"FAIL {jar_path.name}: thin jar license layout problems:")
+ for problem in problems:
+ print(f" - {problem}")
+ else:
+ print(f"OK {jar_path.name}: thin jar, no third-party license
texts.")
raise SystemExit(status)
diff --git a/xtable-aws/pom.xml b/xtable-aws/pom.xml
index 9652042d..9d58eb7e 100644
--- a/xtable-aws/pom.xml
+++ b/xtable-aws/pom.xml
@@ -142,6 +142,26 @@
<resource>META-INF/NOTICE</resource>
<file>target/classes/META-INF/NOTICE-bundled</file>
</transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-checker-qual</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-checker-qual</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-javax.annotation-api</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-javax.annotation-api</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-paranamer</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-paranamer</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-reactive-streams</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-reactive-streams</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-zstd-jni</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-zstd-jni</file>
+ </transformer>
</transformers>
<artifactSet>
<includes>
diff --git a/xtable-hive-metastore/pom.xml b/xtable-hive-metastore/pom.xml
index 0319fff1..1f5107f6 100644
--- a/xtable-hive-metastore/pom.xml
+++ b/xtable-hive-metastore/pom.xml
@@ -379,6 +379,54 @@
<resource>META-INF/NOTICE</resource>
<file>target/classes/META-INF/NOTICE-bundled</file>
</transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-ST4</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-ST4</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-antlr-runtime</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-antlr-runtime</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-checker-qual</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-checker-qual</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-javax.annotation-api</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-javax.annotation-api</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-javolution</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-javolution</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-jersey-json</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-jersey-json</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-jline</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-jline</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-leveldbjni-all</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-leveldbjni-all</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-paranamer</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-paranamer</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-transaction-api</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-transaction-api</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-zstd-jni</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-zstd-jni</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE.datanucleus-asm.txt</resource>
+
<file>target/classes/META-INF/licenses/LICENSE.datanucleus-asm.txt</file>
+ </transformer>
</transformers>
<artifactSet>
<includes>
diff --git a/xtable-hudi-support/xtable-hudi-support-extensions/pom.xml
b/xtable-hudi-support/xtable-hudi-support-extensions/pom.xml
index 22489854..14912e45 100644
--- a/xtable-hudi-support/xtable-hudi-support-extensions/pom.xml
+++ b/xtable-hudi-support/xtable-hudi-support-extensions/pom.xml
@@ -245,6 +245,18 @@
<resource>META-INF/NOTICE</resource>
<file>target/classes/META-INF/NOTICE-bundled</file>
</transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-checker-qual</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-checker-qual</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-paranamer</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-paranamer</file>
+ </transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-slf4j-api</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-slf4j-api</file>
+ </transformer>
</transformers>
<artifactSet>
<includes>
diff --git a/xtable-spark-runtime/pom.xml b/xtable-spark-runtime/pom.xml
index 94e057a6..d23a3ae5 100644
--- a/xtable-spark-runtime/pom.xml
+++ b/xtable-spark-runtime/pom.xml
@@ -348,6 +348,10 @@
<resource>META-INF/NOTICE</resource>
<file>target/classes/META-INF/NOTICE-bundled</file>
</transformer>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+
<resource>META-INF/licenses/LICENSE-checker-qual</resource>
+
<file>target/classes/META-INF/licenses/LICENSE-checker-qual</file>
+ </transformer>
</transformers>
</configuration>
</execution>