Module Raven::MavenLocalRepoImport
In: lib/raven/repo_builder.rb

Methods

run   select_repo  

Public Class methods

[Source]

     # File lib/raven/repo_builder.rb, line 239
239:     def self.run
240:       # Trying to find out where the local repository is

241:       maven_home = ENV['MAVEN_HOME'] ? ENV['MAVEN_HOME'] : ''
242:       repo_home = self.select_repo([maven_home + '/repository', USER_HOME + '/.maven/repository', USER_HOME + '/.m2/repository'])
243:       if repo_home
244:         print "Found a Maven repository in #{repo_home}, do you want to use this one? (y/n)"
245:         puts '' while (!['y', 'n'].include?(answer = gets.chomp))
246:       end
247:       repo_home = nil if answer == 'n'
248:       unless repo_home
249:         puts "Please provide the path to your maven repository to convert."
250:         puts "Path doesn't exist! Try again..." while (!File.exist?(repo_home = gets.chomp))
251:       end
252:       # Detect the repository type (2 first entries are always . and ..)

253:       first_subdir = Dir.entries(File.join(repo_home, Dir.entries(repo_home)[2]))[2]
254:       repo = (first_subdir == 'jars') ? M1LocalRepository.new(repo_home) : M2LocalRepository.new(repo_home)
255:       
256:       FileUtils.mkdir('ext') unless File.exist?('ext')
257:       repo.each do |artifact|
258:         if File.exist?(File.join(repo_home, artifact.path))
259:           # Building Gem        

260:           FileUtils.cp(File.join(repo_home, artifact.path), 'ext')
261:           gemspec = Raven.create_gemspec(artifact)
262:           Gem::Builder.new(gemspec).build
263:           # Installing Gem

264:           params = [false]
265:           params << RAVEN_HOME if defined?(GEMS_IN_HOME)
266:           Gem::Installer.new("#{artifact.groupId}-#{artifact.artifactId}-#{artifact.versionId}-java.gem").install(*params)
267:           # Cleaning up for next iteration

268:           FileUtils.rm(Dir.glob('ext/*'))
269:           FileUtils.rm(Dir.glob('*.gem'))
270:         else
271:           puts "File #{artifact.path} couldn't be found, ignoring."
272:         end
273:       end
274:       FileUtils.rm_r('ext')
275:     end

[Source]

     # File lib/raven/repo_builder.rb, line 277
277:     def self.select_repo(paths)
278:       paths.each { |p| return p if File.exist?(p) }
279:       nil
280:     end

[Validate]