GradleUp / GradleUp/shadow

Add excluded dependencies to the shadow configuration automatically

Open
#265 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Kotlin
Stars
4.2k
Forks
425
Avg merge
3h 52m
Merged PRs (30d)
88

Description

In my project I have to relocate a dependency because it clashes with a different version of the same dependency in the environment where my project is used. So I do:

dependencies {
    compile 'org.metaborg:org.metaborg.core:2.1.0-SNAPSHOT'
    compile 'commons-io:commons-io:2.4'
}

shadowJar {
    relocate 'org.apache.commons.io', 'shadow.org.apache.commons.io'
}

Now, because I relocated the dependency, I have to include in my shadowed jar all dependencies that themselves depend on the relocated dependency. But these dependencies transitively depend on other dependencies that I would like to exclude from the Jar. They should just be normal dependencies.

shadowJar {
    relocate 'org.apache.commons.io', 'shadow.org.apache.commons.io'

    dependencies {
        include(dependency('org.metaborg::'))
        include(dependency('commons-io:commons-io'))
   }
}

Doing this, I would expect the excluded (transitive) dependencies to be added to the shadow configuration automatically, since they are still dependencies my project or the shadowed jars. This appears not to be the case, and I would have to manually add all transitive dependencies to the shadow configuration. This is error prone, and as soon as one of my dependencies changes its own dependencies, I'd have to change my script.

Is there a way to add dependencies not included in the uber jar automatically to the shadow configuration?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the shadowJar dependencies block and how excluded transitive dependencies are handled in the shadow configuration. Done means dependencies omitted from the uber JAR are added to the shadow configuration automatically without manually listing every transitive dependency; the issue names no files or tests to run.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.