I’m trying to configure the Hierynomus Gradle License Plugin in my build.gradle.kts file, but I keep encountering the error:
A problem was found with the configuration of task ':licenseMain' (type 'LicenseCheck').
- In plugin 'com.hierynomus.gradle.license.LicenseBasePlugin' type 'com.hierynomus.gradle.license.tasks.LicenseCheck' property 'header' specifies file 'F:\Kod\Java\Plugin\mFly\LICENSE' which doesn't exist.`
It seems like the plugin isn’t saving or applying the header
variable correctly, and it expects a file that doesn’t exist. Here’s my build.gradle.kts
file:
import nl.javadude.gradle.plugins.license.LicenseExtension
plugins {
id("java")
id("com.github.hierynomus.license") version "0.16.1"
}
defaultTasks("licenseFormat", "build")
subprojects {
apply(plugin = "java")
apply(plugin = "com.github.hierynomus.license")
group = "me.makalidap.mfly"
version = "0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
tasks {
withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
jar {
from("${project.rootDir}/LICENSE.txt")
}
}
configure<LicenseExtension> {
header = file("${project.rootDir}\\HEADER.txt")
}
repositories {
mavenCentral()
}
}
I’ve also tried these alternatives, but they did not solve the issue:
license {
header = file("${project.rootDir}\\HEADER.txt")
}
header = rootProject.file("HEADER.txt")
I printed out paths to ensure correctness, and I’ve tried running the build with both Java 8 and Java 17, but the issue persists.
Here’s the full error message:
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':licenseMain' (type 'LicenseCheck').
- In plugin 'com.hierynomus.gradle.license.LicenseBasePlugin' type 'com.hierynomus.gradle.license.tasks.LicenseCheck' property 'header' specifies file 'F:\Kod\Java\Plugin\mFly\LICENSE' which doesn't exist.
Reason: An input file was expected to be present but it doesn't exist.
Possible solutions:
1. Make sure the file exists before the task is called.
2. Make sure that the task which produces the file is declared as an input.
I’m using Gradle 8.8. Any suggestions on what could be going wrong?
I’m not particularly attached to this plugin, so if you have recommendations for alternative plugins that handle license checks, I would be happy to try them!