Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of MANIFEST.MF attributes #435

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

jerboaa
Copy link
Collaborator

@jerboaa jerboaa commented Jul 10, 2024

Previously, the build script would add these two attributes irrespective whether or not they'd exist in the Graal artefacts:

  Specification-Version
  Implementation-Version

With this patch, only updates to the Implementation-Version attribute are done based on the maven version in use. Specification-Version is only added if it's not yet there in a jar or source jar file.

Closes: Karm/mandrel-integration-tests#270

Previously, the build script would add these two attributes irrespective
whether or not they'd exist in the Graal artefacts:

  Specification-Version
  Implementation-Version

With this patch, only updates to the Implementation-Version attribute
are done based on the maven version in use. Specification-Version is
only added if it's not yet there in a jar or source jar file.

Closes: Karm/mandrel-integration-tests#270
@jerboaa jerboaa requested a review from zakkak July 10, 2024 17:48
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 10, 2024
@jerboaa
Copy link
Collaborator Author

jerboaa commented Jul 10, 2024

The GraalVM maven artifact's MANIFEST.MF entries before the patch:

$ for i in $(find -name \*.jar); do echo "Inspecting $i"; unzip -d test $i 2>&1 > /dev/null; pushd test > /dev/null; grep -E 'Implementation-Version|Specification-Version' META-INF/MANIFEST.MF; popd > /dev/null; rm -rf test; done
Inspecting ./nativeimage/jvmti-agent-base/24.2.0.SNAPSHOT/jvmti-agent-base-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/jvmti-agent-base/24.2.0.SNAPSHOT/jvmti-agent-base-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/native-image-base/24.2.0.SNAPSHOT/native-image-base-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/native-image-base/24.2.0.SNAPSHOT/native-image-base-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/objectfile/24.2.0.SNAPSHOT/objectfile-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/objectfile/24.2.0.SNAPSHOT/objectfile-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/pointsto/24.2.0.SNAPSHOT/pointsto-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/pointsto/24.2.0.SNAPSHOT/pointsto-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm/24.2.0.SNAPSHOT/svm-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm/24.2.0.SNAPSHOT/svm-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-agent/24.2.0.SNAPSHOT/svm-agent-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-agent/24.2.0.SNAPSHOT/svm-agent-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-configure/24.2.0.SNAPSHOT/svm-configure-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-configure/24.2.0.SNAPSHOT/svm-configure-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-diagnostics-agent/24.2.0.SNAPSHOT/svm-diagnostics-agent-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-diagnostics-agent/24.2.0.SNAPSHOT/svm-diagnostics-agent-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-driver/24.2.0.SNAPSHOT/svm-driver-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-driver/24.2.0.SNAPSHOT/svm-driver-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-foreign/24.2.0.SNAPSHOT/svm-foreign-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-foreign/24.2.0.SNAPSHOT/svm-foreign-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./compiler/compiler/24.2.0.SNAPSHOT/compiler-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./compiler/compiler/24.2.0.SNAPSHOT/compiler-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./truffle/truffle-compiler/24.2.0.SNAPSHOT/truffle-compiler-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./truffle/truffle-compiler/24.2.0.SNAPSHOT/truffle-compiler-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/collections/24.2.0.SNAPSHOT/collections-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/collections/24.2.0.SNAPSHOT/collections-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/graal-sdk/24.2.0.SNAPSHOT/graal-sdk-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/graal-sdk/24.2.0.SNAPSHOT/graal-sdk-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/mandrel-packaging-wrapper-linux-amd64/24.2.0.SNAPSHOT/mandrel-packaging-wrapper-linux-amd64-24.2.0.SNAPSHOT.jar
grep: META-INF/MANIFEST.MF: No such file or directory
Inspecting ./sdk/nativeimage/24.2.0.SNAPSHOT/nativeimage-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/nativeimage/24.2.0.SNAPSHOT/nativeimage-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/word/24.2.0.SNAPSHOT/word-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/word/24.2.0.SNAPSHOT/word-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./polyglot/polyglot/24.2.0.SNAPSHOT/polyglot-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Inspecting ./polyglot/polyglot/24.2.0.SNAPSHOT/polyglot-24.2.0.SNAPSHOT-sources.jar
grep: META-INF/MANIFEST.MF: No such file or directory

Note for example this:

Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT

That is, library-support-24.2.0.SNAPSHOT.jar has duplicate Specification-Version. One at 0.0 which is added by mandrel packaging. Also for Implementation-Version: 24.2.0-dev where it should only have one entry like so:

Implementation-Version: 24.2.0.SNAPSHOT

After the patch

$ for i in $(find -name \*.jar); do echo "Inspecting $i"; unzip -d test $i 2>&1 > /dev/null; pushd test > /dev/null; grep -E 'Implementation-Version|Specification-Version' META-INF/MANIFEST.MF; popd > /dev/null; rm -rf test; done
Inspecting ./nativeimage/jvmti-agent-base/24.2.0.SNAPSHOT/jvmti-agent-base-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/jvmti-agent-base/24.2.0.SNAPSHOT/jvmti-agent-base-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/native-image-base/24.2.0.SNAPSHOT/native-image-base-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/native-image-base/24.2.0.SNAPSHOT/native-image-base-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/objectfile/24.2.0.SNAPSHOT/objectfile-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/objectfile/24.2.0.SNAPSHOT/objectfile-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/pointsto/24.2.0.SNAPSHOT/pointsto-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/pointsto/24.2.0.SNAPSHOT/pointsto-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm/24.2.0.SNAPSHOT/svm-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm/24.2.0.SNAPSHOT/svm-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-agent/24.2.0.SNAPSHOT/svm-agent-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-agent/24.2.0.SNAPSHOT/svm-agent-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-configure/24.2.0.SNAPSHOT/svm-configure-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-configure/24.2.0.SNAPSHOT/svm-configure-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-diagnostics-agent/24.2.0.SNAPSHOT/svm-diagnostics-agent-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-diagnostics-agent/24.2.0.SNAPSHOT/svm-diagnostics-agent-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-driver/24.2.0.SNAPSHOT/svm-driver-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-driver/24.2.0.SNAPSHOT/svm-driver-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-foreign/24.2.0.SNAPSHOT/svm-foreign-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-foreign/24.2.0.SNAPSHOT/svm-foreign-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./compiler/compiler/24.2.0.SNAPSHOT/compiler-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./compiler/compiler/24.2.0.SNAPSHOT/compiler-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./truffle/truffle-compiler/24.2.0.SNAPSHOT/truffle-compiler-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./truffle/truffle-compiler/24.2.0.SNAPSHOT/truffle-compiler-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./sdk/collections/24.2.0.SNAPSHOT/collections-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/collections/24.2.0.SNAPSHOT/collections-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./sdk/graal-sdk/24.2.0.SNAPSHOT/graal-sdk-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/graal-sdk/24.2.0.SNAPSHOT/graal-sdk-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./sdk/mandrel-packaging-wrapper-linux-amd64/24.2.0.SNAPSHOT/mandrel-packaging-wrapper-linux-amd64-24.2.0.SNAPSHOT.jar
grep: META-INF/MANIFEST.MF: No such file or directory
Inspecting ./sdk/nativeimage/24.2.0.SNAPSHOT/nativeimage-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/nativeimage/24.2.0.SNAPSHOT/nativeimage-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./sdk/word/24.2.0.SNAPSHOT/word-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/word/24.2.0.SNAPSHOT/word-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./polyglot/polyglot/24.2.0.SNAPSHOT/polyglot-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Inspecting ./polyglot/polyglot/24.2.0.SNAPSHOT/polyglot-24.2.0.SNAPSHOT-sources.jar
grep: META-INF/MANIFEST.MF: No such file or directory

That is we have after the patch for library-support-24.2.0.SNAPSHOT.jar:

Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT

No more the duplicate entries and the Implementation-Version matches the maven version.

Thoughts?

build.java Show resolved Hide resolved
Copy link
Collaborator

@zakkak zakkak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. My only hesitation is about the Specification-Version not being the same with the Implementation-Version.

@jerboaa
Copy link
Collaborator Author

jerboaa commented Jul 11, 2024

LGTM. My only hesitation is about the Specification-Version not being the same with the Implementation-Version.

Thanks for the review! This is pre-existing. We were adding Specification-Version: 0.0 unconditionally before while setting "Implementation-Version: " + options.mavenVersion. The comment of the method suggests it wasn't important. Also, what would we set the specification version to if it's not there in the original jar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[24.2] "Duplicate name in Manifest" warnings on latest graal master builds
2 participants