license_finder 3.0.4 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +56 -0
- data/CHANGELOG.md +29 -2
- data/CONTRIBUTING.md +5 -1
- data/Dockerfile +33 -10
- data/Gemfile +2 -2
- data/README.md +27 -5
- data/Rakefile +15 -21
- data/ci/pipelines/pipeline.yml.erb +40 -6
- data/ci/pipelines/release.yml +11 -5
- data/ci/scripts/containerize-tests.sh +16 -0
- data/ci/scripts/run-rubocop.sh +8 -0
- data/ci/scripts/run-tests.sh +22 -0
- data/ci/scripts/test.ps1 +81 -0
- data/ci/tasks/build-windows.yml +6 -0
- data/ci/tasks/build.yml +2 -2
- data/ci/tasks/rubocop.yml +13 -0
- data/features/features/cli/cli_spec.rb +8 -8
- data/features/features/configure/add_dependencies_spec.rb +7 -7
- data/features/features/configure/approve_dependencies_spec.rb +15 -15
- data/features/features/configure/assign_licenses_spec.rb +4 -4
- data/features/features/configure/blacklist_licenses_spec.rb +3 -3
- data/features/features/configure/ignore_dependencies_spec.rb +3 -3
- data/features/features/configure/ignore_groups_spec.rb +4 -4
- data/features/features/configure/name_project_spec.rb +4 -4
- data/features/features/configure/set_project_path_spec.rb +2 -2
- data/features/features/configure/whitelist_licenses_spec.rb +4 -4
- data/features/features/package_managers/bower_spec.rb +3 -3
- data/features/features/package_managers/carthage_spec.rb +14 -0
- data/features/features/package_managers/cocoapods_spec.rb +3 -3
- data/features/features/package_managers/conan_spec.rb +11 -0
- data/features/features/package_managers/dep_spec.rb +15 -0
- data/features/features/package_managers/glide_spec.rb +14 -0
- data/features/features/package_managers/govendor_spec.rb +15 -0
- data/features/features/package_managers/gradle_spec.rb +1 -1
- data/features/features/package_managers/gvt_spec.rb +14 -0
- data/features/features/package_managers/maven_spec.rb +2 -3
- data/features/features/package_managers/mix_spec.rb +16 -0
- data/features/features/package_managers/npm_spec.rb +3 -3
- data/features/features/package_managers/nuget_spec.rb +4 -4
- data/features/features/package_managers/pip_spec.rb +2 -2
- data/features/features/package_managers/rebar_spec.rb +3 -3
- data/features/features/package_managers/yarn_spec.rb +14 -0
- data/features/features/report/composite_spec.rb +1 -1
- data/features/features/report/csv_spec.rb +3 -3
- data/features/features/report/diff_spec.rb +20 -10
- data/features/features/report/html_spec.rb +10 -10
- data/features/features/report/subproject_spec.rb +15 -4
- data/features/fixtures/Cartfile +1 -0
- data/features/fixtures/Podfile +1 -1
- data/features/fixtures/alternate-build-file-gradle/build-alt.gradle +5 -15
- data/features/fixtures/build.gradle +5 -15
- data/features/fixtures/conanfile.txt +11 -0
- data/features/fixtures/file-based-libs-gradle/build.gradle +5 -7
- data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.lock +9 -0
- data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.toml +7 -0
- data/features/fixtures/gopath_dep/src/foo-dep/bar/bar.go +10 -0
- data/features/fixtures/gopath_dep/src/foo-dep/foo.go +7 -0
- data/features/fixtures/gopath_glide/src/glide.lock +9 -0
- data/features/fixtures/gopath_glide/src/glide.yaml +6 -0
- data/features/fixtures/gopath_govendor/src/vendor/vendor.json +19 -0
- data/features/fixtures/gopath_gvt/src/vendor/manifest +22 -0
- data/features/fixtures/gradle-wrapper/build.gradle +5 -15
- data/features/fixtures/gradle-wrapper/gradlew +6 -1
- data/features/fixtures/gradle-wrapper/gradlew.bat +9 -1
- data/features/fixtures/mix.exs +22 -0
- data/features/fixtures/multi-module-gradle/build.gradle +7 -15
- data/features/fixtures/single-module-gradle/build.gradle +5 -15
- data/features/support/testing_dsl.rb +155 -43
- data/lib/license_finder.rb +4 -3
- data/lib/license_finder/cli.rb +0 -3
- data/lib/license_finder/cli/approvals.rb +3 -3
- data/lib/license_finder/cli/base.rb +11 -8
- data/lib/license_finder/cli/blacklist.rb +7 -7
- data/lib/license_finder/cli/dependencies.rb +8 -8
- data/lib/license_finder/cli/ignored_dependencies.rb +4 -4
- data/lib/license_finder/cli/ignored_groups.rb +4 -4
- data/lib/license_finder/cli/licenses.rb +2 -2
- data/lib/license_finder/cli/main.rb +59 -39
- data/lib/license_finder/cli/makes_decisions.rb +2 -2
- data/lib/license_finder/cli/patched_thor.rb +6 -7
- data/lib/license_finder/cli/project_name.rb +5 -6
- data/lib/license_finder/cli/whitelist.rb +7 -7
- data/lib/license_finder/configuration.rb +15 -4
- data/lib/license_finder/core.rb +20 -4
- data/lib/license_finder/decision_applier.rb +0 -1
- data/lib/license_finder/decisions.rb +12 -14
- data/lib/license_finder/diff.rb +33 -31
- data/lib/license_finder/license.rb +13 -9
- data/lib/license_finder/license/definitions.rb +55 -55
- data/lib/license_finder/license/none_matcher.rb +1 -1
- data/lib/license_finder/license/template.rb +1 -1
- data/lib/license_finder/license/text.rb +0 -1
- data/lib/license_finder/license_aggregator.rb +1 -0
- data/lib/license_finder/logger.rb +18 -61
- data/lib/license_finder/package.rb +25 -11
- data/lib/license_finder/package_delta.rb +3 -6
- data/lib/license_finder/package_manager.rb +77 -34
- data/lib/license_finder/package_managers/bower.rb +8 -8
- data/lib/license_finder/package_managers/bower_package.rb +12 -12
- data/lib/license_finder/package_managers/bundler.rb +21 -9
- data/lib/license_finder/package_managers/bundler_package.rb +1 -1
- data/lib/license_finder/package_managers/carthage.rb +66 -0
- data/lib/license_finder/package_managers/carthage_package.rb +16 -0
- data/lib/license_finder/package_managers/cocoa_pods.rb +13 -13
- data/lib/license_finder/package_managers/cocoa_pods_package.rb +1 -1
- data/lib/license_finder/package_managers/conan.rb +26 -0
- data/lib/license_finder/package_managers/conan_info_parser.rb +74 -0
- data/lib/license_finder/package_managers/conan_package.rb +17 -0
- data/lib/license_finder/package_managers/dep.rb +33 -0
- data/lib/license_finder/package_managers/glide.rb +30 -0
- data/lib/license_finder/package_managers/{go_vendor.rb → go_15vendorexperiment.rb} +19 -24
- data/lib/license_finder/package_managers/go_dep.rb +15 -12
- data/lib/license_finder/package_managers/go_package.rb +15 -13
- data/lib/license_finder/package_managers/go_workspace.rb +39 -34
- data/lib/license_finder/package_managers/govendor.rb +32 -0
- data/lib/license_finder/package_managers/gradle.rb +16 -16
- data/lib/license_finder/package_managers/gradle_package.rb +8 -8
- data/lib/license_finder/package_managers/gvt.rb +61 -0
- data/lib/license_finder/package_managers/maven.rb +17 -18
- data/lib/license_finder/package_managers/maven_package.rb +4 -6
- data/lib/license_finder/package_managers/merged_package.rb +25 -2
- data/lib/license_finder/package_managers/mix.rb +51 -0
- data/lib/license_finder/package_managers/mix_package.rb +7 -0
- data/lib/license_finder/package_managers/npm.rb +8 -32
- data/lib/license_finder/package_managers/npm_package.rb +51 -48
- data/lib/license_finder/package_managers/nuget.rb +30 -40
- data/lib/license_finder/package_managers/pip.rb +11 -11
- data/lib/license_finder/package_managers/pip_package.rb +8 -8
- data/lib/license_finder/package_managers/rebar.rb +11 -11
- data/lib/license_finder/package_managers/yarn.rb +62 -0
- data/lib/license_finder/packages/activation.rb +2 -2
- data/lib/license_finder/packages/license_files.rb +6 -6
- data/lib/license_finder/packages/licensing.rb +8 -10
- data/lib/license_finder/packages/manual_package.rb +2 -2
- data/lib/license_finder/project_finder.rb +6 -5
- data/lib/license_finder/report.rb +1 -0
- data/lib/license_finder/reports/csv_report.rb +4 -4
- data/lib/license_finder/reports/diff_report.rb +2 -2
- data/lib/license_finder/reports/erb_report.rb +2 -4
- data/lib/license_finder/reports/html_report.rb +2 -2
- data/lib/license_finder/reports/markdown_report.rb +1 -1
- data/lib/license_finder/reports/merged_report.rb +1 -1
- data/lib/license_finder/reports/text_report.rb +3 -5
- data/lib/license_finder/shared_helpers/cmd.rb +11 -0
- data/lib/license_finder/version.rb +1 -1
- data/license_finder-2.1.2.gem +0 -0
- data/license_finder.gemspec +38 -38
- metadata +84 -118
- data/ci/scripts/test.sh +0 -26
- data/ci/tasks/create-source-archives.yml +0 -23
- data/spec/dummy_app/Gemfile +0 -6
- data/spec/fixtures/all_pms/.envrc +0 -1
- data/spec/fixtures/all_pms/.nuget/.keep +0 -0
- data/spec/fixtures/all_pms/Gemfile +0 -0
- data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
- data/spec/fixtures/all_pms/Podfile +0 -0
- data/spec/fixtures/all_pms/bower.json +0 -0
- data/spec/fixtures/all_pms/build.gradle +0 -0
- data/spec/fixtures/all_pms/package.json +0 -0
- data/spec/fixtures/all_pms/pom.xml +0 -0
- data/spec/fixtures/all_pms/rebar.config +0 -0
- data/spec/fixtures/all_pms/requirements.txt +0 -0
- data/spec/fixtures/all_pms/vendor/.gitkeep +0 -0
- data/spec/fixtures/composite/Gemfile +0 -0
- data/spec/fixtures/composite/nested_project/.envrc +0 -8
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +0 -16
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +0 -5
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +0 -6
- data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
- data/spec/fixtures/composite/project1/Gemfile +0 -0
- data/spec/fixtures/composite/project2/package.json +0 -0
- data/spec/fixtures/config/license_finder.yml +0 -5
- data/spec/fixtures/license_directory/COPYING +0 -1
- data/spec/fixtures/license_directory/LICENSE/MIT.txt +0 -1
- data/spec/fixtures/license_directory/LICENSE/lib/unrelated.txt +0 -2
- data/spec/fixtures/license_names/COPYING.txt +0 -1
- data/spec/fixtures/license_names/LICENSE +0 -1
- data/spec/fixtures/license_names/Licence.rdoc +0 -1
- data/spec/fixtures/license_names/Mit-License +0 -1
- data/spec/fixtures/license_names/README.rdoc +0 -1
- data/spec/fixtures/nested_gem/vendor/LICENSE +0 -1
- data/spec/fixtures/npm-circular-dependencies/npm-list.json +0 -5339
- data/spec/fixtures/npm-circular-dependencies/package.json +0 -5
- data/spec/fixtures/npm-circular-licenses/npm-list.json +0 -7597
- data/spec/fixtures/npm-circular-licenses/package.json +0 -23
- data/spec/fixtures/npm-licenses-string/npm-list.json +0 -7597
- data/spec/fixtures/npm-licenses-string/package.json +0 -23
- data/spec/fixtures/npm-recursive-dependencies/npm-list.json +0 -5158
- data/spec/fixtures/npm-recursive-dependencies/package.json +0 -15
- data/spec/fixtures/npm-stack-too-deep/npm-list.json +0 -13464
- data/spec/fixtures/npm-stack-too-deep/package.json +0 -5
- data/spec/fixtures/utf8_gem/README +0 -210
- data/spec/lib/license_finder/cli/approvals_spec.rb +0 -71
- data/spec/lib/license_finder/cli/blacklist_spec.rb +0 -58
- data/spec/lib/license_finder/cli/dependencies_spec.rb +0 -73
- data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +0 -47
- data/spec/lib/license_finder/cli/ignored_groups_spec.rb +0 -40
- data/spec/lib/license_finder/cli/licenses_spec.rb +0 -60
- data/spec/lib/license_finder/cli/main_spec.rb +0 -243
- data/spec/lib/license_finder/cli/project_name_spec.rb +0 -40
- data/spec/lib/license_finder/cli/whitelist_spec.rb +0 -58
- data/spec/lib/license_finder/configuration_spec.rb +0 -115
- data/spec/lib/license_finder/core_spec.rb +0 -54
- data/spec/lib/license_finder/decision_applier_spec.rb +0 -219
- data/spec/lib/license_finder/decisions_spec.rb +0 -408
- data/spec/lib/license_finder/diff_spec.rb +0 -129
- data/spec/lib/license_finder/license/definitions_spec.rb +0 -177
- data/spec/lib/license_finder/license_aggregator_spec.rb +0 -61
- data/spec/lib/license_finder/license_spec.rb +0 -106
- data/spec/lib/license_finder/package_delta_spec.rb +0 -18
- data/spec/lib/license_finder/package_manager_spec.rb +0 -62
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +0 -71
- data/spec/lib/license_finder/package_managers/bower_spec.rb +0 -39
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +0 -35
- data/spec/lib/license_finder/package_managers/bundler_spec.rb +0 -56
- data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +0 -48
- data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +0 -59
- data/spec/lib/license_finder/package_managers/go_dep_spec.rb +0 -126
- data/spec/lib/license_finder/package_managers/go_package_spec.rb +0 -33
- data/spec/lib/license_finder/package_managers/go_vendor_spec.rb +0 -144
- data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +0 -286
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +0 -80
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +0 -180
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +0 -63
- data/spec/lib/license_finder/package_managers/maven_spec.rb +0 -128
- data/spec/lib/license_finder/package_managers/merged_package_spec.rb +0 -60
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +0 -57
- data/spec/lib/license_finder/package_managers/npm_spec.rb +0 -253
- data/spec/lib/license_finder/package_managers/nuget_package_spec.rb +0 -9
- data/spec/lib/license_finder/package_managers/nuget_spec.rb +0 -157
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +0 -87
- data/spec/lib/license_finder/package_managers/pip_spec.rb +0 -47
- data/spec/lib/license_finder/package_managers/rebar_package_spec.rb +0 -24
- data/spec/lib/license_finder/package_managers/rebar_spec.rb +0 -50
- data/spec/lib/license_finder/package_spec.rb +0 -179
- data/spec/lib/license_finder/packages/activation_spec.rb +0 -41
- data/spec/lib/license_finder/packages/license_files_spec.rb +0 -46
- data/spec/lib/license_finder/packages/licensing_spec.rb +0 -1
- data/spec/lib/license_finder/packages/possible_license_file_spec.rb +0 -38
- data/spec/lib/license_finder/project_finder_spec.rb +0 -33
- data/spec/lib/license_finder/reports/csv_report_spec.rb +0 -70
- data/spec/lib/license_finder/reports/diff_report_spec.rb +0 -56
- data/spec/lib/license_finder/reports/html_report_spec.rb +0 -101
- data/spec/lib/license_finder/reports/markdown_report_spec.rb +0 -45
- data/spec/lib/license_finder/reports/merged_report_spec.rb +0 -21
- data/spec/lib/license_finder/reports/text_report_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -27
- data/spec/support/shared_examples_for_package_manager.rb +0 -52
- data/spec/support/stdout_helpers.rb +0 -31
- data/spec/support/test_fixtures.rb +0 -7
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe GradlePackage do
|
5
|
-
subject do
|
6
|
-
described_class.new(
|
7
|
-
"name" => "ch.qos.logback:logback-classic:1.1.1",
|
8
|
-
"license" => [ { "name" => "MIT" } ]
|
9
|
-
)
|
10
|
-
end
|
11
|
-
|
12
|
-
its(:name) { should == "logback-classic" }
|
13
|
-
its(:version) { should == "1.1.1" }
|
14
|
-
its(:authors) { should == "" }
|
15
|
-
its(:summary) { should == "" }
|
16
|
-
its(:description) { should == "" }
|
17
|
-
its(:homepage) { should == "" }
|
18
|
-
its(:groups) { should == [] } # no way to get groups from gradle?
|
19
|
-
its(:children) { should == [] } # no way to get children from gradle?
|
20
|
-
its(:install_path) { should be_nil }
|
21
|
-
its(:package_manager) { should eq 'Gradle' }
|
22
|
-
|
23
|
-
describe "when file name has a funny format, possibly because it is a jar saved in the project" do
|
24
|
-
it "uses a reasonable name and default version" do
|
25
|
-
subject = described_class.new("name" => "data.json-0.2.3.jar")
|
26
|
-
expect(subject.name).to eq "data.json-0.2.3.jar"
|
27
|
-
expect(subject.version).to eq "unknown"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#license_names_from_spec" do
|
32
|
-
it "returns the license" do
|
33
|
-
expect(subject.license_names_from_spec).to eq ["MIT"]
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when there are no licenses" do
|
37
|
-
subject { described_class.new("name" => "a:b:c") }
|
38
|
-
|
39
|
-
it "is empty" do
|
40
|
-
expect(subject.license_names_from_spec).to be_empty
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when include_groups is set to true' do
|
45
|
-
subject { described_class.new({"name" => "a:b:c"}, include_groups: true) }
|
46
|
-
|
47
|
-
it 'includes the group id in the name' do
|
48
|
-
expect(subject.name).to eq("a:b")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when there are no real licenses" do
|
53
|
-
subject do
|
54
|
-
described_class.new(
|
55
|
-
"name" => "a:b:c",
|
56
|
-
"license" => [ { "name" => "No license found"} ]
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "is empty" do
|
61
|
-
expect(subject.license_names_from_spec).to be_empty
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context "when there are multiple licenses" do
|
66
|
-
subject do
|
67
|
-
described_class.new(
|
68
|
-
"name" => "a:b:c",
|
69
|
-
"license" => [ { "name" => "1" }, { "name" => "2" } ]
|
70
|
-
)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "returns multiple licenses" do
|
74
|
-
expect(subject.license_names_from_spec).to eq ['1', '2']
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
@@ -1,180 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fakefs/spec_helpers'
|
3
|
-
|
4
|
-
module LicenseFinder
|
5
|
-
describe Gradle do
|
6
|
-
let(:options) { {} }
|
7
|
-
|
8
|
-
subject { Gradle.new(options.merge(project_path: Pathname('/fake/path'))) }
|
9
|
-
|
10
|
-
let(:content) { [] }
|
11
|
-
|
12
|
-
it_behaves_like 'a PackageManager'
|
13
|
-
|
14
|
-
describe '#current_packages' do
|
15
|
-
before do
|
16
|
-
allow(Dir).to receive(:chdir).with(Pathname('/fake/path')).and_return(['', true])
|
17
|
-
dependencies = double(:subject_dependency_file, dependencies: content)
|
18
|
-
expect(GradleDependencyFinder).to receive(:new).and_return(dependencies)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'uses the gradle wrapper, if present' do
|
22
|
-
subject = Gradle.new(project_path: Pathname('features/fixtures/gradle-wrapper'))
|
23
|
-
expect(Dir).to receive(:chdir).with(Pathname('features/fixtures/gradle-wrapper')).and_call_original
|
24
|
-
if Platform.windows?
|
25
|
-
expect(subject.package_management_command).to eq('gradlew.bat')
|
26
|
-
else
|
27
|
-
expect(subject.package_management_command).to eq('./gradlew')
|
28
|
-
end
|
29
|
-
subject.current_packages
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'uses custom subject command, if provided' do
|
33
|
-
subject = Gradle.new(gradle_command: 'subjectfoo', project_path: Pathname('/fake/path'))
|
34
|
-
expect(Dir).to receive(:chdir).with(Pathname('/fake/path')) { |&block| block.call }
|
35
|
-
expect(subject).to receive(:capture).with('subjectfoo downloadLicenses').and_return(['', true])
|
36
|
-
subject.current_packages
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'sets the working directory to project_path, if provided' do
|
40
|
-
subject = Gradle.new(project_path: Pathname('/Users/foo/bar'))
|
41
|
-
expect(Dir).to receive(:chdir).with(Pathname('/Users/foo/bar')) { |&block| block.call }
|
42
|
-
if Platform.windows?
|
43
|
-
expect(subject).to receive(:capture).with('gradle.bat downloadLicenses').and_return(['', true])
|
44
|
-
else
|
45
|
-
expect(subject).to receive(:capture).with('gradle downloadLicenses').and_return(['', true])
|
46
|
-
end
|
47
|
-
subject.current_packages
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'when dependencies are found' do
|
51
|
-
let(:content) do
|
52
|
-
[
|
53
|
-
"<dependencies>
|
54
|
-
<dependency name='org.springframework:spring-aop:4.0.1.RELEASE'></dependency>
|
55
|
-
<dependency name='org.springframework:spring-core:4.0.1.RELEASE'></dependency>
|
56
|
-
</dependencies>"
|
57
|
-
]
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'lists all dependencies' do
|
61
|
-
expect(subject.current_packages.map(&:name)).to eq ['spring-aop', 'spring-core']
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'when gradle group ids option is enabled' do
|
65
|
-
let(:options) { { gradle_include_groups: true } }
|
66
|
-
|
67
|
-
it 'lists the dependencies with the group id' do
|
68
|
-
expect(subject.current_packages.map(&:name)).to eq ['org.springframework:spring-aop', 'org.springframework:spring-core']
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'when multiple licenses exist' do
|
74
|
-
let(:content) do
|
75
|
-
[
|
76
|
-
"<dependencies>
|
77
|
-
<dependency name=''>
|
78
|
-
<license name='License 1'/>
|
79
|
-
<license name='License 2'/>
|
80
|
-
</dependency>
|
81
|
-
</dependencies>"
|
82
|
-
]
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'lists all dependencies' do
|
86
|
-
expect(subject.current_packages.first.licenses.map(&:name)).to eq ['License 1', 'License 2']
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'when no licenses exist' do
|
91
|
-
let(:content) do
|
92
|
-
[
|
93
|
-
"<dependencies>
|
94
|
-
<dependency name=''></dependency>
|
95
|
-
</dependencies>"
|
96
|
-
]
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'returns unknown' do
|
100
|
-
expect(subject.current_packages.first.licenses.map(&:name)).to eq ['unknown']
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'when multiple license files exist' do
|
105
|
-
let(:content) do
|
106
|
-
[
|
107
|
-
"<dependencies>
|
108
|
-
<dependency name='junit:junit:4.12'></dependency>
|
109
|
-
</dependencies>",
|
110
|
-
"<dependencies>
|
111
|
-
<dependency name='org.mockito:mockito-core:1.9.5'></dependency>
|
112
|
-
</dependencies>"
|
113
|
-
]
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'lists all dependencies' do
|
117
|
-
expect(subject.current_packages.map(&:name)).to eq ['junit', 'mockito-core']
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'and there are duplicate dependencies' do
|
121
|
-
let(:content) do
|
122
|
-
[
|
123
|
-
"<dependencies>
|
124
|
-
<dependency name='junit:junit:4.12'></dependency>
|
125
|
-
</dependencies>",
|
126
|
-
"<dependencies>
|
127
|
-
<dependency name='org.mockito:mockito-core:1.9.5'></dependency>
|
128
|
-
</dependencies>",
|
129
|
-
"<dependencies>
|
130
|
-
<dependency name='org.mockito:mockito-core:1.9.5'></dependency>
|
131
|
-
</dependencies>"
|
132
|
-
]
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'removes duplicates' do
|
136
|
-
expect(subject.current_packages.map(&:name)).to eq ['junit', 'mockito-core']
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe '#active?' do
|
143
|
-
include FakeFS::SpecHelpers
|
144
|
-
|
145
|
-
it 'return true if build.gradle exists' do
|
146
|
-
FakeFS do
|
147
|
-
FileUtils.mkdir_p '/fake/path'
|
148
|
-
FileUtils.touch '/fake/path/build.gradle'
|
149
|
-
|
150
|
-
expect(subject.active?).to be true
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
context "when there's no build.gradle" do
|
155
|
-
it 'returns false' do
|
156
|
-
expect(subject.active?).to be false
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
context "when there's a settings.gradle" do
|
161
|
-
it 'uses the build.gradle referenced inside' do
|
162
|
-
SETTINGS_DOT_GRADLE = <<-eos
|
163
|
-
rootProject.buildFileName = 'build-alt.gradle'
|
164
|
-
eos
|
165
|
-
|
166
|
-
FakeFS do
|
167
|
-
FileUtils.mkdir_p '/fake/path'
|
168
|
-
File.open('/fake/path/settings.gradle', 'w') do |file|
|
169
|
-
file.write SETTINGS_DOT_GRADLE
|
170
|
-
end
|
171
|
-
FileUtils.touch '/fake/path/build-alt.gradle'
|
172
|
-
|
173
|
-
expect(subject.active?).to be true
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe MavenPackage do
|
5
|
-
let(:options) { {} }
|
6
|
-
subject do
|
7
|
-
described_class.new(
|
8
|
-
{
|
9
|
-
"groupId" => "org.hamcrest",
|
10
|
-
"artifactId" => "hamcrest-core",
|
11
|
-
"version" => "4.11",
|
12
|
-
"licenses" => [{ "name" => "MIT" }],
|
13
|
-
},
|
14
|
-
options
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
its(:name) { should == "hamcrest-core" }
|
19
|
-
its(:version) { should == "4.11" }
|
20
|
-
its(:summary) { should == "" }
|
21
|
-
its(:description) { should == "" }
|
22
|
-
its(:homepage) { should == "" }
|
23
|
-
its(:groups) { should == [] } # no way to get groups from maven?
|
24
|
-
its(:children) { should == [] } # no way to get children from maven?
|
25
|
-
its(:install_path) { should be_nil }
|
26
|
-
its(:package_manager) { should eq 'Maven' }
|
27
|
-
|
28
|
-
describe "#license_names_from_spec" do
|
29
|
-
it "returns the license" do
|
30
|
-
expect(subject.license_names_from_spec).to eq ["MIT"]
|
31
|
-
end
|
32
|
-
|
33
|
-
context "when there are no licenses" do
|
34
|
-
subject { described_class.new({}) }
|
35
|
-
|
36
|
-
it "is empty" do
|
37
|
-
expect(subject.license_names_from_spec).to be_empty
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when include_groups is set to true' do
|
42
|
-
let(:options) { {include_groups: true} }
|
43
|
-
|
44
|
-
it 'includes the group id in the name' do
|
45
|
-
expect(subject.name).to eq("org.hamcrest:hamcrest-core")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "when there are multiple licenses" do
|
50
|
-
subject do
|
51
|
-
described_class.new(
|
52
|
-
"licenses" => [{ "name" => "1" }, { "name" => "2" }]
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "returns multiple licenses" do
|
57
|
-
expect(subject.license_names_from_spec).to eq ['1', '2']
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe Maven do
|
5
|
-
let(:options) { {} }
|
6
|
-
|
7
|
-
subject { Maven.new(options.merge(project_path: Pathname('/fake/path'))) }
|
8
|
-
|
9
|
-
it_behaves_like "a PackageManager"
|
10
|
-
|
11
|
-
def license_xml(xml)
|
12
|
-
<<-resp
|
13
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
14
|
-
<licenseSummary>
|
15
|
-
<dependencies>
|
16
|
-
#{xml}
|
17
|
-
</dependencies>
|
18
|
-
</licenseSummary>
|
19
|
-
resp
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '.current_packages' do
|
23
|
-
before do
|
24
|
-
allow(Dir).to receive(:chdir).with(Pathname('/fake/path')) { |&block| block.call }
|
25
|
-
allow(subject).to receive(:capture).with('mvn org.codehaus.mojo:license-maven-plugin:download-licenses').and_return(['', true])
|
26
|
-
end
|
27
|
-
|
28
|
-
def stub_license_report(deps)
|
29
|
-
dependencies = double(:subject_dependency_file, dependencies: [license_xml(deps)])
|
30
|
-
expect(MavenDependencyFinder).to receive(:new).and_return(dependencies)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'uses the maven wrapper, if present' do
|
34
|
-
subject = Maven.new(project_path: Pathname('features/fixtures/maven-wrapper'))
|
35
|
-
expect(Dir).to receive(:chdir).with(Pathname('features/fixtures/maven-wrapper')).and_call_original
|
36
|
-
expect(subject.package_management_command).to eq('./mvnw').or eq('mvnw.cmd')
|
37
|
-
subject.current_packages
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'lists all the current packages' do
|
41
|
-
stub_license_report("
|
42
|
-
<dependency>
|
43
|
-
<groupId>org.otherorg</groupId>
|
44
|
-
<artifactId>junit</artifactId>
|
45
|
-
<version>4.11</version>
|
46
|
-
</dependency>
|
47
|
-
<dependency>
|
48
|
-
<groupId>org.hamcrest</groupId>
|
49
|
-
<artifactId>hamcrest-core</artifactId>
|
50
|
-
<version>1.3</version>
|
51
|
-
</dependency>
|
52
|
-
")
|
53
|
-
|
54
|
-
expect(subject.current_packages.map { |p| [p.name, p.version] }).to eq [
|
55
|
-
["junit", "4.11"],
|
56
|
-
["hamcrest-core", "1.3"]
|
57
|
-
]
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when ignored_groups is used' do
|
61
|
-
subject {
|
62
|
-
Maven.new(options.merge(
|
63
|
-
project_path: Pathname('/fake/path'),
|
64
|
-
ignored_groups: Set.new(%w(system test provided import))
|
65
|
-
))
|
66
|
-
}
|
67
|
-
|
68
|
-
before do
|
69
|
-
expect(subject).to receive(:capture).with('mvn org.codehaus.mojo:license-maven-plugin:download-licenses -Dlicense.excludedScopes=system,test,provided,import').and_return(['', true])
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'uses skips the specified groups' do
|
73
|
-
subject.current_packages
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
it "handles multiple licenses" do
|
78
|
-
stub_license_report("
|
79
|
-
<dependency>
|
80
|
-
<licenses>
|
81
|
-
<license>
|
82
|
-
<name>License 1</name>
|
83
|
-
</license>
|
84
|
-
<license>
|
85
|
-
<name>License 2</name>
|
86
|
-
</license>
|
87
|
-
</licenses>
|
88
|
-
</dependency>
|
89
|
-
")
|
90
|
-
|
91
|
-
expect(subject.current_packages.first.licenses.map(&:name)).to eq ['License 1', 'License 2']
|
92
|
-
end
|
93
|
-
|
94
|
-
context 'when maven group ids option is enabled' do
|
95
|
-
let(:options) { { maven_include_groups: true } }
|
96
|
-
|
97
|
-
it 'lists all the current packages' do
|
98
|
-
stub_license_report("
|
99
|
-
<dependency>
|
100
|
-
<groupId>junit</groupId>
|
101
|
-
<artifactId>junit</artifactId>
|
102
|
-
<version>4.11</version>
|
103
|
-
</dependency>
|
104
|
-
<dependency>
|
105
|
-
<groupId>org.hamcrest</groupId>
|
106
|
-
<artifactId>hamcrest-core</artifactId>
|
107
|
-
<version>1.3</version>
|
108
|
-
</dependency>
|
109
|
-
")
|
110
|
-
|
111
|
-
expect(subject.current_packages.map { |p| [p.name, p.version] }).to eq [
|
112
|
-
["junit:junit", "4.11"],
|
113
|
-
["org.hamcrest:hamcrest-core", "1.3"]
|
114
|
-
]
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
it "handles no licenses" do
|
119
|
-
stub_license_report("
|
120
|
-
<dependency>
|
121
|
-
</dependency>
|
122
|
-
")
|
123
|
-
|
124
|
-
expect(subject.current_packages.first.licenses.map(&:name)).to eq ['unknown']
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|