Runtime project dependencies are not included in the shadowJar #152

Closed
jpdamon opened this Issue Jul 24, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@jpdamon

jpdamon commented Jul 24, 2015

I have a multi-module build with both compile and runtime dependencies on other projects:

dependencies {
    compile project(":common")

    runtime project(":agents:mqtt")
}

I would expect both to end up in the shadow jar when running gradle shadowJar, but only the "compile project" ones do.

As a workaround, gradle build shadowJar will cause both compile and runtime project dependencies to be bundled.

@johnrengelman

This comment has been minimized.

Show comment
Hide comment
@johnrengelman

johnrengelman Nov 28, 2015

Owner

shadowJar by default depends on the runtime scope, so all it's dependencies should be included. if you have a reproducible example you can post, I'd be happy to look.

Owner

johnrengelman commented Nov 28, 2015

shadowJar by default depends on the runtime scope, so all it's dependencies should be included. if you have a reproducible example you can post, I'd be happy to look.

@ddimtirov

This comment has been minimized.

Show comment
Hide comment
@johnrengelman

This comment has been minimized.

Show comment
Hide comment
@johnrengelman

johnrengelman Dec 30, 2015

Owner

Thanks @ddimtirov.
I was able to reproduce the error and I see what the problem is.
There issue is coming from this line here: https://github.com/johnrengelman/shadow/blob/master/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java#L68-L71

That line resolves the configuration and sets the resulting file paths as an input for the task but in this process it's losing the context of the task dependency that produced that file.

I believe this fix is that we need to declare this method:

public List<Configuration> getConfigurations() {
as dependencies for the task.

In fact adding this line to the build.gradle fixed the issue:

shadowJar.dependsOn shadowJar.configurations
Owner

johnrengelman commented Dec 30, 2015

Thanks @ddimtirov.
I was able to reproduce the error and I see what the problem is.
There issue is coming from this line here: https://github.com/johnrengelman/shadow/blob/master/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java#L68-L71

That line resolves the configuration and sets the resulting file paths as an input for the task but in this process it's losing the context of the task dependency that produced that file.

I believe this fix is that we need to declare this method:

public List<Configuration> getConfigurations() {
as dependencies for the task.

In fact adding this line to the build.gradle fixed the issue:

shadowJar.dependsOn shadowJar.configurations

@johnrengelman johnrengelman added the bug label Dec 30, 2015

@johnrengelman johnrengelman self-assigned this Dec 30, 2015

@johnrengelman johnrengelman added this to the 1.2.3 milestone Dec 30, 2015

@johnrengelman johnrengelman modified the milestones: 2.0.0, 1.2.3 Feb 18, 2016

@johnrengelman johnrengelman modified the milestones: 1.4.0, 2.0.0 Jun 24, 2016

@johnrengelman

This comment has been minimized.

Show comment
Hide comment
@johnrengelman

johnrengelman Nov 3, 2016

Owner

Fixed with 5013695

Owner

johnrengelman commented Nov 3, 2016

Fixed with 5013695

@johnrengelman johnrengelman modified the milestones: 1.2.4, 1.3.0 Nov 3, 2016

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