Class: LicenseFinder::Gradle
Instance Method Summary
collapse
#active?, #capture, command_exists?, current_packages, #current_packages_with_relations, installed?, package_management_command, package_managers
Constructor Details
#initialize(options = {}) ⇒ Gradle
7
8
9
10
11
|
# File 'lib/license_finder/package_managers/gradle.rb', line 7
def initialize(options={})
super
@command = options[:gradle_command] || package_management_command
@include_groups = options[:gradle_include_groups]
end
|
Instance Method Details
#current_packages ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/license_finder/package_managers/gradle.rb', line 13
def current_packages
WithEnv.with_env({"TERM" => "dumb"}) do
command = "#{@command} downloadLicenses"
output, success = Dir.chdir(project_path) { capture(command) }
raise "Command '#{command}' failed to execute: #{output}" unless success
dependencies = GradleDependencyFinder.new(project_path).dependencies
packages = dependencies.flat_map do |xml_file|
options = {'GroupTags' => {'dependencies' => 'dependency'}}
contents = XmlSimple.xml_in(xml_file, options).fetch('dependency', [])
contents.map do |dep|
GradlePackage.new(dep, logger: logger, include_groups: @include_groups)
end
end
packages.uniq
end
end
|
#package_management_command ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/license_finder/package_managers/gradle.rb', line 31
def package_management_command
if Platform.windows?
wrapper = 'gradlew.bat'
gradle = 'gradle.bat'
else
wrapper = './gradlew'
gradle = 'gradle'
end
File.exist?(File.join(project_path, wrapper)) ? wrapper : gradle
end
|