Skip to content

Added support for specifying closures as renderers for the HTML "dependency to license" report of "downloadLicenses"#37

Open
marcotrevisan wants to merge 4 commits intohierynomus:masterfrom
marcotrevisan:master
Open

Added support for specifying closures as renderers for the HTML "dependency to license" report of "downloadLicenses"#37
marcotrevisan wants to merge 4 commits intohierynomus:masterfrom
marcotrevisan:master

Conversation

@marcotrevisan
Copy link
Copy Markdown

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.

Marco Trevisan added 3 commits March 13, 2014 18:05
custom renderer closures for dependency to license reports.
variable "dependenciesToIgnore" and has no input parameters.

NEW: Added the isIgnored(String dependency) method to isolate the logic
that evaluates the "ignored" status. Now also groups are looked up.

NEW: DependencyMetadata, populated the new "pomXml" property that
carries all the POM information.
POM information.

NEW: Usage of the renderer closures to render the "Dependency to
license" HTML report.
@buildhive
Copy link
Copy Markdown

Jeroen van Erp » license-gradle-plugin #20 FAILURE
Looks like there's a problem with this pull request
(what's this?)

@marcotrevisan
Copy link
Copy Markdown
Author

Looks like I've broken some unit tests. Sorry.
Also, please note that I tested the plugin under Gradle 1.10

Cheers,
Marco

@buildhive
Copy link
Copy Markdown

Jeroen van Erp » license-gradle-plugin #21 FAILURE
Looks like there's a problem with this pull request
(what's this?)

@marcotrevisan
Copy link
Copy Markdown
Author

The latest build failed due to a timeout in cloning the git repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants