Class: LicenseFinder::Gradle
Instance Method Summary
collapse
#active?, #command_exists?, #current_packages_with_relations, id, #installed?, #prepare, #prepare_command, takes_priority_over
Constructor Details
#initialize(options = {}) ⇒ Gradle
Returns a new instance of Gradle.
9
10
11
12
13
|
# File 'lib/license_finder/package_managers/gradle.rb', line 9
def initialize(options = {})
super
@command = options[:gradle_command] || package_management_command
@include_groups = options[:gradle_include_groups]
end
|
Instance Method Details
#current_packages ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/license_finder/package_managers/gradle.rb', line 15
def current_packages
WithEnv.with_env('TERM' => 'dumb') do
command = "#{@command} downloadLicenses"
_stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
raise "Command '#{command}' failed to execute: #{stderr}" unless status.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
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/license_finder/package_managers/gradle.rb', line 33
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
|
#project_root? ⇒ Boolean
45
46
47
|
# File 'lib/license_finder/package_managers/gradle.rb', line 45
def project_root?
active? && root_module?
end
|