Uploaded image for project: 'Maven Shade Plugin'
  1. Maven Shade Plugin
  2. MSHADE-400

Self-minimisation with custom entry points

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.4
    • 3.5.0
    • None

    Description

      While discussing MSHADE-366, rmannibucau refused to merge a simple workaround suppressing the warning target/classes (access denied) during minimisation (option minimizeJar), suggesting that instead directories should be handled as a first-class class container, just like dependency JARs.

      • He implemented that for DefaultShader, which has no effect on minimisation.
      • So I also implemented it for MinijarFilter. To my surprise, it had no effect either, because minimisation is currently just implemented for dependencies, not for the target module itself.

      So what we need here is self-minimisation, i.e. removal of unneeded classes in the target module itself. For boot-strapping reasons - we need starting points for class dependency analysis - it is necessary to add a new plugin parameter entryPoints, taking a set of fully-qualified class names as its input. If present and minimizeJar is active, it will treat only the defined entry points (e.g. classes with main methods, but can be any type of class) as starting points for dependency analysis instead of all classes of the target module.

      This feature should also correctly consider Java Service Provider (SPI) configuration files according to the implementation of MSHADE-313. I.e., services are to be considered as entry points if and only if there is an SPI config file and something like ServiceLoader.load( MyServiceProvider.class ) is present in a Java entry point class or one of its (transitive) dependency classes. In that case, both the service provider interface and all implementations defined in the SPI config file are being kept in the minimised JAR. Due to unified handling of directories and JARs as input sources for minimisation, this should work transparently.

      I already have a first implementation which I am going to push and link to this issue soon.

      Attachments

        Issue Links

          Activity

            People

              michael-o Michael Osipov
              kriegaex Alexander Kriegisch
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: