Code Monkey home page Code Monkey logo

Comments (10)

mgroth0 avatar mgroth0 commented on May 28, 2024 1

You may be right. Just speaking as a fellow user though, I have found that setting repository content filtering has benefits beyond just performance; it has also helped me make builds more deterministic and prevent strange dependency conflicts that can occasionally arise since gradle is sensitive to the order that repositorties are defined. It was tedius for me to setup but I do not regret it. Though, its understandable that for your project it might be less realistic.

from gradle.

kriegaex avatar kriegaex commented on May 28, 2024 1
  1. https://github.com/kriegaex/SO_AJ_GradleFreefairAspectNotFiring_78167916
  2. I ran gradle clean build --scan twice in the same console session. Weirdly enough, the first run was faster than the second.

from gradle.

mgroth0 avatar mgroth0 commented on May 28, 2024

I am curious if Repository Content Filtering could help you. You said there are a few dependencies that require mavenLocal. What if you used includeGroup so that mavenLocal only searched for these specific dependencies?

from gradle.

kriegaex avatar kriegaex commented on May 28, 2024

@mgroth0, thanks for the advice, but that would be a tedious workaround, not a solution. Usually, it is different for each project which dependencies it needs. Imagine trying to predict which direct and transitive dependencies - usually dozens of them - a Spring Boot project might need. The solution would be to make a local Maven repository a first-class citizen when it comes to resolving dependencies. Currently, it rather seems to resemble an unwanted stepchild.

from gradle.

ov7a avatar ov7a commented on May 28, 2024

This issue needs a decision from the team responsible for that area. They have been informed. Response time may vary.

from gradle.

bigdaz avatar bigdaz commented on May 28, 2024

My local Maven repository is huge, and for the rare cases in which I have to use Gradle, I do not want it to download all the same artifacts again, given the fact that my SSD does not have unlimited free space. Therefore, whichever project I am cloning, e.g. to help other people on Stack Overflow, I always add mavenCentral() and mavenLocal() repositories to the build.

This is based on a misunderstanding. Even if mavenLocal() is NOT included as a repository, Gradle will look into ~/.m2/repository to attempt to avoid re-downloading artifacts: if your Maven local has a required artifact, Gradle will copy it from there assuming the hash matches the hash declared in the remote repository. See here: https://docs.gradle.org/current/userguide/dependency_resolution.html#sub:cache_artifact_reuse

So mavenLocal is not useful to speed up resolution. If you need to consume artifacts produced locally by Maven, then using mavenLocal with repository content filtering is the way to go. See here for more information.

from gradle.

kriegaex avatar kriegaex commented on May 28, 2024

Why did you close the issue? Gradle is still slow. Is that not worth investigating and fixing?

from gradle.

bigdaz avatar bigdaz commented on May 28, 2024

I'll reopen this, since I'm not the one who normally processes issues.
You'll have much more luck getting this investigated if you :

  1. Provide a reproducer. You say that even a small project with 1 class will take 60s to start. Please provide a GitHub repo that someone can clone and reproduce these results.
  2. Provide a Gradle Build Scan®. These give a good idea of what's taking a long time WRT dependency resolution.

from gradle.

kriegaex avatar kriegaex commented on May 28, 2024

I tried again in a Git Bash session:

$ time gradle clean build

BUILD SUCCESSFUL in 53s
3 actionable tasks: 3 executed

real    0m54.744s
user    0m0.045s
sys     0m0.351s

$ time gradle clean build

BUILD SUCCESSFUL in 4s
3 actionable tasks: 3 executed

real    0m5.292s
user    0m0.135s
sys     0m0.273s

I really have no idea what takes 55 seconds to initialise here, and why sometimes it is "only" 20-25 seconds. The computer was idle otherwise in both situations.

Please note, that in both cases (Gradle-scanned builds above and the ones I ran just with time now), there was no mavenLocal(). But like @bigdaz said:

Even if mavenLocal() is NOT included as a repository, Gradle will look into ~/.m2/repository to attempt to avoid re-downloading artifacts

I have no idea, if the local Maven repo is involved in the long initialisation time or not (it is just an educated guess), I am just giving you the facts.

from gradle.

kriegaex avatar kriegaex commented on May 28, 2024

Looking at the build scan, I noticed that most of the time is spent in initialisation, not in execution, which I found weird.

image

So, I started searching explicitly for "gradle initialisation slow" and found this Stack Overflow answer. Adding

org.gradle.vfs.watch=true

to [USER_HOME]/.gradle/gradle.properties fixes he problem for me, as it seems. I.e., this issue is not really about mavenLocal(), as I thought, because somehow it seemed to help to comment it out (but maybe there was just a Gradle daemon already running somewhere, shortening the build time).

I think, this issue might be a duplicate of #17955, which is unfixed since 2021. Please investigate my build scans and ask for more verification data, if you like. I will be happy to provide any information you need to determine, if this is really a duplicate or maybe a separate case or new wrinkle.

from gradle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.