diff --git a/README.md b/README.md
index 1a5a50e2..ae16368d 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:
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.
diff --git a/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy b/src/main/groovy/com/jaredsburrows/license/LicenseReportTask.groovy
index 63f0bbd5..b3d3d28b 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,
+ 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 4ff1ba30..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,4 +8,5 @@ final class Project {
String url
List developers
String year
+ 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 1642f9d3..74b0bf0b 100644
--- a/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy
+++ b/src/main/groovy/com/jaredsburrows/license/internal/report/HtmlReport.groovy
@@ -11,7 +11,9 @@ 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 static def NO_URL = "N/A"
final List projects
HtmlReport(def projects) {
@@ -35,7 +37,12 @@ final class HtmlReport {
// Store packages by license
projects.each { project ->
- def key = project.licenses[0]
+ def key = new License(name: NO_LICENSE, url: NO_URL)
+
+ if (project.licenses && project.licenses.size > 0) {
+ key = project.licenses[0]
+ }
+
if (!projectsMap.containsKey(key)) {
projectsMap.put(key, [])
}
@@ -73,7 +80,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 || 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 +92,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..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,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 = "dependency"
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" : project.gav
]
})
}
diff --git a/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy b/src/test/groovy/com/jaredsburrows/license/LicenseReportTaskAndroidSpec.groovy
index cd028bd0..6f6d6290 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:
+ No license found
+