Repository navigation
build: add Implementation-Version to packaged jars - #4884
jabrailkhalil wants to merge 1 commit into
Conversation
|
|
| * as {@code Implementation-Version}. These integration tests run after the jar is packaged | ||
| * and assert on the real manifest. | ||
| */ | ||
| class ImplementationVersionIT { |
There was a problem hiding this comment.
Nice instinct adding coverage here — declarative Maven config changes like this are easy to leave unverified. One thing worth being explicit about in the class Javadoc or PR description: these tests verify that maven-jar-plugin and the JVM behave as documented (i.e. that the config was wired correctly), not any Kroxylicious-owned logic. That's still useful — it'd catch a scope/POM-inheritance mistake — but it's a different kind of guarantee than testing our own code, and worth naming so a future reader doesn't read it as "our version-reporting logic is tested" when what's actually pinned down is Maven's own contract.
There was a problem hiding this comment.
+1 to adding a test, however, I've got an alternative test approach to suggest to you both.
Instead on adding a new IT test, let's give the lint workflow the responsibility to check that the JARs metadata in in the right shape. It already checks POM metadata - so the new responsibility is in keeping.
The POC tests kroxylicious-api.jar. We could extend it to check all the other shippable JARs. I'm not sure I'd go quite that far. Checking one JAR is enough for me.
If we like the idea, I suggest merging into your @jabrailkhalil PR, and removing the IT test.
WDYAT?
| private static final String EXPECTED_VERSION = System.getProperty("implementation.version"); | ||
|
|
||
| private Path packagedJar() { | ||
| return Path.of("target", "kroxylicious-api-" + EXPECTED_VERSION + ".jar"); |
There was a problem hiding this comment.
This re-derives the packaged jar's filename ("target" + artifactId + version) by hand, duplicating naming knowledge the POM already owns. If finalName or the output directory is ever customized in kroxylicious-api/pom.xml, this will silently drift out of sync. I'd rather the POM hand the test the fully-resolved path directly, e.g. ${project.build.directory}/${project.build.finalName}.jar as a system property, than have the test reconstruct Maven's naming convention itself.
|
|
||
| @Test | ||
| void packagedJarManifestCarriesImplementationEntries() throws Exception { | ||
| try (var jarFile = new JarFile(packagedJar().toFile())) { |
There was a problem hiding this comment.
This will fail with a raw FileNotFoundException if the jar hasn't been packaged yet — for example if this IT is somehow invoked before the package phase, target/ is stale/cleaned, or the version property resolves to something unexpected. Suggest guarding with assumeThat(packagedJar()).exists() before opening the jar, so a missing artifact skips the test with a clear explanation rather than failing on an opaque exception. Same guard would help the URLClassLoader test below (line 47), which hits the same packagedJar() path.
Add a Python script to validate JAR manifest implementation entries and integrate it into the lint workflow as a proof of concept for the kroxylicious-api module. This provides an alternative to the integration test approach in PR kroxylicious#4884, validating build artifacts directly during the lint phase similar to how we validate POM metadata. The script validates that maven-jar-plugin's addDefaultImplementationEntries correctly populates Implementation-Title, Implementation-Version, and Implementation-Vendor in the JAR manifest. Related: kroxylicious#4884 Assisted-by: Claude Sonnet 4.5 <[email protected]> Signed-off-by: Keith Wall <[email protected]>
|
@jabrailkhalil thanks for picking up this work. it is appreciated. you'll need put the DCO signoff on your commit(s) too. |
5fd6cde to
486b97c
Compare
Configure maven-jar-plugin to add the default implementation manifest entries and validate the packaged kroxylicious-api JAR in the existing lint workflow. The validation checks the exact Maven finalName artifact and keeps packaging-contract verification out of the runtime test suite. Assisted-by: ChatGPT GPT-5.6 Sol Co-authored-by: Keith Wall <[email protected]> Signed-off-by: Keith Wall <[email protected]> Signed-off-by: jabrailkhalil <[email protected]> Signed-off-by: Jabrail <[email protected]>
486b97c to
8f708f3
Compare



Summary
Adds
Implementation-Title,Implementation-Version, andImplementation-Vendormanifest entries to every packaged jar, sourced from the module's effective POM viamaven-jar-plugin'saddDefaultImplementationEntries.Closes #4666
Changes
pom.xml(parent): configuredmaven-jar-pluginin<pluginManagement>with<addDefaultImplementationEntries>true</addDefaultImplementationEntries>. Aggregator (pompackaging) modules never invoke the jar plugin, so this is harmless to them.kroxylicious-api/pom.xml: enables the failsafe plugin so an integration test can assert on the packaged jar (it runs after thepackagephase).kroxylicious-api/.../ImplementationVersionIT.java: three checks:Implementation-*entries;Class.getPackage().getImplementationVersion()returns the project version for a class loaded from the jar;nullread there.Verification
Local build (JDK 21, Maven 3.9.11):
BUILD SUCCESS, failsafe ranImplementationVersionITwith 3 tests, 0 failures.jar:3.5.1:jarproducedkroxylicious-api-0.25.0-SNAPSHOT.jarwhose manifest contains:Implementation-Version: 0.25.0-SNAPSHOT,Implementation-Title: Kroxylicious API,Implementation-Vendor: Kroxylicious.Note: the full unit suite was not runnable on this Windows host because the pre-existing
UtilsTest#testFileAsStringNamedPiperequiresmkfifo(Linux-only; unaffected by this change).Commits are signed off and carry an
Assisted-by:trailer per AGENTS.md.