239: def self.run
240:
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:
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:
260: FileUtils.cp(File.join(repo_home, artifact.path), 'ext')
261: gemspec = Raven.create_gemspec(artifact)
262: Gem::Builder.new(gemspec).build
263:
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:
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