Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Andreas Leitgeb Newsgroups: comp.lang.java.programmer Subject: Re: maven and its downloads Date: Wed, 26 Feb 2020 16:57:29 -0000 (UTC) Organization: A noiseless patient Spider Lines: 41 Message-ID: References: <3b5cef64-f28b-447c-a6cc-5b47dfe463ee@googlegroups.com> Reply-To: avl@logic.at Injection-Date: Wed, 26 Feb 2020 16:57:29 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="812aa21b3845a24927bebcd21299ff81"; logging-data="6155"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KRjERETYxzxmPoUCvOsGr" User-Agent: slrn/1.0.3 (Linux) Cancel-Lock: sha1:+krTAvmPpjaoOrvTIh5PmzOHVrU= Xref: csiph.com comp.lang.java.programmer:39305 Eric Douglas wrote: > On Wednesday, February 26, 2020 at 4:16:26 AM UTC-5, Andreas Leitgeb wrote: >> I've got a single maven project on a particular user at a machine. >> After some development stages (with often changed dependencies), >> I made a full clean+build (took only a few minutes), then used >> "find ~/.m2/repository -amin +60 -exec rm {} +" >> (remove everything not used in the last 60 minutes) >> On next build afterwards, it again downloaded a few packages. >> >> Apparently, it downloads packages that it doesn't ever use. >> Majority of them is in org.apache.maven group. >> >> Given that the local repo of that user is used only for that >> project, is there a way to prune it of no-longer necessary >> stuff, while avoiding to prune stuff that will be re-downloaded? > It should download everything in your pom file(s). > Are you seeing projects downloaded which are not referenced for download anywhere? Yes. Well, not "anywhere in my pom-files". > Define "doesn't ever use". > Are you thinking it doesn't use things it downloaded because you didn't > call them directly? As I wrote: The OS doesn't record any attempt at reading those files during the time I do a complete build. > Sometimes your dependencies have dependencies, > and sometimes they're only required if you call certain methods. > You might reference a project which pulls down POI because it can > read/write a spreadsheet, but it won't care if you're missing that > (runtime) dependency if you never do that in your application. I did the same methods before the "find" and afterwards. Apparently, maven sometimes just checks if a file exists in the repo, and if not then downloads it, despite not accessing it during a build. Usually it does seem to get the files only on demand, as I could see when I first did a "mvn clean" and it downloaded some "clean"-helpers.