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

Manifest.from(Object...) does not support merging Manifest implementations #20928

Closed
bjhargrave opened this issue Jun 3, 2022 · 0 comments · Fixed by #20929
Closed

Manifest.from(Object...) does not support merging Manifest implementations #20928

bjhargrave opened this issue Jun 3, 2022 · 0 comments · Fixed by #20929
Assignees
Labels
a:bug in:java-plugins java-library, java, java-base, java-platform, java-test-fixtures
Milestone

Comments

@bjhargrave
Copy link
Contributor

bjhargrave commented Jun 3, 2022

Expected Behavior

One should be able to pass an implementation of org.gradle.api.java.archives.Manifest to Manifest.from(Object...) to get the argument manifest merged into the receiver manifest.

The javadoc indicates this is supported.

Current Behavior

The current implementation of DefaultManifestMergeSpec requires the manifest object to be an instance of the internal DefaultManifest type:

rather than the Manifest type. When the manifest object is not an instance of the internal DefaultManifest type, the code attempts to resolve the manifest object as a file path which fails.

Context

The is affecting the use of custom manifest object in plugins as they cannot merge a manifest object unless it is of the internal DefaultManifest type.

Steps to Reproduce

This can be seen when using the latest fix bndtools/bnd#5276 to the Bnd Gradle plugin (6.4.0-SNAPSHOT) when building JUnit 5 which also uses the com.github.johnrengelman.shadow plugin. These two plugins interact over the jar task's manifest object. With the Bnd fix, the following exception occurs.

Caused by: org.gradle.internal.typeconversion.UnsupportedNotationException: Cannot convert the provided notation to a File or URI: org.gradle.api.java.archives.internal.DefaultManifest@1ab3a446.
The following types/formats are supported:
  - A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
  - A String or CharSequence URI, for example 'file:/usr/include'.
  - A File instance.
  - A Path instance.
  - A Directory instance.
  - A RegularFile instance.
  - A URI or URL instance.
  - A TextResource instance.
        at org.gradle.internal.typeconversion.ErrorHandlingNotationParser.parseNotation(ErrorHandlingNotationParser.java:57)
        at org.gradle.api.internal.file.AbstractFileResolver.convertObjectToFile(AbstractFileResolver.java:105)
        at org.gradle.api.internal.file.AbstractBaseDirFileResolver.doResolve(AbstractBaseDirFileResolver.java:63)
        at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:74)
        at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:48)
        at org.gradle.api.java.archives.internal.DefaultManifest.read(DefaultManifest.java:281)
        at org.gradle.api.java.archives.internal.DefaultManifest.<init>(DefaultManifest.java:77)
        at org.gradle.api.java.archives.internal.DefaultManifestMergeSpec.createManifest(DefaultManifestMergeSpec.java:155)
        at org.gradle.api.java.archives.internal.DefaultManifestMergeSpec.merge(DefaultManifestMergeSpec.java:84)
        at org.gradle.api.java.archives.internal.DefaultManifestMergeSpec$merge.call(Unknown Source)
        at com.github.jengelman.gradle.plugins.shadow.tasks.DefaultInheritManifest$_getEffectiveManifest_closure1.doCall(DefaultInheritManifest.groovy:65)

I have a PR I will submit with the fix for this issue.

Your Environment

Build scan URL:
https://scans.gradle.com/s/huhyrwmnaz73w

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug in:java-plugins java-library, java, java-base, java-platform, java-test-fixtures
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants