From 50e8d7e1dae43c1938ceb1f0547bdabf60a65bc8 Mon Sep 17 00:00:00 2001 From: Reynold Morel Date: Fri, 6 Sep 2024 16:05:32 -0400 Subject: [PATCH] Addressing comments --- rskj-core/build.gradle | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/rskj-core/build.gradle b/rskj-core/build.gradle index b64d68f223b..0398a56048b 100644 --- a/rskj-core/build.gradle +++ b/rskj-core/build.gradle @@ -26,11 +26,9 @@ spotless { indentWithTabs(2) indentWithSpaces(4) target filteredFiles - } } - def getFilteredFiles() { def timestamp = ext.timestamp @@ -72,7 +70,6 @@ def getFilteredFiles() { def committedFiles = outputLog.toString().trim().split('\n').toList().unique() def uncommittedFiles = outputDiff.toString().trim().split('\n').toList().unique() def stagedFiles = outputStaged.toString().trim().split('\n').toList().unique() - def allFiles = committedFiles + uncommittedFiles + stagedFiles allFiles = allFiles.unique().findAll { file -> file } @@ -83,7 +80,6 @@ def getFilteredFiles() { return allFiles.collect { file -> Paths.get(file).toAbsolutePath().toFile() } } -// Method to configure Checkstyle tasks def configureCheckstyleTask(Checkstyle task, File sourceDir) { def sourceDirPath = sourceDir.toPath().normalize() def files = getFilteredFiles() @@ -92,7 +88,6 @@ def configureCheckstyleTask(Checkstyle task, File sourceDir) { def isUnderSourceDir = filePath.startsWith(sourceDirPath) && !filePath.equals(sourceDirPath) isUnderSourceDir } - task.source = project.files(filteredFilesCheckstyle) task.classpath = project.files( sourceSets.main.output.classesDirs, @@ -102,9 +97,12 @@ def configureCheckstyleTask(Checkstyle task, File sourceDir) { xml.required.set(true) html.required.set(true) } + task.onlyIf { + !filteredFilesCheckstyle.isEmpty() + } } -// Configure each Checkstyle task explicitly +// Configure each Checkstyle task tasks.withType(Checkstyle).configureEach { Checkstyle task -> switch (task.name) { case 'checkstyleMain': @@ -120,6 +118,13 @@ tasks.withType(Checkstyle).configureEach { Checkstyle task -> configureCheckstyleTask(task, file('src/jmh/java')) break } + if (task.name == 'checkstyleJmh' || task.name == 'checkstyleIntegrationTest') { + task.doFirst { + if(!getFilteredFiles().isEmpty()) { + task.source = project.files(getFilteredFiles()) + } + } + } } configurations { @@ -537,4 +542,6 @@ static def amendPathIfNeeded(details) { tasks.named('check').configure { dependsOn 'checkstyleMain' dependsOn 'checkstyleTest' + dependsOn 'checkstyleJmh' + dependsOn 'checkstyleIntegrationTest' }