license_finder 0.9.5.1-java → 1.0.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.rdoc +9 -0
- data/MIT.LICENSE +20 -0
- data/db/migrate/201401302113_re_reassociate_license.rb +23 -0
- data/features/gradle_dependencies.feature +9 -0
- data/features/maven_dependencies.feature +9 -0
- data/features/step_definitions/gradle_steps.rb +8 -0
- data/features/step_definitions/maven_steps.rb +8 -0
- data/features/step_definitions/node_steps.rb +1 -1
- data/features/step_definitions/set_license_steps.rb +0 -1
- data/features/step_definitions/shared_steps.rb +26 -13
- data/lib/license_finder.rb +6 -1
- data/lib/license_finder/cli.rb +13 -9
- data/lib/license_finder/configuration.rb +113 -72
- data/lib/license_finder/dependency_manager.rb +12 -7
- data/lib/license_finder/license.rb +39 -65
- data/lib/license_finder/license/any_matcher.rb +13 -0
- data/lib/license_finder/license/definitions.rb +106 -0
- data/lib/license_finder/license/header_matcher.rb +10 -0
- data/lib/license_finder/license/matcher.rb +17 -0
- data/lib/license_finder/license/template.rb +16 -0
- data/lib/license_finder/license/text.rb +19 -0
- data/lib/license_finder/license_url.rb +1 -4
- data/lib/license_finder/package.rb +18 -2
- data/lib/license_finder/package_managers/bower_package.rb +3 -17
- data/lib/license_finder/package_managers/bundler_package.rb +2 -2
- data/lib/license_finder/package_managers/gradle.rb +29 -0
- data/lib/license_finder/package_managers/gradle_package.rb +41 -0
- data/lib/license_finder/package_managers/maven.rb +31 -0
- data/lib/license_finder/package_managers/maven_package.rb +46 -0
- data/lib/license_finder/package_managers/npm_package.rb +2 -16
- data/lib/license_finder/package_managers/pip_package.rb +7 -7
- data/lib/license_finder/package_saver.rb +1 -1
- data/lib/license_finder/possible_license_file.rb +1 -5
- data/lib/license_finder/possible_license_files.rb +4 -2
- data/lib/license_finder/reports/dependency_report.rb +5 -1
- data/lib/license_finder/reports/detailed_text_report.rb +0 -1
- data/lib/license_finder/reports/formatted_report.rb +21 -0
- data/lib/license_finder/reports/html_report.rb +1 -21
- data/lib/license_finder/reports/markdown_report.rb +1 -21
- data/lib/license_finder/reports/reporter.rb +8 -7
- data/lib/license_finder/reports/text_report.rb +0 -2
- data/lib/license_finder/tables.rb +1 -1
- data/lib/license_finder/tables/dependency.rb +12 -12
- data/lib/license_finder/yml_to_sql.rb +4 -4
- data/license_finder.gemspec +3 -2
- data/readme.md +10 -1
- data/release/publish.sh +10 -7
- data/spec/fixtures/build.gradle +24 -0
- data/spec/fixtures/pom.xml +19 -0
- data/spec/lib/license_finder/cli_spec.rb +13 -3
- data/spec/lib/license_finder/configuration_spec.rb +121 -74
- data/spec/lib/license_finder/dependency_manager_spec.rb +34 -16
- data/spec/lib/license_finder/license/{new_bsd_spec.rb → definitions_spec.rb} +93 -7
- data/spec/lib/license_finder/license_spec.rb +72 -26
- data/spec/lib/license_finder/license_url_spec.rb +10 -14
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +17 -5
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +2 -2
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +66 -0
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +89 -0
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +72 -0
- data/spec/lib/license_finder/package_managers/maven_spec.rb +115 -0
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +17 -3
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +27 -5
- data/spec/lib/license_finder/possible_license_file_spec.rb +2 -2
- data/spec/lib/license_finder/{detailed_text_report_spec.rb → reports/detailed_text_report_spec.rb} +0 -0
- data/spec/lib/license_finder/{html_report_spec.rb → reports/html_report_spec.rb} +0 -0
- data/spec/lib/license_finder/{markdown_report_spec.rb → reports/markdown_report_spec.rb} +0 -0
- data/spec/lib/license_finder/reports/reporter_spec.rb +33 -0
- data/spec/lib/license_finder/{text_report_spec.rb → reports/text_report_spec.rb} +0 -0
- data/spec/lib/license_finder/tables/dependency_spec.rb +1 -2
- data/spec/lib/license_finder/tables/license_alias_spec.rb +1 -2
- data/spec/lib/license_finder/yml_to_sql_spec.rb +10 -11
- data/spec/lib/license_finder_spec.rb +5 -71
- metadata +64 -53
- data/features/rails_rake.feature +0 -9
- data/features/step_definitions/rails_rake_steps.rb +0 -12
- data/lib/license_finder/license/apache2.rb +0 -8
- data/lib/license_finder/license/bsd.rb +0 -4
- data/lib/license_finder/license/gplv2.rb +0 -4
- data/lib/license_finder/license/isc.rb +0 -3
- data/lib/license_finder/license/lgpl.rb +0 -4
- data/lib/license_finder/license/mit.rb +0 -23
- data/lib/license_finder/license/new_bsd.rb +0 -27
- data/lib/license_finder/license/python.rb +0 -8
- data/lib/license_finder/license/ruby.rb +0 -11
- data/lib/license_finder/license/simplified_bsd.rb +0 -8
- data/lib/license_finder/railtie.rb +0 -7
- data/lib/tasks/license_finder.rake +0 -7
- data/spec/lib/license_finder/license/apache_spec.rb +0 -7
- data/spec/lib/license_finder/license/bsd_spec.rb +0 -41
- data/spec/lib/license_finder/license/gplv2_spec.rb +0 -7
- data/spec/lib/license_finder/license/isc_spec.rb +0 -7
- data/spec/lib/license_finder/license/lgpl_spec.rb +0 -7
- data/spec/lib/license_finder/license/mit_spec.rb +0 -33
- data/spec/lib/license_finder/license/python_spec.rb +0 -7
- data/spec/lib/license_finder/license/ruby_spec.rb +0 -19
- data/spec/lib/license_finder/license/simplified_bsd_spec.rb +0 -7
- data/spec/lib/license_finder/reporter_spec.rb +0 -46
- data/spec/support/license_examples.rb +0 -30
@@ -0,0 +1,29 @@
|
|
1
|
+
require "xmlsimple"
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class Gradle
|
5
|
+
def self.current_packages
|
6
|
+
`gradle downloadLicenses`
|
7
|
+
|
8
|
+
xml = File.read('build/reports/license/dependency-license.xml')
|
9
|
+
|
10
|
+
options = {
|
11
|
+
'GroupTags' => { 'dependencies' => 'dependency' }
|
12
|
+
}
|
13
|
+
XmlSimple.xml_in(xml, options)["dependency"].map do |d|
|
14
|
+
d["license"].reject! { |l| l["name"] == "No license found" }
|
15
|
+
GradlePackage.new(d)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.active?
|
20
|
+
File.exists?(package_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def self.package_path
|
26
|
+
Pathname.new('build.gradle').expand_path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class GradlePackage < Package
|
3
|
+
attr_reader :name, :version
|
4
|
+
|
5
|
+
def initialize(gradle_dependency)
|
6
|
+
@gradle_dependency = gradle_dependency
|
7
|
+
@name = @gradle_dependency["name"].split(":")[1]
|
8
|
+
@version = @gradle_dependency["name"].split(":")[2]
|
9
|
+
end
|
10
|
+
|
11
|
+
def description
|
12
|
+
""
|
13
|
+
end
|
14
|
+
|
15
|
+
def summary
|
16
|
+
""
|
17
|
+
end
|
18
|
+
|
19
|
+
def homepage
|
20
|
+
""
|
21
|
+
end
|
22
|
+
|
23
|
+
def groups
|
24
|
+
[]
|
25
|
+
end
|
26
|
+
|
27
|
+
def children
|
28
|
+
[]
|
29
|
+
end
|
30
|
+
|
31
|
+
def license_from_files
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def licenses_from_spec
|
38
|
+
@gradle_dependency["license"].map { |l| l["name"] }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "xmlsimple"
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class Maven
|
5
|
+
def self.current_packages
|
6
|
+
`mvn license:download-licenses`
|
7
|
+
|
8
|
+
xml = File.read('target/generated-resources/licenses.xml')
|
9
|
+
|
10
|
+
options = {
|
11
|
+
'GroupTags' => { 'licenses' => 'license', 'dependencies' => 'dependency' },
|
12
|
+
'ForceArray' => ['license', 'dependency']
|
13
|
+
}
|
14
|
+
dependencies = XmlSimple.xml_in(xml, options)["dependencies"]
|
15
|
+
|
16
|
+
dependencies.map do |dep|
|
17
|
+
MavenPackage.new(dep)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.active?
|
22
|
+
File.exists?(package_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def self.package_path
|
28
|
+
Pathname.new('pom.xml').expand_path
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class MavenPackage < Package
|
3
|
+
def initialize(mvn_dependency)
|
4
|
+
@mvn_dependency = mvn_dependency
|
5
|
+
end
|
6
|
+
|
7
|
+
def name
|
8
|
+
mvn_dependency["artifactId"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def version
|
12
|
+
mvn_dependency["version"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def description
|
16
|
+
""
|
17
|
+
end
|
18
|
+
|
19
|
+
def summary
|
20
|
+
""
|
21
|
+
end
|
22
|
+
|
23
|
+
def homepage
|
24
|
+
""
|
25
|
+
end
|
26
|
+
|
27
|
+
def groups
|
28
|
+
[]
|
29
|
+
end
|
30
|
+
|
31
|
+
def children
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
|
35
|
+
def license_from_files
|
36
|
+
[]
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
attr_reader :mvn_dependency
|
41
|
+
|
42
|
+
def licenses_from_spec
|
43
|
+
mvn_dependency["licenses"].map { |l| l["name"] }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -40,22 +40,8 @@ module LicenseFinder
|
|
40
40
|
node_module["path"]
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
if license
|
47
|
-
license = license.fetch("type", nil)
|
48
|
-
end
|
49
|
-
|
50
|
-
if license.nil?
|
51
|
-
license = node_module.fetch("license", nil)
|
52
|
-
|
53
|
-
if license.is_a? Hash
|
54
|
-
license = license.fetch("type", nil)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
license
|
43
|
+
def licenses_from_spec
|
44
|
+
Package.extract_licenses_from_standard_spec(node_module)
|
59
45
|
end
|
60
46
|
end
|
61
47
|
end
|
@@ -33,19 +33,19 @@ module LicenseFinder
|
|
33
33
|
|
34
34
|
attr_reader :install_path, :pypi_def
|
35
35
|
|
36
|
-
def
|
37
|
-
license = pypi_def
|
36
|
+
def licenses_from_spec
|
37
|
+
license = pypi_def["license"]
|
38
38
|
|
39
|
-
if license
|
39
|
+
if pypi_def["license"] && pypi_def["license"] != "UNKNOWN"
|
40
|
+
return [license]
|
41
|
+
else
|
40
42
|
classifiers = pypi_def.fetch("classifiers", [])
|
41
|
-
|
43
|
+
classifiers.map do |c|
|
42
44
|
if c.start_with?("License")
|
43
45
|
c.gsub(/^License.*::\s*(.*)$/, '\1')
|
44
46
|
end
|
45
|
-
end.compact
|
47
|
+
end.compact
|
46
48
|
end
|
47
|
-
|
48
|
-
license
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -10,14 +10,16 @@ module LicenseFinder
|
|
10
10
|
@install_path = install_path
|
11
11
|
end
|
12
12
|
|
13
|
-
attr_reader :install_path
|
14
|
-
|
15
13
|
def find
|
16
14
|
paths_for_license_files.map do |path|
|
17
15
|
get_file_for_path(path)
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :install_path
|
22
|
+
|
21
23
|
def paths_for_license_files
|
22
24
|
find_matching_files.map do |path|
|
23
25
|
File.directory?(path) ? paths_for_files_in_license_directory(path) : path
|
@@ -10,13 +10,17 @@ module LicenseFinder
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.of(dependencies)
|
14
|
+
new(dependencies).to_s
|
15
|
+
end
|
16
|
+
|
13
17
|
def initialize(dependencies=[])
|
14
18
|
@dependencies = Array dependencies
|
15
19
|
end
|
16
20
|
|
17
21
|
def to_s
|
18
22
|
filename = ROOT_PATH.join('templates', "#{self.class.underscored_name}.erb")
|
19
|
-
template = ERB.new(
|
23
|
+
template = ERB.new(filename.read, nil, '-')
|
20
24
|
template.result(binding)
|
21
25
|
end
|
22
26
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class FormattedReport < DependencyReport
|
3
|
+
private
|
4
|
+
def unapproved_dependencies
|
5
|
+
dependencies.reject(&:approved?)
|
6
|
+
end
|
7
|
+
|
8
|
+
def grouped_dependencies
|
9
|
+
find_name = lambda do |dep|
|
10
|
+
license = License.find_by_name(dep.license.name)
|
11
|
+
if license
|
12
|
+
license.pretty_name
|
13
|
+
else
|
14
|
+
dep.license.name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
dependencies.group_by(&find_name).sort_by { |_, group| group.size }.reverse
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,23 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
module LicenseFinder
|
4
|
-
class HtmlReport <
|
5
|
-
private
|
6
|
-
def unapproved_dependencies
|
7
|
-
dependencies.reject(&:approved?)
|
8
|
-
end
|
9
|
-
|
10
|
-
def grouped_dependencies
|
11
|
-
find_name = lambda do |dep|
|
12
|
-
license = License.find_by_name(dep.license.name)
|
13
|
-
if license
|
14
|
-
license.pretty_name
|
15
|
-
else
|
16
|
-
dep.license.name
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
dependencies.group_by(&find_name).sort_by { |_, group| group.size }.reverse
|
21
|
-
end
|
22
|
-
end
|
2
|
+
class HtmlReport < FormattedReport; end
|
23
3
|
end
|
@@ -1,23 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
module LicenseFinder
|
4
|
-
class MarkdownReport <
|
5
|
-
private
|
6
|
-
def unapproved_dependencies
|
7
|
-
dependencies.reject(&:approved?)
|
8
|
-
end
|
9
|
-
|
10
|
-
def grouped_dependencies
|
11
|
-
find_name = lambda do |dep|
|
12
|
-
license = License.find_by_name(dep.license.name)
|
13
|
-
if license
|
14
|
-
license.pretty_name
|
15
|
-
else
|
16
|
-
dep.license.name
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
dependencies.group_by(&find_name).sort_by { |_, group| group.size }.reverse
|
21
|
-
end
|
22
|
-
end
|
2
|
+
class MarkdownReport < FormattedReport; end
|
23
3
|
end
|
@@ -4,20 +4,21 @@ module LicenseFinder
|
|
4
4
|
|
5
5
|
def write_reports
|
6
6
|
dependencies = Dependency.all
|
7
|
+
artifacts = LicenseFinder.config.artifacts
|
7
8
|
|
8
|
-
write_file
|
9
|
-
write_file
|
10
|
-
write_file
|
11
|
-
write_file
|
9
|
+
write_file artifacts.text_file, TextReport.of(dependencies)
|
10
|
+
write_file artifacts.detailed_text_file, DetailedTextReport.of(dependencies)
|
11
|
+
write_file artifacts.html_file, HtmlReport.of(dependencies)
|
12
|
+
write_file artifacts.markdown_file, MarkdownReport.of(dependencies)
|
12
13
|
|
13
|
-
if
|
14
|
-
|
14
|
+
if LicenseFinder.config.artifacts.legacy_text_file.exist?
|
15
|
+
LicenseFinder.config.artifacts.legacy_text_file.delete
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
private
|
19
20
|
def write_file(file_path, content)
|
20
|
-
|
21
|
+
file_path.open('w+') do |f|
|
21
22
|
f.puts content
|
22
23
|
end
|
23
24
|
end
|
@@ -2,6 +2,6 @@ require 'rubygems'
|
|
2
2
|
require 'sequel'
|
3
3
|
require LicenseFinder::Platform.sqlite_load_path
|
4
4
|
|
5
|
-
LicenseFinder::DB = Sequel.connect("#{LicenseFinder::Platform.sqlite_adapter}://#{LicenseFinder.config.database_uri}")
|
5
|
+
LicenseFinder::DB = Sequel.connect("#{LicenseFinder::Platform.sqlite_adapter}://#{LicenseFinder.config.artifacts.database_uri}")
|
6
6
|
Sequel.extension :migration, :core_extensions
|
7
7
|
Sequel::Migrator.run(LicenseFinder::DB, LicenseFinder::ROOT_PATH.join('../db/migrate'))
|
@@ -29,21 +29,11 @@ module LicenseFinder
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def bundler_group_names=(names)
|
32
|
-
|
33
|
-
|
34
|
-
remove, add = set_diff(bundler_groups, current_groups)
|
35
|
-
|
36
|
-
remove.each { |g| remove_bundler_group(g) }
|
37
|
-
add.each { |g| add_bundler_group(g) }
|
32
|
+
update_association_collection(:bundler_groups, names)
|
38
33
|
end
|
39
34
|
|
40
35
|
def children_names=(names)
|
41
|
-
|
42
|
-
|
43
|
-
remove, add = set_diff(children, current_children)
|
44
|
-
|
45
|
-
remove.each { |c| remove_child(c) }
|
46
|
-
add.each { |c| add_child(c) }
|
36
|
+
update_association_collection(:children, names)
|
47
37
|
end
|
48
38
|
|
49
39
|
def approve!
|
@@ -70,6 +60,16 @@ module LicenseFinder
|
|
70
60
|
|
71
61
|
private
|
72
62
|
|
63
|
+
def update_association_collection(association_name, names)
|
64
|
+
association = model.association_reflection(association_name)
|
65
|
+
current_records = names.map { |name| association.associated_class.named(name) }
|
66
|
+
|
67
|
+
remove, add = set_diff(public_send(association_name), current_records)
|
68
|
+
|
69
|
+
remove.each { |r| public_send(association.remove_method, r) }
|
70
|
+
add.each { |r| public_send(association.add_method, r) }
|
71
|
+
end
|
72
|
+
|
73
73
|
# Foreign method, belongs on Set
|
74
74
|
#
|
75
75
|
# Returns a pair of sets, which contain the elements that would have to be
|