Skip to content

Commit

Permalink
Allow cache relocatability for Delombok task
Browse files Browse the repository at this point in the history
  • Loading branch information
jprinet committed Mar 29, 2022
1 parent bbf6d15 commit e7000d7
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ plugins {

apply from: "$rootDir/gradle/ci-support.gradle"

/**
* Allows build cache relocatability for Delombok task
*/
class DelombokArgumentProvider implements CommandLineArgumentProvider {

@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
Set<File> srcDirs

@Internal
File outputDir

@Override
Iterable<String> asArguments() {
return [srcDirs.collect { it.absolutePath }.join(" "), "-d", outputDir.absolutePath, "-f", "generateDelombokComment:skip"]
}
}

subprojects {
apply plugin: 'java-library'
apply plugin: 'idea'
Expand All @@ -43,18 +61,22 @@ subprojects {
version = '1.18.20'
}


task delombok(type: io.franzbecker.gradle.lombok.task.DelombokTask) {
def outputDir = file("$buildDir/delombok")
outputs.dir(outputDir)
outputs.cacheIf {
true
}
def i = 1
for (srcDir in project.sourceSets.main.java.srcDirs) {
// TODO: named input and relative path for `srcDir` to make task more cacheable
inputs.dir(srcDir)
// TODO: `outputDir` as relative path to make task more cacheable
args(srcDir, "-d", outputDir, "-f", "generateDelombokComment:skip")
.withPropertyName("srcDir${i++}")
.withPathSensitivity(PathSensitivity.RELATIVE)
}
argumentProviders.addAll(
new DelombokArgumentProvider(srcDirs: project.sourceSets.main.java.srcDirs, outputDir: outputDir)
)
}
delombok.onlyIf {
project.sourceSets.main.java.srcDirs.find { it.exists() }
Expand Down

0 comments on commit e7000d7

Please sign in to comment.