fgrehm / vagrant-cachier

Caffeine reducer
http://fgrehm.viewdocs.io/vagrant-cachier
MIT License
1.08k stars 111 forks source link

Add cache "buckets" for maven #57

Closed nikolauskrismer closed 1 year ago

nikolauskrismer commented 10 years ago

Would it be possible to add cache "buckets" for maven? If one installs maven using yum, the packages from the local maven repository should also get cached

fgrehm commented 10 years ago

I've never used maven before, but this gist should give you an idea of what is needed to support a new bucket https://gist.github.com/fgrehm/fd3907dafde6aa7272b9. Please let us know if you have any questions

nikolauskrismer commented 10 years ago

Based on the reply for #58 I implemented a simple maven cache "bucket". The important part of my shell-script looks like this:

mkdir -p /tmp/vagrant-cache/maven
yum -y install maven xmlstarlet
xmlstarlet ed -L -s "/_:settings" -t elem -n "localRepository" -v "/tmp/vagrant-cache/maven" /etc/maven/settings.xml
fgrehm commented 10 years ago

Awesome! Is maven just a command or it comes as some .jar? I think that is the only part missing as we need to figure out how can we detect if it is installed in order to automatically configure if cache.auto_detect is set to true and to error out in case if it is enabled for a guest that does not support it :)

tmatilai commented 10 years ago

Maven is a build tool etc. for java which downloads half the internet. ;) So, a command. Worth noting that finding it in $PATH and config being in /etc/maven/ depends on it being installed via package. A common pattern seems to be to install it directly from a tarball.

As it happens, I just last week had to build a cookbook using maven, and filed tmatilai/vagrant-proxyconf#33.

fgrehm commented 10 years ago

@tmatilai Oh yeah, I've heard about the "downloads half the internet" fame :P I'll try to have a look at the stuff you wrote for proxyconf when I have a chance, sounds like it will be useful to us as well :)

fgrehm commented 10 years ago

Just so you guys know, this seems to be doable and not very complicated so I tagged it for our 1.0 release

fgrehm commented 10 years ago

Ok folks, this didn't get many requests as I thought it would and now that we have the generic bucket in place people can always fall back to that.

If someone is able to put up a PR that provides the automatic detection and setup for this I'll be more than happy to bring it in :-)

hardyoyo commented 10 years ago

Hi, I have been meaning to write just such a bucket, and I'm happy to see that there is prior work to follow. I'm happy to see if I can figure out what's going on here, and will try making a PR as soon as I get something working. We recommend using Vagrant-Cachier for our Vagrant-based development environment (https://github.com/dspace/vagrant-dspace), and a working bucket for Maven would be a nice simple alternative to running a repository cache like Nexus on my own notebook, on the off chance I want to do some offline development.

fgrehm commented 10 years ago

@hardyoyo do you know where Maven keeps its packages tarballs (or its equivalent)? that would be a good start towards implementing the bucket :)

hardyoyo commented 10 years ago

Yes, Maven keeps them in ~/.m2/repository. I will look for the docs later tonight and pass on a link.

--Hardy

Sent from my iPad

On Aug 21, 2014, at 6:47 PM, "Fabio Rehm" notifications@github.com<mailto:notifications@github.com> wrote:

@hardyoyohttps://github.com/hardyoyo do you know where Maven keeps its packages tarballs (or its equivalent)? that would be a good start towards implementing the bucket :)

— Reply to this email directly or view it on GitHubhttps://github.com/fgrehm/vagrant-cachier/issues/57#issuecomment-53003555.

fgrehm commented 10 years ago

Awesome! What about detecting that maven is installed?

hardyoyo commented 10 years ago

Hi, there are a few alternatives. You can check the PATH to see if there is a mvn executable there, you can just try running

mvn -version

or you can try

which mvn

...you can look for the presence of the Maven Home env. var, (called MAVEN3_HOME for Maven 3, and M2_HOME for Maven 2).

Any of these work?

--Hardy


From: Fabio Rehm [notifications@github.com] Sent: Thursday, August 21, 2014 9:47 PM To: fgrehm/vagrant-cachier Cc: Pottinger, Hardy J. Subject: Re: [vagrant-cachier] Add cache "buckets" for maven (#57)

Awesome! What about detecting that maven is installed?

— Reply to this email directly or view it on GitHubhttps://github.com/fgrehm/vagrant-cachier/issues/57#issuecomment-53016210.

hardyoyo commented 10 years ago

As promised, here is the documentation on the Maven "localRepository" setting:

http://maven.apache.org/settings.html

If you'd like a handy way to test a Vagrant environment that has Maven already set up, this is the one I use every day: https://github.com/DSpace/vagrant-dspace

fgrehm commented 10 years ago

Ok, that is enough info, let's reopen this so we don't forget about it.

@hardyoyo In the meantime, you can use the generic bucket for caching maven packages and let us know how it goes :-)

hardyoyo commented 10 years ago

Hi, I made an attempt at setting up the generic bucket, but I don't think it's working:

https://gist.github.com/hardyoyo/497c2b57dac93f8c96ef#file-vagrantfile-L60

I don't see anything in ~/.vagrant.d/cache for maven, after running vagrant destroy -f && vagrant up. I bet I'm just not implementing things correctly. Help?

fgrehm commented 9 years ago

@hardyoyo I believe you are missing the cache scope! See http://fgrehm.viewdocs.io/vagrant-cachier/usage for more info

hardyoyo commented 9 years ago

That fixed it, thanks! I've made and merged a pull request for adding this generic bucket configuration to our project:

https://github.com/DSpace/vagrant-dspace/pull/28

The generic bucket appears to work well for this. Thanks!

fgrehm commented 9 years ago

@hardyoyo awesome! thanks for sharing :)

typekpb commented 9 years ago

I'd like to see this one fixed as well. In the meantime, thanks for the workaround!

gildegoma commented 9 years ago

Hi! Is there anybody working on this at the moment?

fgrehm commented 9 years ago

Not me! :P

sworisbreathing commented 8 years ago

@typekpb @gildegoma have you tried @hardyoyo's solution?

...

# use the generic cache bucket for Maven
config.cache.enable :generic, {
  "maven" => { cache_dir: "/home/vagrant/.m2/repository" }
}
...
fgrehm commented 1 year ago

Hey, sorry for the silence here but this project is looking for maintainers :sweat_smile:

As per https://github.com/fgrehm/vagrant-cachier/issues/193, I've added the ignored label and will close this issue. Thanks for the interest in the project and LMK if you want to step up and take ownership of this project on that other issue :wave: