Skip to content

Commit

Permalink
Addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoreliovlabs committed Sep 6, 2024
1 parent 46c3fec commit 50e8d7e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions rskj-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ spotless {
indentWithTabs(2)
indentWithSpaces(4)
target filteredFiles

}
}


def getFilteredFiles() {
def timestamp = ext.timestamp

Expand Down Expand Up @@ -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 }

Expand All @@ -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()
Expand All @@ -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,
Expand All @@ -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':
Expand All @@ -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 {
Expand Down Expand Up @@ -537,4 +542,6 @@ static def amendPathIfNeeded(details) {
tasks.named('check').configure {
dependsOn 'checkstyleMain'
dependsOn 'checkstyleTest'
dependsOn 'checkstyleJmh'
dependsOn 'checkstyleIntegrationTest'
}

0 comments on commit 50e8d7e

Please sign in to comment.