1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
require 'spec_helper'
RSpec.describe "gradle" do
context "when running a default gradle build" do
it 'scans a gradle project' do
content = <<~GRADLE
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds
*/
plugins {
id "com.github.hierynomus.license" version "0.15.0"
}
GRADLE
runner.add_file('build.gradle', content)
report = runner.scan
expect(report).to match_schema(version: '2.0')
expect(report[:licenses]).to be_empty
expect(report[:dependencies]).to be_empty
end
end
context 'when scanning a gradle project that does not include the `com.github.hierynomus.license` plugin' do
let(:project_url) { 'https://gitlab.com/one-touch-pipeline/otp.git' }
let(:result) { runner.scan }
before do
runner.clone(project_url)
end
it 'is able to detect licenses' do
expect(result).not_to be_empty
expect(result).to match_schema(version: '2.0')
expect(result[:licenses]).not_to be_empty
[
{ name: 'ant', licenses: ['Apache-2.0'] },
{ name: 'activation', licenses: ['CDDL-1.0'] },
{ name: 'xml-apis', licenses: ['Apache-2.0', 'SAX-PD', 'W3C-20150513'] },
{ name: 'sitemesh', licenses: ['Apache-1.1'] },
{ name: 'hibernate-jpa-2.1-api', licenses: ['BSD-3-Clause', 'EPL-1.0'] },
].each do |dependency|
expect(find_in(result, dependency[:name])[:licenses]).to match_array(dependency[:licenses])
end
end
end
context 'when scanning a gradle project that uses kotlin' do
let(:build_file_content) do
<<~GRADLE
plugins {
`java-library`
}
repositories {
jcenter()
}
dependencies {
api("org.apache.commons:commons-math3:3.6.1")
implementation("com.google.guava:guava:28.1-jre")
testImplementation("junit:junit:4.12")
}
GRADLE
end
let(:settings_file_content) { 'rootProject.name = "example"' }
it 'scans a gradle project' do
runner.add_file('build.gradle.kts', build_file_content)
runner.add_file('settings.gradle.kts', settings_file_content)
report = runner.scan
expect(report).to match_schema(version: '2.0')
expect(report[:licenses]).to be_empty
expect(report[:dependencies]).to be_empty
end
end
context "when scanning a v6 gradle project" do
it 'scans a gradle project' do
content = <<~GRADLE
GRADLE
runner.add_file('build.gradle', content)
report = runner.scan
expect(report).to match_schema(version: '2.0')
expect(report[:licenses]).to be_empty
expect(report[:dependencies]).to be_empty
end
end
context "when scanning a v5 gradle project"
context "when scanning a v4 gradle project"
context "when scanning a v3 gradle project"
context "when scanning a v2 gradle project"
context "when scanning a v1 gradle project"
end
|