Ahmed Riyadh
05/16/2024, 2:44 PMplugins
block, to configure it in Gradle groovy you simply have to use:
license {
header = project.file('LICENSEHEADER')
}
So I used this in Gradle Kotlin DSL:
configure<org.cadixdev.gradle.licenser.LicenseExtension> {
setHeader(project.file("LICENSEHEADER"))
}
since I'm applying the plugin using the plugins
block then should use this instead:
license {
setHeader(project.file("LICENSEHEADER"))
}
As an alternative, but the problem is the configurations doesn't seems to be applied in the Gradle Kotlin DSL one because when running the task that use those configurations (./gradlew licenseCheck
) it will always success even if there was a file that doesn't append the LICENSE at the start of the file, this wasn't in issue in Gradle Groovy code, any ideas or is it a issue from the plugin side?Vampire
05/16/2024, 2:53 PMplugins { ... }
block (and there are only very few and seldom cases where you cannot) why do you need to use configure
?Ahmed Riyadh
05/16/2024, 2:54 PMVampire
05/16/2024, 2:55 PMHEADER.txt
while in the Kotlin version you use LICENSEHEADER
?Ahmed Riyadh
05/16/2024, 2:56 PMVampire
05/16/2024, 2:56 PMVampire
05/16/2024, 3:01 PMlicense {
setHeader(project.file("LICENSEHEADER"))
}
or
license {
header(project.file("LICENSEHEADER"))
}
in Kotlin DSL should behave like
license {
header = project.file('LICENSEHEADER')
}
in Groovy DSLVampire
05/16/2024, 3:01 PMAhmed Riyadh
05/16/2024, 3:03 PMAhmed Riyadh
05/16/2024, 3:08 PMinclude("'**/*.java'")
exclude("io/github/**/*.java")
exclude("net/minecraft/**/*.java")
exclude("com/atlauncher/graphql/**/*.java")
exclude("com/atlauncher/gui/layouts/WrapLayout.java")
newLine = false
ext.set("year", currentYear())
And after removing them and make it minimal it worked (it throw an error), but I'm not sure why this is needed, on Gradle groovy that's wasn't needed, I'm pretty sure they added those configurations for a reason, because I'm getting on multiple errors for different files instead of the newly created one that doesn't have the License Header in the start of the file, so it's a configuration issue and the plugin work just like expected but I'm not sure why their configurations work like expected only on Gradle Groovy code, I update the syntax and didn't touch anything else
The old Groovy code:
license {
header = project.file('LICENSEHEADER')
include '**/*.java'
exclude 'io/github/**/*.java'
exclude 'net/minecraft/**/*.java'
exclude 'com/atlauncher/graphql/**/*.java'
exclude 'com/atlauncher/gui/layouts/WrapLayout.java'
newLine = false
properties {
year = currentYear()
}
}
It could be the issue with the properties, so it's an issue from my side or the project side, not really from the plugin.
I couldn't find the alternative of
properties {
year = currentYear()
}
in Gradle Kotlin DSLAhmed Riyadh
05/16/2024, 3:13 PMinclude("**/*.java")
still not sure on how how set the year property in the propeties
block as the year
doesn't exist when using Gradle Kotlin DSLVampire
05/16/2024, 3:17 PMproperties {
set("year", currentYear())
}
Ahmed Riyadh
05/16/2024, 3:19 PM