Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Chip Butty
Chip Butty
@otfrom@functional.cafe  ·  activity timestamp last week

Oh java experts in my feed! Is there a way to have a system wide cache of maven artefacts or does it only check ~/.m2

My non-ai influenced web searching skills are failing me

#java #maven

  • Copy link
  • Flag this post
  • Block
Deven Phillips
Deven Phillips
@infosec812@foojay.social  ·  activity timestamp last week

@otfrom
You can put the maven cache whenever you like as long as you have permissions on the directory. Just create a `.mavenrc` file. https://maven.apache.org/configure.html#mavenrc-file

Configuring Apache Maven – Maven

  • Copy link
  • Flag this comment
  • Block
wakingrufus
wakingrufus
@wakingrufus@bigshoulders.city  ·  activity timestamp last week

@otfrom
I think you can override the location here: https://maven.apache.org/settings.html#simple-values

But I'm mostly a #gradle user so I not that familiar with the #maven side of things

Settings Reference – Maven

  • Copy link
  • Flag this comment
  • Block
Elric
Elric
@elricofmelnibone@mastodon.social  ·  activity timestamp last week

@otfrom

The location is configurable in settings.xml:

<localRepository>/path/to/whatever/.m2/repository</localRepository>

And you can tell maven which settings.xml to use by specifying it on the commandline:

mvn --settings /path/to/settings.xml

  • Copy link
  • Flag this comment
  • Block
Chip Butty
Chip Butty
@otfrom@functional.cafe  ·  activity timestamp last week

@elricofmelnibone looks like that can only be set to a single directory rather than a PATH or LD_LIBRARY_PATH like list?

It would be good to say something like "look in /usr/local/m2 then in ~/.m2"

  • Copy link
  • Flag this comment
  • Block
Elric
Elric
@elricofmelnibone@mastodon.social  ·  activity timestamp last week

@otfrom You can configure which repositories you publish to and which you resolve artifacts from on a per pom.xml-basis, where you can declare <repository>-objects. You <url>file:///path/to/wherever</url> to specificy paths on disk.

If you specify multiple repositories in this way, the order of precedence is specified here: https://maven.apache.org/guides/mini/guide-multiple-repositories.html

Setting up Multiple Repositories – Maven

  • Copy link
  • Flag this comment
  • Block
Chip Butty
Chip Butty
@otfrom@functional.cafe  ·  activity timestamp last week

@elricofmelnibone ooh, thank you. I think this is what I was looking for

  • Copy link
  • Flag this comment
  • Block
Fae
Fae
@fae@pony.social  ·  activity timestamp last week

@otfrom @elricofmelnibone if there were multiple levels, how would you want it to decide which one to write new artifacts to?

  • Copy link
  • Flag this comment
  • Block
Chip Butty
Chip Butty
@otfrom@functional.cafe  ·  activity timestamp last week

@fae @elricofmelnibone I probably need to understand more about guix and nix as well, but I'm trying to think about how to make ~/.m2 play nicely with system wide dependencies installed by the distros package manager so that things can be recreated. (which makes me think that the solution is a symlink to the right part of ~/.m2, but I should really read how the current nix/guix systems do it)

  • Copy link
  • Flag this comment
  • Block
Fae
Fae
@fae@pony.social  ·  activity timestamp last week

@otfrom@funct onal.cafe @elricofmelnibone from my limited experience packaging maven projects for nix, maven.buildMavenPackage actually creates a new maven cache (a .m2) for every build, since the hash of the mvn deps `mvnHash` is stored along side the hash of the src. so the collection of mvn dependencies for a given version of pom.xml is treated as a monolith.

i think this dedicated .m2 for the build might be recycled between builds if the hash does not change?

nix is many things, but it is not disk space efficient.

see example package configs at: https://ryantm.github.io/nixpkgs/languages-frameworks/maven/

Maven | nixpkgs

  • Copy link
  • Flag this comment
  • Block
Marcus Fihlon
Marcus Fihlon
@McPringle@fosstodon.org  ·  activity timestamp last week

@otfrom I have never seen a package manager from the OS writing to the maven repo directory. And I hope NIX does not do it as well.

  • Copy link
  • Flag this comment
  • Block
Admiral Snackbär
Admiral Snackbär
@AdmSnackbar@mastodon.social  ·  activity timestamp last week

@otfrom @elricofmelnibone

Yes, but I'm struggling to understand, what problem you want to solve? Multi-level caching? If so, what's your concern with using one global or project specific caches?

Maven caches are usually much smaller than npm module caches, if that's your concern.

  • Copy link
  • Flag this comment
  • Block
Tobias Frech
Tobias Frech
@TobiasFrech@ijug.social  ·  activity timestamp last week

@otfrom yes, there is. You may want to look at your local repository configuration of the used maven configuration. See https://maven.apache.org/guides/mini/guide-configuring-maven.html

The maven configuration can be fetched from your local .m2 or the local maven installation AFAIK. Also check overrides in your pom.xml.

Configuring Maven – Maven

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.2-alpha.34 no JS en
Automatic federation enabled
Log in
Instance logo
  • Explore
  • About
  • Members
  • Code of Conduct