license-gradle-plugin
license-gradle-plugin copied to clipboard
licenseTest fails if no HEADER set, default HEADER file does not exist, and ignoreFailures=true
First, great plugin! Thanks for all the effort and hard work.
Second, while we may eventually utilize the primary purpose of this plugin (apply licenses as headers to source files), we're most interested in the dependency and license management (via the downloadLicenses task).
We tried configuring the license plugin as follows:
license {
exclude "**/*"
skipExistingHeaders true
ignoreFailures true
}
Unfortunately, our gradle build
fails because licenseTest
task tries to use the default header
value (LICENSE) but that file does not exist:
:code:configs:licenseTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':code:configs:licenseTest'.
> File '/code/configs/LICENSE' specified for property 'header' does not exist.
The error is valid...we do NOT have a LICENSE file in /code/configs
. But we assumed that excluding everything (exclude "*/") OR setting ignoreFailures=true
, the licenseTest task would continue.
We were able to workaround this issue, by creating an empty LICENSE file at the root location and setting the header property:
license {
header rootProject.file('LICENSE')
exclude "**/*"
skipExistingHeaders true
ignoreFailures true
}
However, we also contemplated configuring our gradle to always skip the licenseMain, licenseTest, etc. tasks.
So:
- Should 'ignoreFailures' ignore all failures, including HEADER file not existing
- If not, how would you suggest getting past the licenseTest task:
- Set a dummy
header
property like we did above OR - Configuring gradle to always ignore/exclude
licenseTest
andlicenseMain
tasks since we are mainly interested in downloadLicenses task.
Thanks!
Actually I think the correct one would be the last option you suggest. Disabling the licenseTest
and licenseMain
tasks.
Ignoring the non-existing HEADER file would actually potentially trip up people when they by accident configure it wrongly, or when they do not have access to the URI specified by the headerURI
property.
Setting a dummy would work, but I think the clearest at the moment would be to exclude the tasks.
I could also introduce some more flags such as checkLicenseHeaders
and/or downloadLicenses
that would tweak which tasks are active?
@hierynomus Whatever is the easiest/simplest option to implement that would allow us to disable licenseChecking would work for us.
Since we currently don't use licenseTest
and licenseMain
, having an option to completely "disable" them may also speed up our gradle tasks.
Thanks for this plugin!
I am having the same issue and would love to be able to not have the license tasks get created.
This is a great plugin!
As the others, I mostly use the downloadLicenses
task, so an option to disable other tasks would be greatly appreciated.
I think things go wrong already when this plugin hooks into the regular build. Wouldn't it be better to just offer the tasks, and then let users hook them into their Gradle builds as they see fit?
Doing the other way around is much more awkward. I could not find a way to disable these tasks in a multi-project gradle build where the plugin is applied for all sub-projects.
I think that's a matter of taste. If you apply the Java plugin, you don't expect you're needing to wire up all the compile/resources/test tasks yourself. Same holds here. I think however the plugin should be split in two, one the license-enforcing/formatting
plugin, and a license-reporting
plugin. This would allow you to choose which one of the two you want.
basic gladle solution:
licenseMain.onlyIf { rootProject.file('LICENSE ').exists() }
This worked for me:
gradle.startParameter.excludedTaskNames += "licenseMain"
gradle.startParameter.excludedTaskNames += "licenseTest"
But I think these task should not be activated just by adding this plugin.
For all the changes mentioned above, where should they be applied? In the Build.Gradle file? Some where else?
Is there still no workaround other than to explicitly exclude the above tasks?
Looks like the plugin was split in two a couple of years back (https://github.com/hierynomus/license-gradle-plugin/commit/6ca08d50a2f797a7d29ef3518fc05c116f8a2832) albeit within the same repository, and therefore with the same plugin id. This means you can now opt out of applying the LicenseBasePlugin
and just use the LicenseReportingPlugin
using the following build.gradle
snippet:
plugins {
id "com.github.hierynomus.license" version "0.15.0" apply false
}
// com.github.hierynomus.license contains 2 plugins, we just want this one applied:
apply plugin: com.hierynomus.gradle.license.LicenseReportingPlugin
Still seems pretty ugly to me - would much prefer two separately identified plugins - but it appears to do the job.
Thanks for this information.