Class: LicenseFinder::Maven
Instance Method Summary
collapse
#active?, #command_exists?, #current_packages_with_relations, #detected_package_path, id, #installed?, #prepare, #prepare_command, takes_priority_over
Constructor Details
#initialize(options = {}) ⇒ Maven
Returns a new instance of Maven.
8
9
10
11
12
13
|
# File 'lib/license_finder/package_managers/maven.rb', line 8
def initialize(options = {})
super
@ignored_groups = options[:ignored_groups]
@include_groups = options[:maven_include_groups]
@maven_options = options[:maven_options]
end
|
Instance Method Details
#current_packages ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/license_finder/package_managers/maven.rb', line 15
def current_packages
command = "#{package_management_command} org.codehaus.mojo:license-maven-plugin:download-licenses"
command += " -Dlicense.excludedScopes=#{@ignored_groups.to_a.join(',')}" if @ignored_groups && !@ignored_groups.empty?
command += " #{@maven_options}" unless @maven_options.nil?
_stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?
dependencies = MavenDependencyFinder.new(project_path).dependencies
packages = dependencies.flat_map do |xml|
options = {
'GroupTags' => { 'licenses' => 'license', 'dependencies' => 'dependency' },
'ForceArray' => %w[license dependency]
}
contents = XmlSimple.xml_in(xml, options)['dependencies']
contents.map do |dep|
MavenPackage.new(dep, logger: logger, include_groups: @include_groups)
end
end
packages.uniq
end
|
#package_management_command ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/license_finder/package_managers/maven.rb', line 36
def package_management_command
wrapper = if Platform.windows?
'mvnw.cmd'
else
'./mvnw'
end
maven = 'mvn'
File.exist?(File.join(project_path, wrapper)) ? wrapper : maven
end
|
#possible_package_paths ⇒ Object
47
48
49
|
# File 'lib/license_finder/package_managers/maven.rb', line 47
def possible_package_paths
[project_path.join('pom.xml')]
end
|
#project_root? ⇒ Boolean
51
52
53
|
# File 'lib/license_finder/package_managers/maven.rb', line 51
def project_root?
active? && root_module?
end
|