Class: MavenRequire::RuntimeInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/maven_require.rb

Instance Method Summary collapse

Constructor Details

#initialize(builder) ⇒ RuntimeInstaller

Returns a new instance of RuntimeInstaller.



46
47
48
49
# File 'lib/maven_require.rb', line 46

def initialize(builder)
	@options = builder.options
	@list = builder
end

Instance Method Details

#executeObject



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/maven_require.rb', line 67

def execute
	Tempfile.open("deps.lst") do |deps_file|
		raise LoadError, "Maven Resolve failed (see stdout/stderr)" unless resolve_dependencies_list(deps_file.path)

		puts File.read deps_file.path if Jars.debug?

		jars = Jars::Installer.load_from_maven(deps_file.path)
		raise LoadError, "Maven Resolve returned no results" unless jars.length >= 1
		jars.each do |id|
			require(id.file)
		end
	end
end

#resolve_dependencies_list(file) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/maven_require.rb', line 50

def resolve_dependencies_list(file)
	factory = Jars::MavenFactory.new(@options)
	#maven = factory.maven_new(File.expand_path('../gemspec_pom.rb', __FILE__))
	# Extract the path to the jar_dependencies' pom
	maven = factory.maven_new(File.expand_path('../gemspec_pom.rb', $LOADED_FEATURES.find{|x|x =~ /jars\/maven_factory\.rb$/}))

	maven.attach_jars(@list, false)

	maven['outputAbsoluteArtifactFilename'] = 'true'
	maven['includeTypes'] = 'jar'
	maven['outputScope'] = 'true'
	maven['useRepositoryLayout'] = 'true'
	maven['outputDirectory'] = Jars.home.to_s
	maven['outputFile'] = file.to_s

	maven.exec('dependency:copy-dependencies', 'dependency:list')
end