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

Runtime project dependencies are not included in the shadowJar #152

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

Runtime project dependencies are not included in the shadowJar #152

jpdamon opened this issue Jul 24, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@jpdamon
Copy link

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
Copy link
Collaborator

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
Copy link

I have posted a reproducible case in this thread: https://discuss.gradle.org/t/gradle-doesnt-rebuild-submodules-on-resolving-configurations/13468/3

@johnrengelman
Copy link
Collaborator

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: https://github.com/johnrengelman/shadow/blob/5013695772b083d2d2b79d809b89af4761b686da/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java#L296 as dependencies for the task.

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

shadowJar.dependsOn shadowJar.configurations

@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
Copy link
Collaborator

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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants