Skip to content

Add original artifact name to FileTreeElement #913

Closed as not planned
Closed as not planned

Description

@uhyonc

Shadow Version

8.1.1

Gradle Version

7.5.3

Expected Behavior

Transformers should allow access to the Jar file path containing the FileTreeElement.
This is for implementing the method:
boolean canTransformResource(FileTreeElement element)
For example, I would like to be able to do something like

class MyTransformer implements Transformer {
    boolean canTransformResource(FileTreeElement element) {
        if (element instanceof com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction.ArchiveFileTreeElement
            && element.classFile && element.jarFile.path.contains('grpc-core-1.19.0.jar')) {
            return false
        }
        return true 
    }
   ...
}

This is useful for allowing us custom mechanisms to override which classes to be used (e.g. when multiple dependencies have the same class files in it...).

Actual Behavior

ShadowCopyAction.ArchiveFileTreeElement is the actual implementation class passed as the element. However, this does not have any information on the containing jar file.

Gradle Build Script(s)

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)

Activity

  1. reopened this on Mar 23, 2024
  2. uhyonc commented on Mar 23, 2024

    @uhyonc
    Author

    In fact, another issue is that ".class" files are not getting transformed... Actually I don't necessarily want it to be transformed, just a way to define the policy for which dependency gets priority when there are class file conflicts.

  3. uhyonc commented on Mar 23, 2024

    @uhyonc
    Author

    A similar request for Relocator as well... e.g. RelocatePathContext / RelocateClassContext should hold information about the dependency and/or the jar file it came from.

  4. Goooler commented on Feb 28, 2025

    @Goooler
    Member

    ArchiveFileTreeElement has been dropped in #1233, may have to add something to FileTreeElement.

  5. changed the title [-]Add a getter on ShadowCopyAction.ArchiveFileTreeElement to access the containing jar file name[/-] [+]Add original artifact name to `FileTreeElement`[/+] on Mar 13, 2025
  6. Goooler commented on Jul 31, 2025

    @Goooler
    Member

    Filed a new issue to gradle/gradle#34493.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions