From f3cf36abb1b346ae0b25e8d6396aa63400b058d9 Mon Sep 17 00:00:00 2001 From: Mark Houghton Date: Mon, 30 Apr 2018 16:32:02 +0100 Subject: [PATCH 1/7] Add more info to the reports. 1. List dependencies for which no license was found. For these, licenses will be an empty array for the JSON report, and the HTML report will show a category for "no license found". 2. Include the original Gradle dependency string in the JSON report (useful to track down dependencies when the description is not enough). --- .../jaredsburrows/license/LicenseReportTask.groovy | 5 +++-- .../license/internal/pom/Project.groovy | 1 + .../license/internal/report/HtmlReport.groovy | 14 +++++++++++--- .../license/internal/report/JsonReport.groovy | 4 +++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy b/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy index 63f0bbd5..b08d9343 100644 --- a/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy +++ b/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy @@ -151,7 +151,7 @@ class LicenseReportTask extends DefaultTask { def licenses = findLicenses(pomFile) if (!licenses) { logger.log(LogLevel.WARN, "${name} dependency does not have a license.") - return + licenses = [] } // Store the information that we need @@ -162,7 +162,8 @@ class LicenseReportTask extends DefaultTask { developers: developers, licenses: licenses, url: url, - year: year + year: year, + dependencyString: pom.owner ) projects << project diff --git a/src/main/groovy/com/jaredsburrows/license/internal/pom/Project.groovy b/src/main/groovy/com/jaredsburrows/license/internal/pom/Project.groovy index 4ff1ba30..80f4c9f0 100644 --- a/src/main/groovy/com/jaredsburrows/license/internal/pom/Project.groovy +++ b/src/main/groovy/com/jaredsburrows/license/internal/pom/Project.groovy @@ -8,4 +8,5 @@ final class Project { String url List developers String year + String dependencyString } diff --git a/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy b/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy index 1642f9d3..2dd067c5 100644 --- a/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy +++ b/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy @@ -11,6 +11,7 @@ final class HtmlReport { final static def CSS_STYLE = BODY_CSS + " " + PRE_CSS final static def OPEN_SOURCE_LIBRARIES = "Open source licenses" final static def NO_LIBRARIES = "None" + final static def NO_LICENSE = "No license found" final static def NOTICE_LIBRARIES = "Notice for packages:" final List projects @@ -35,7 +36,12 @@ final class HtmlReport { // Store packages by license projects.each { project -> - def key = project.licenses[0] + def key = new License(name: "No license found", url: "N/A") + + if (project.licenses.size > 0) { + key = project.licenses[0] + } + if (!projectsMap.containsKey(key)) { projectsMap.put(key, []) } @@ -73,7 +79,9 @@ final class HtmlReport { // Display associated license with libraries // Try to find license by URL, name and then default to whatever is listed in the POM.xml def licenseMap = LicenseHelper.LICENSE_MAP - if (licenseMap.containsKey(entry.key.url)) { + if (currentProject.licenses.size == 0) { + pre(NO_LICENSE) + } else if (licenseMap.containsKey(entry.key.url)) { a(name: currentLicense) pre(getLicenseText(licenseMap.get(entry.key.url))) } else if (licenseMap.containsKey(entry.key.name)) { @@ -83,7 +91,7 @@ final class HtmlReport { if (currentProject && (currentProject.licenses[0].name.trim() || currentProject.licenses[0].url.trim())) { pre("${currentProject.licenses[0].name.trim()}\n${currentProject.licenses[0].url.trim()}") } else { - pre(NO_LIBRARIES) + pre(NO_LICENSE) } } } diff --git a/src/main/groovy/com/jaredsburrows/license/internal/report/JsonReport.groovy b/src/main/groovy/com/jaredsburrows/license/internal/report/JsonReport.groovy index 3314b586..8e7ca6cf 100644 --- a/src/main/groovy/com/jaredsburrows/license/internal/report/JsonReport.groovy +++ b/src/main/groovy/com/jaredsburrows/license/internal/report/JsonReport.groovy @@ -15,6 +15,7 @@ final class JsonReport { private final static def LICENSE = "license" private final static def LICENSE_URL = "license_url" private final static def EMPTY_JSON_ARRAY = "[]" + private final static def DEPENDENCY_STRING = "dependency_string" private final List projects JsonReport(projects) { @@ -45,7 +46,8 @@ final class JsonReport { "$DEVELOPERS" : project.developers*.name, "$URL" : project.url ? project.url : null, "$YEAR" : project.year ? project.year : null, - "$LICENSES" : licensesJson + "$LICENSES" : licensesJson, + "$DEPENDENCY_STRING": project.dependencyString ] }) } From 78888e0855566bddfb8ef9946d5472ab1ea77ce9 Mon Sep 17 00:00:00 2001 From: Mark Houghton Date: Mon, 30 Apr 2018 17:04:29 +0100 Subject: [PATCH 2/7] Updated tests Updated tests to include cases with and without license info, and to include the dependency string in the JSON report tests. --- .../license/internal/report/HtmlReport.groovy | 4 +-- .../internal/report/HtmlReportSpec.groovy | 8 +++++- .../internal/report/JsonReportSpec.groovy | 27 +++++++++---------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy b/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy index 2dd067c5..16b18434 100644 --- a/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy +++ b/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy @@ -38,7 +38,7 @@ final class HtmlReport { projects.each { project -> def key = new License(name: "No license found", url: "N/A") - if (project.licenses.size > 0) { + if (project.licenses && project.licenses.size > 0) { key = project.licenses[0] } @@ -79,7 +79,7 @@ final class HtmlReport { // Display associated license with libraries // Try to find license by URL, name and then default to whatever is listed in the POM.xml def licenseMap = LicenseHelper.LICENSE_MAP - if (currentProject.licenses.size == 0) { + if (!currentProject.licenses || currentProject.licenses.size == 0) { pre(NO_LICENSE) } else if (licenseMap.containsKey(entry.key.url)) { a(name: currentLicense) diff --git a/src/test/groovy/com/jaredsburrows/license/internal/report/HtmlReportSpec.groovy b/src/test/groovy/com/jaredsburrows/license/internal/report/HtmlReportSpec.groovy index 70ed62ce..4c079c63 100644 --- a/src/test/groovy/com/jaredsburrows/license/internal/report/HtmlReportSpec.groovy +++ b/src/test/groovy/com/jaredsburrows/license/internal/report/HtmlReportSpec.groovy @@ -37,7 +37,9 @@ final class HtmlReportSpec extends Specification { def license = new License(name: "name", url: "url") def project = new Project(name: "name", licenses: [license], url: "url", developers: developers, year: "year") - def projects = [project, project] + def missingLicensesproject = new Project(name: "name", url: "url", developers: developers, + year: "year") + def projects = [project, project, missingLicensesproject] def sut = new HtmlReport(projects) when: @@ -52,6 +54,10 @@ final class HtmlReportSpec extends Specification {

Notice for packages:

    +
  • + name +
  • +
    No license found
  • name
  • diff --git a/src/test/groovy/com/jaredsburrows/license/internal/report/JsonReportSpec.groovy b/src/test/groovy/com/jaredsburrows/license/internal/report/JsonReportSpec.groovy index dfc82bf4..535de1af 100644 --- a/src/test/groovy/com/jaredsburrows/license/internal/report/JsonReportSpec.groovy +++ b/src/test/groovy/com/jaredsburrows/license/internal/report/JsonReportSpec.groovy @@ -24,8 +24,7 @@ final class JsonReportSpec extends Specification { def "open source json - missing values"() { given: - def license = new License(name: "name", url: "url") - def project = new Project(name: "name", licenses: [license], developers: []) + def project = new Project(name: "name", developers: [], dependencyString: "foo:bar:1.2.3") def projects = [project, project] def sut = new JsonReport(projects) @@ -44,11 +43,9 @@ final class JsonReportSpec extends Specification { "url": null, "year": null, "licenses": [ - { - "license": "name", - "license_url": "url" - } - ] + + ], + "dependency_string": "foo:bar:1.2.3" }, { "project": "name", @@ -60,11 +57,9 @@ final class JsonReportSpec extends Specification { "url": null, "year": null, "licenses": [ - { - "license": "name", - "license_url": "url" - } - ] + + ], + "dependency_string": "foo:bar:1.2.3" } ] """.stripIndent().trim() @@ -79,7 +74,7 @@ final class JsonReportSpec extends Specification { def developers = [developer, developer] def license = new License(name: "name", url: "url") def project = new Project(name: "name", description: "description", version: "1.0.0", - licenses: [license], url: "url", developers: developers, year: "year") + licenses: [license], url: "url", developers: developers, year: "year", dependencyString: "foo:bar:1.2.3") def projects = [project, project] def sut = new JsonReport(projects) @@ -103,7 +98,8 @@ final class JsonReportSpec extends Specification { "license": "name", "license_url": "url" } - ] + ], + "dependency_string": "foo:bar:1.2.3" }, { "project": "name", @@ -120,7 +116,8 @@ final class JsonReportSpec extends Specification { "license": "name", "license_url": "url" } - ] + ], + "dependency_string": "foo:bar:1.2.3" } ] """.stripIndent().trim() From 5a0f90a38a2c52863e28d2f192631f994781286f Mon Sep 17 00:00:00 2001 From: Mark Houghton Date: Wed, 16 May 2018 18:01:29 +0100 Subject: [PATCH 3/7] Fixing unit tests. --- .../LicenseReportTaskAndroidSpec.groovy | 61 ++++++++++++++----- .../license/LicenseReportTaskJavaSpec.groovy | 55 +++++++++++++---- 2 files changed, 90 insertions(+), 26 deletions(-) diff --git a/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy b/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy index cd028bd0..8b6d5438 100644 --- a/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy +++ b/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy @@ -103,14 +103,35 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { Open source licenses -

    None

    +

    Notice for packages:

    + """.stripIndent().trim() def actualJson = task.jsonFile.text.stripIndent().trim() def expectedJson = """ -[] +[ + { + "project": "Firebase-core", + "description": null, + "version": "10.0.1", + "developers": [ + + ], + "url": null, + "year": null, + "licenses": [ + + ], + "dependency_string": "com.google.firebase:firebase-core:10.0.1" + } +] """.stripIndent().trim() then: @@ -186,7 +207,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -202,7 +224,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -285,7 +308,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -301,7 +325,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -404,7 +429,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -420,7 +446,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:design:26.1.0" }, { "project": "Support-annotations", @@ -436,7 +463,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:support-annotations:26.1.0" }, { "project": "Support-v4", @@ -452,7 +480,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:support-v4:26.1.0" } ] """.stripIndent().trim() @@ -533,7 +562,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The MIT License", "license_url": "http://opensource.org/licenses/MIT" } - ] + ], + "dependency_string": "pl.droidsonroids.gif:android-gif-drawable:1.2.3" }, { "project": "Design", @@ -549,7 +579,8 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -732,7 +763,8 @@ http://website.tld/ "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:design:26.1.0" }, { "project": "Fake dependency name", @@ -748,7 +780,8 @@ http://website.tld/ "license": "Some license", "license_url": "http://website.tld/" } - ] + ], + "dependency_string": "group:name:1.0.0" } ] """.stripIndent().trim() diff --git a/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskJavaSpec.groovy b/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskJavaSpec.groovy index 86466fc4..7cb713fe 100644 --- a/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskJavaSpec.groovy +++ b/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskJavaSpec.groovy @@ -97,7 +97,8 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -113,7 +114,8 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -145,14 +147,35 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { Open source licenses -

    None

    +

    Notice for packages:

    + """.stripIndent().trim() def actualJson = task.jsonFile.text.stripIndent().trim() def expectedJson = """ -[] +[ + { + "project": "Firebase-core", + "description": null, + "version": "10.0.1", + "developers": [ + + ], + "url": null, + "year": null, + "licenses": [ + + ], + "dependency_string": "com.google.firebase:firebase-core:10.0.1" + } +] """.stripIndent().trim() then: @@ -217,7 +240,8 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -233,7 +257,8 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -331,7 +356,8 @@ http://website.tld/ "license": "Some license", "license_url": "http://website.tld/" } - ] + ], + "dependency_string": "group:name:1.0.0" } ] """.stripIndent().trim() @@ -396,7 +422,8 @@ http://website.tld/ "license": "Some license", "license_url": "http://website.tld/" } - ] + ], + "dependency_string": "group:name2:1.0.0" } ] """.stripIndent().trim() @@ -463,7 +490,8 @@ http://website.tld/ "license": "Some license", "license_url": "http://website.tld/" } - ] + ], + "dependency_string": "group:child:1.0.0" }, { "project": "Retrofit", @@ -479,7 +507,8 @@ http://website.tld/ "license": "Apache 2.0", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.squareup.retrofit2:retrofit:2.3.0" } ] """.stripIndent().trim() @@ -549,7 +578,8 @@ http://website.tld/ "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -565,7 +595,8 @@ http://website.tld/ "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency_string": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() From 70a62ccc93c6286a2050442753139848806ec0c9 Mon Sep 17 00:00:00 2001 From: Mark Houghton Date: Wed, 30 May 2018 14:03:31 +0100 Subject: [PATCH 4/7] Address comments from review. Changed "dependency_string" to "dependency" in the JSON output. Made some strings into constants. --- .../license/LicenseReportTask.groovy | 2 +- .../license/internal/pom/Project.groovy | 2 +- .../license/internal/report/HtmlReport.groovy | 3 ++- .../license/internal/report/JsonReport.groovy | 4 +-- .../LicenseReportTaskAndroidSpec.groovy | 26 +++++++++---------- .../license/LicenseReportTaskJavaSpec.groovy | 22 ++++++++-------- .../internal/report/JsonReportSpec.groovy | 12 ++++----- 7 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy b/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy index b08d9343..b3d3d28b 100644 --- a/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy +++ b/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy @@ -163,7 +163,7 @@ class LicenseReportTask extends DefaultTask { licenses: licenses, url: url, year: year, - dependencyString: pom.owner + gav: pom.owner ) projects << project diff --git a/src/main/groovy/com/jaredsburrows/license/internal/pom/Project.groovy b/src/main/groovy/com/jaredsburrows/license/internal/pom/Project.groovy index 80f4c9f0..b404a618 100644 --- a/src/main/groovy/com/jaredsburrows/license/internal/pom/Project.groovy +++ b/src/main/groovy/com/jaredsburrows/license/internal/pom/Project.groovy @@ -8,5 +8,5 @@ final class Project { String url List developers String year - String dependencyString + String gav // Group/artifact/version } diff --git a/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy b/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy index 16b18434..74b0bf0b 100644 --- a/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy +++ b/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy @@ -13,6 +13,7 @@ final class HtmlReport { final static def NO_LIBRARIES = "None" final static def NO_LICENSE = "No license found" final static def NOTICE_LIBRARIES = "Notice for packages:" + final static def NO_URL = "N/A" final List projects HtmlReport(def projects) { @@ -36,7 +37,7 @@ final class HtmlReport { // Store packages by license projects.each { project -> - def key = new License(name: "No license found", url: "N/A") + def key = new License(name: NO_LICENSE, url: NO_URL) if (project.licenses && project.licenses.size > 0) { key = project.licenses[0] diff --git a/src/main/groovy/com/jaredsburrows/license/internal/report/JsonReport.groovy b/src/main/groovy/com/jaredsburrows/license/internal/report/JsonReport.groovy index 8e7ca6cf..08788441 100644 --- a/src/main/groovy/com/jaredsburrows/license/internal/report/JsonReport.groovy +++ b/src/main/groovy/com/jaredsburrows/license/internal/report/JsonReport.groovy @@ -15,7 +15,7 @@ final class JsonReport { private final static def LICENSE = "license" private final static def LICENSE_URL = "license_url" private final static def EMPTY_JSON_ARRAY = "[]" - private final static def DEPENDENCY_STRING = "dependency_string" + private final static def DEPENDENCY = "dependency" private final List projects JsonReport(projects) { @@ -47,7 +47,7 @@ final class JsonReport { "$URL" : project.url ? project.url : null, "$YEAR" : project.year ? project.year : null, "$LICENSES" : licensesJson, - "$DEPENDENCY_STRING": project.dependencyString + "$DEPENDENCY" : project.gav ] }) } diff --git a/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy b/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy index 8b6d5438..6f6d6290 100644 --- a/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy +++ b/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy @@ -129,7 +129,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "licenses": [ ], - "dependency_string": "com.google.firebase:firebase-core:10.0.1" + "dependency": "com.google.firebase:firebase-core:10.0.1" } ] """.stripIndent().trim() @@ -208,7 +208,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:appcompat-v7:26.1.0" + "dependency": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -225,7 +225,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:design:26.1.0" + "dependency": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -309,7 +309,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:appcompat-v7:26.1.0" + "dependency": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -326,7 +326,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:design:26.1.0" + "dependency": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -430,7 +430,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:appcompat-v7:26.1.0" + "dependency": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -447,7 +447,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:design:26.1.0" + "dependency": "com.android.support:design:26.1.0" }, { "project": "Support-annotations", @@ -464,7 +464,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:support-annotations:26.1.0" + "dependency": "com.android.support:support-annotations:26.1.0" }, { "project": "Support-v4", @@ -481,7 +481,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:support-v4:26.1.0" + "dependency": "com.android.support:support-v4:26.1.0" } ] """.stripIndent().trim() @@ -563,7 +563,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://opensource.org/licenses/MIT" } ], - "dependency_string": "pl.droidsonroids.gif:android-gif-drawable:1.2.3" + "dependency": "pl.droidsonroids.gif:android-gif-drawable:1.2.3" }, { "project": "Design", @@ -580,7 +580,7 @@ final class LicenseReportTaskAndroidSpec extends BaseAndroidSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:design:26.1.0" + "dependency": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -764,7 +764,7 @@ http://website.tld/ "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:design:26.1.0" + "dependency": "com.android.support:design:26.1.0" }, { "project": "Fake dependency name", @@ -781,7 +781,7 @@ http://website.tld/ "license_url": "http://website.tld/" } ], - "dependency_string": "group:name:1.0.0" + "dependency": "group:name:1.0.0" } ] """.stripIndent().trim() diff --git a/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskJavaSpec.groovy b/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskJavaSpec.groovy index 7cb713fe..fb46e086 100644 --- a/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskJavaSpec.groovy +++ b/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskJavaSpec.groovy @@ -98,7 +98,7 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:appcompat-v7:26.1.0" + "dependency": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -115,7 +115,7 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:design:26.1.0" + "dependency": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -173,7 +173,7 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { "licenses": [ ], - "dependency_string": "com.google.firebase:firebase-core:10.0.1" + "dependency": "com.google.firebase:firebase-core:10.0.1" } ] """.stripIndent().trim() @@ -241,7 +241,7 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:appcompat-v7:26.1.0" + "dependency": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -258,7 +258,7 @@ final class LicenseReportTaskJavaSpec extends BaseJavaSpecification { "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:design:26.1.0" + "dependency": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() @@ -357,7 +357,7 @@ http://website.tld/ "license_url": "http://website.tld/" } ], - "dependency_string": "group:name:1.0.0" + "dependency": "group:name:1.0.0" } ] """.stripIndent().trim() @@ -423,7 +423,7 @@ http://website.tld/ "license_url": "http://website.tld/" } ], - "dependency_string": "group:name2:1.0.0" + "dependency": "group:name2:1.0.0" } ] """.stripIndent().trim() @@ -491,7 +491,7 @@ http://website.tld/ "license_url": "http://website.tld/" } ], - "dependency_string": "group:child:1.0.0" + "dependency": "group:child:1.0.0" }, { "project": "Retrofit", @@ -508,7 +508,7 @@ http://website.tld/ "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.squareup.retrofit2:retrofit:2.3.0" + "dependency": "com.squareup.retrofit2:retrofit:2.3.0" } ] """.stripIndent().trim() @@ -579,7 +579,7 @@ http://website.tld/ "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:appcompat-v7:26.1.0" + "dependency": "com.android.support:appcompat-v7:26.1.0" }, { "project": "Design", @@ -596,7 +596,7 @@ http://website.tld/ "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } ], - "dependency_string": "com.android.support:design:26.1.0" + "dependency": "com.android.support:design:26.1.0" } ] """.stripIndent().trim() diff --git a/src/test/groovy/com/jaredsburrows/license/internal/report/JsonReportSpec.groovy b/src/test/groovy/com/jaredsburrows/license/internal/report/JsonReportSpec.groovy index 535de1af..3d0334c8 100644 --- a/src/test/groovy/com/jaredsburrows/license/internal/report/JsonReportSpec.groovy +++ b/src/test/groovy/com/jaredsburrows/license/internal/report/JsonReportSpec.groovy @@ -24,7 +24,7 @@ final class JsonReportSpec extends Specification { def "open source json - missing values"() { given: - def project = new Project(name: "name", developers: [], dependencyString: "foo:bar:1.2.3") + def project = new Project(name: "name", developers: [], gav: "foo:bar:1.2.3") def projects = [project, project] def sut = new JsonReport(projects) @@ -45,7 +45,7 @@ final class JsonReportSpec extends Specification { "licenses": [ ], - "dependency_string": "foo:bar:1.2.3" + "dependency": "foo:bar:1.2.3" }, { "project": "name", @@ -59,7 +59,7 @@ final class JsonReportSpec extends Specification { "licenses": [ ], - "dependency_string": "foo:bar:1.2.3" + "dependency": "foo:bar:1.2.3" } ] """.stripIndent().trim() @@ -74,7 +74,7 @@ final class JsonReportSpec extends Specification { def developers = [developer, developer] def license = new License(name: "name", url: "url") def project = new Project(name: "name", description: "description", version: "1.0.0", - licenses: [license], url: "url", developers: developers, year: "year", dependencyString: "foo:bar:1.2.3") + licenses: [license], url: "url", developers: developers, year: "year", gav: "foo:bar:1.2.3") def projects = [project, project] def sut = new JsonReport(projects) @@ -99,7 +99,7 @@ final class JsonReportSpec extends Specification { "license_url": "url" } ], - "dependency_string": "foo:bar:1.2.3" + "dependency": "foo:bar:1.2.3" }, { "project": "name", @@ -117,7 +117,7 @@ final class JsonReportSpec extends Specification { "license_url": "url" } ], - "dependency_string": "foo:bar:1.2.3" + "dependency": "foo:bar:1.2.3" } ] """.stripIndent().trim() From bd97a21e577792e60b5660a0feed4dd35ccd386a Mon Sep 17 00:00:00 2001 From: Mark Houghton Date: Wed, 13 Jun 2018 10:13:45 +0100 Subject: [PATCH 5/7] Updated readme.md with example HTML and JSON output for a library with no license information available. --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a5a50e2..401c224f 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Example `build.gradle`: dependencies { compile "com.android.support:design:26.1.0" compile "pl.droidsonroids.gif:android-gif-drawable:1.2.3" + compile "wsdl4j:wsdl4j:1.5.1" // Very old library with no license info available } ``` @@ -74,6 +75,10 @@ dependencies {

    Notice for packages:

      +
    • + WSDL4J +
    • +
      No license found
    • Android GIF Drawable Library
    • @@ -106,7 +111,8 @@ dependencies { "license": "The MIT License", "license_url": "http://opensource.org/licenses/MIT" } - ] + ], + "dependency": "pl.droidsonroids.gif:android-gif-drawable:1.2.3" }, { "project": "Design", @@ -122,11 +128,28 @@ dependencies { "license": "The Apache Software License", "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt" } - ] + ], + "dependency": "com.android.support:design:26.1.0" + }, + { + "project": "WSDL4J", + "description": "Java stub generator for WSDL", + "version": "1.5.1", + "developers": [ + + ], + "url": "http://sf.net/projects/wsdl4j", + "year": null, + "licenses": [ + + ], + "dependency": "wsdl4j:wsdl4j:1.5.1" } ] ``` +Note, if no license information is found for a component, the `licenses` element in the JSON output will be an empty array. + ## Configuration The plugin can be configured to generate specific reports and automatically copy the reports to the assets directory (Android projects only). The default behaviours are: - Java projects: Generate both the HTML report and the JSON report. From d2cb6a79a411d26cab7d179c55a2dda0cfa442cb Mon Sep 17 00:00:00 2001 From: Mark Houghton Date: Wed, 13 Jun 2018 10:16:24 +0100 Subject: [PATCH 6/7] Fix indent. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 401c224f..dca2211d 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ dependencies {

      Notice for packages:

        -
      • +
      • WSDL4J
      • No license found
        From 866d401bb93fcc1ed08bb021a91a7767898caa22 Mon Sep 17 00:00:00 2001 From: Mark Houghton Date: Thu, 14 Jun 2018 12:09:20 +0100 Subject: [PATCH 7/7] Fixed indentation again. --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index dca2211d..ae16368d 100644 --- a/README.md +++ b/README.md @@ -132,18 +132,18 @@ dependencies { "dependency": "com.android.support:design:26.1.0" }, { - "project": "WSDL4J", - "description": "Java stub generator for WSDL", - "version": "1.5.1", - "developers": [ + "project": "WSDL4J", + "description": "Java stub generator for WSDL", + "version": "1.5.1", + "developers": [ - ], - "url": "http://sf.net/projects/wsdl4j", - "year": null, - "licenses": [ + ], + "url": "http://sf.net/projects/wsdl4j", + "year": null, + "licenses": [ - ], - "dependency": "wsdl4j:wsdl4j:1.5.1" + ], + "dependency": "wsdl4j:wsdl4j:1.5.1" } ] ```