hierynomus/license-gradle-plugin — pull request #37 by marcotrevisan (2014-03-13 17:22:57+00:00)
Title: Added support for specifying closures as renderers for the HTML "dependency to license" report of "downloadLicenses"

Hi all,

I added support for specifying closures as renderers for the HTML "dependency to license" report of "downloadLicenses".
Other useful changes are:
- DependencyMetadata now carries the complete POM information, useful in the custom renderers.
- The report is now sorted in alphabetical order.

With the new patch, users can specify something like the following:
```
downloadLicenses {
....
report.html.dependencyToLicenseTableHeadRenderer = { table ->
table.tr {
th(){ h3("Dependency") }
th(){ h3("Dependency artifact id") }
th(){ h3("Dependency version") }
th(){ h3("Jar") }
th(){ h3("Dependency Url") }
th(){ h3("License name") }
th(){ h3("License text URL") }
}
}

report.html.dependencyToLicenseTableRowRenderer = { table, depMetadata, license ->
table.tr {
String[] gav = depMetadata.dependency.split(':')
td(depMetadata.dependency, class: 'dependencies')
td(gav[1], class: 'dependencies')
td(gav[2], class: 'dependencies')
td(depMetadata.dependencyFileName, class: 'licenseName')
if(depMetadata.url){
td(class: 'url') {
a(href: depMetadata.url, depMetadata.url)
}
} else {
td('no url available', class:'url')
}
td(license.licenseName, class: 'licenseName')
td(class: 'license') {
if (license.licenseTextUrl) {
a(href: license.licenseTextUrl, license.licenseTextUrl)
}
}
}
}

}
```
The code works successfully.

I wasn't able to set the closures as "@Input" parameters of the task due to the fact that gradle then executes them with no arguments as a result of an "unwrap" phase at setup time, leading to the following exception:

```
groovy.lang.MissingMethodException: No signature of method: nl.javadude.gradle.plugins.license.LicenseReporter$__clinit__closure8.doCall() is applicable for argument types: () values: []
Possible solutions: doCall(java.lang.Object, java.lang.Object, java.lang.Object), isCase(java.lang.Object), isCase(java.lang.Object), findAll(), findAll(), findAll(groovy.lang.Closure)
at org.gradle.api.internal.tasks.DefaultTaskInputs.unwrap(DefaultTaskInputs.java:111)
...
```
Maybe you know how to correctly set them as input parameters.