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

ShadowJar runs extremely slow compared to fatJar #359

Closed
StFS opened this issue Feb 6, 2018 · 10 comments
Closed

ShadowJar runs extremely slow compared to fatJar #359

StFS opened this issue Feb 6, 2018 · 10 comments

Comments

@StFS
Copy link

StFS commented Feb 6, 2018

Shadow Version

2.0.2

Gradle Version

4.3.1

Expected Behavior

shadowJar should be able to create a jar file in roughly the same time as my previous fatJar task.

Actual Behavior

shadowJar takes 15,5 hourse to run while fatJar finishes in ~4 minutes. The resulting jar file is around 150mb in size. shadowJar does eventually finish (I left it running last night and it finished as I said previously in more than 15 hours).

Gradle Build Script(s)

The fat jar part:

    task fatJar(type: Jar) {
        manifest manifestTemplate
        zip64 true
        baseName = getProjectFullName() + '-all'
        destinationDir = file("${buildDir}/distributions")
        from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } {
            exclude 'META-INF/*'
        }
        with jar
    }

The shadowJar part:

    apply plugin: 'com.github.johnrengelman.plugin-shadow'

    shadowJar {
        mainClassName = "com.my.client.ClientClass"
        zip64 true
    }

The project is a multi-project so the specific sub-project that I'm trying to build as a fatJar/shadowJar has dependencies on both other sub-projects as well as external JAR libraries.

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

Don't have one, deleted the one that got generated in 15 hours but it did look like it was similar in size as the one generated by the fatJar task.

What can cause such a huge slowdown?

@johnrengelman
Copy link
Collaborator

johnrengelman commented Feb 11, 2018

You haven't provided enough information to make any type of guess why you would experiencing that magnitude of slowness. In every other case and the reason why I wrote Shadow in the first place was because it was faster than using the zipTree method as it doesn't incur I/O costs by writing to the disk.

I'm going to close this issue as it doesn't contain any particulars.

@michel-zededa
Copy link

Hi,

i'm actually seeing the same issue, but not sure what to provide for debugging?

@victorbr
Copy link

victorbr commented Apr 23, 2018

I believe I'm reproducing this using the following build.gradle file with Gradle 4.7 (no source files necessary)

buildscript {
    repositories {
        mavenCentral()
    }
}

plugins {
    id 'com.github.johnrengelman.plugin-shadow' version '2.0.3'
}

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile "com.hubspot.dropwizard:dropwizard-guice:1.0.6.0"
}

The problem disappears when I replace the plugins section by

    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.3'
    }

(inside buildscript) and

apply plugin: 'com.github.johnrengelman.shadow'

@johnrengelman
Copy link
Collaborator

@victorbr - you should be using the 2nd plugin. The first one is for shadowing Gradle plugins and configures shadow to relocate all dependencies. Dropwizard has a lot of transitive dependencies so that will obviously take longer.

@johnrengelman
Copy link
Collaborator

This could also be related to
#364 and
#374

There is a 2.0.4-SNAPSHOT that has some changes to address this that you could try.

@madorb
Copy link

madorb commented Jul 17, 2018

runs INCREDIBLY, unusably, slowly for me as well. macos, gradle 4.9, shadow 2.0.3

@johnrengelman
Copy link
Collaborator

@madorb have you tried version 2.0.4 that has some fixes for potential causes?

@sg-rs
Copy link

sg-rs commented Jul 20, 2022

Same here. FatJar takes 40 seconds. Shadow does not complete in 15 Minutes

@sg-rs
Copy link

sg-rs commented Jul 20, 2022

For an unexplainable reason using the gradlew command insted of gradle works.

This works (40 seconds):
./gradlew shadowJar

This not (15 Minutes, not completing the build):
gradle shadowJar

@sg-rs
Copy link

sg-rs commented Jul 20, 2022

Maybe this is relevant:

gradlew used Gradle 7.4.2

gradle used Gradle 7.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants