Fix immutable properties. Fix ant uri namespace no longer working (seems like gradle regression).

This commit is contained in:
Dawid Weiss 2021-08-24 13:13:26 +02:00
parent 2b0378cd4a
commit 26eb84a3b5
1 changed files with 4 additions and 6 deletions

View File

@ -126,18 +126,16 @@ allprojects {
*/
class RatTask extends DefaultTask {
@InputFiles
ListProperty<ConfigurableFileTree> inputFileTrees = project.objects.listProperty(ConfigurableFileTree)
final ListProperty<ConfigurableFileTree> inputFileTrees = project.objects.listProperty(ConfigurableFileTree)
@OutputFile
RegularFileProperty xmlReport = project.objects.fileProperty().convention(
final RegularFileProperty xmlReport = project.objects.fileProperty().convention(
project.layout.buildDirectory.file("rat/rat-report.xml"))
def generateReport(File reportFile) {
// Set up ant rat task.
def uri = 'antlib:org.apache.rat.anttasks'
def ratClasspath = project.rootProject.configurations.ratDeps.asPath
ant.taskdef(resource: 'org/apache/rat/anttasks/antlib.xml', uri: uri, classpath: ratClasspath)
def rat = NamespaceBuilder.newInstance(ant, uri)
ant.taskdef(resource: 'org/apache/rat/anttasks/antlib.xml', classpath: ratClasspath)
// Collect all output files for debugging.
String inputFileList = inputFileTrees.get().collectMany { fileTree ->
@ -146,7 +144,7 @@ class RatTask extends DefaultTask {
project.file(reportFile.path.replaceAll('.xml$', '-filelist.txt')).setText(inputFileList, "UTF-8")
// Run rat via ant.
rat.report(format: 'xml', reportFile: reportFile, addDefaultLicenseMatchers: true) {
ant.report(format: 'xml', reportFile: reportFile, addDefaultLicenseMatchers: true) {
// Pass all gradle file trees to the ant task (Gradle's internal adapters are used).
inputFileTrees.get().each { fileTree ->
fileTree.addToAntBuilder(ant, 'resources', FileCollection.AntType.ResourceCollection)