added mvn cache support
This commit is contained in:
parent
da0eff6a71
commit
8c64aff76a
4 changed files with 48 additions and 1 deletions
lib/vagrant-cachier
|
@ -102,3 +102,4 @@ require_relative "bucket/npm"
|
|||
require_relative "bucket/zypper"
|
||||
require_relative "bucket/generic"
|
||||
require_relative "bucket/pip"
|
||||
require_relative "bucket/mvn"
|
||||
|
|
21
lib/vagrant-cachier/bucket/mvn.rb
Normal file
21
lib/vagrant-cachier/bucket/mvn.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module VagrantPlugins
|
||||
module Cachier
|
||||
class Bucket
|
||||
class Mvn < Bucket
|
||||
def self.capability
|
||||
:maven_cache_dir
|
||||
end
|
||||
|
||||
def install
|
||||
if guest.capability?(:maven_cache_dir)
|
||||
guest_path = guest.capability(:maven_cache_dir)
|
||||
return if @env[:cache_dirs].include?(guest_path)
|
||||
symlink(guest_path)
|
||||
else
|
||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Mvn')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
20
lib/vagrant-cachier/cap/linux/maven_cache_dir.rb
Normal file
20
lib/vagrant-cachier/cap/linux/maven_cache_dir.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module VagrantPlugins
|
||||
module Cachier
|
||||
module Cap
|
||||
module Linux
|
||||
module MavenCacheDir
|
||||
def self.maven_cache_dir(machine)
|
||||
maven_cache_dir = nil
|
||||
machine.communicate.tap do |comm|
|
||||
return unless comm.test('which mvn')
|
||||
comm.execute 'echo $HOME' do |buffer, output|
|
||||
maven_cache_dir = output.chomp if buffer == :stdout
|
||||
end
|
||||
end
|
||||
return "#{maven_cache_dir}/.m2/repository"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -40,7 +40,12 @@ module VagrantPlugins
|
|||
require_relative 'cap/linux/pip_cache_dir'
|
||||
Cap::Linux::PipCacheDir
|
||||
end
|
||||
|
||||
|
||||
guest_capability 'linux', 'mvn_cache_dir' do
|
||||
require_relative 'cap/linux/maven_cache_dir'
|
||||
Cap::Linux::MavenCacheDir
|
||||
end
|
||||
|
||||
guest_capability 'debian', 'apt_cache_dir' do
|
||||
require_relative 'cap/debian/apt_cache_dir'
|
||||
Cap::Debian::AptCacheDir
|
||||
|
|
Loading…
Reference in a new issue