From e4e65e75c8b36bc4e656e6f3997887cac191ee2a Mon Sep 17 00:00:00 2001 From: Tamara Cook <10754072+tamaracha@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:39:16 +0200 Subject: [PATCH] Improvement: Make Jextract tasks cacheable --- CHANGELOG.md | 2 +- .../de/infolektuell/gradle/jextract/tasks/DumpIncludesTask.kt | 3 +++ .../gradle/jextract/tasks/GenerateBindingsTask.kt | 4 ++++ .../kotlin/de/infolektuell/gradle/jextract/tasks/Generator.kt | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5356a8b..1d04d9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Create changelog file for release notes - The source set the generated sources are added to is now user-selectable via extension property, `main` is chosen by default. -- DownloadTask became cacheable, so the downloaded Jextract archives can be shared and re-used via build cache. +- Tasks became cacheable, so the downloaded Jextract archives and generated sources can be shared and re-used via build cache. ### Fixed diff --git a/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/DumpIncludesTask.kt b/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/DumpIncludesTask.kt index 8ad18b2..f5af5f7 100644 --- a/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/DumpIncludesTask.kt +++ b/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/DumpIncludesTask.kt @@ -13,11 +13,14 @@ import org.gradle.workers.WorkParameters import org.gradle.workers.WorkerExecutor import javax.inject.Inject +@CacheableTask abstract class DumpIncludesTask @Inject constructor(private val workerExecutor: WorkerExecutor) : DefaultTask() { interface LibraryConfig { @get:InputFile + @get:PathSensitive(PathSensitivity.RELATIVE) val header: RegularFileProperty @get:InputFiles + @get:PathSensitive(PathSensitivity.RELATIVE) val includes: ListProperty @get:OutputFile val argFile: RegularFileProperty diff --git a/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/GenerateBindingsTask.kt b/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/GenerateBindingsTask.kt index 9c3d883..dc0a692 100644 --- a/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/GenerateBindingsTask.kt +++ b/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/GenerateBindingsTask.kt @@ -16,11 +16,14 @@ import org.gradle.workers.WorkParameters import org.gradle.workers.WorkerExecutor import javax.inject.Inject +@CacheableTask abstract class GenerateBindingsTask @Inject constructor(private val workerExecutor: WorkerExecutor) : DefaultTask() { interface LibraryConfig { @get:InputFile + @get:PathSensitive(PathSensitivity.RELATIVE) val header: RegularFileProperty @get:InputFiles + @get:PathSensitive(PathSensitivity.RELATIVE) val includes: ListProperty @get:Input val definedMacros: ListProperty @@ -34,6 +37,7 @@ abstract class GenerateBindingsTask @Inject constructor(private val workerExecut val whitelist: MapProperty> @get:Optional @get:InputFile + @get:PathSensitive(PathSensitivity.RELATIVE) val argFile: RegularFileProperty @get:Input val libraries: ListProperty diff --git a/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/Generator.kt b/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/Generator.kt index 8babd53..4bc035d 100644 --- a/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/Generator.kt +++ b/plugin/src/main/kotlin/de/infolektuell/gradle/jextract/tasks/Generator.kt @@ -6,11 +6,14 @@ import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Provider import org.gradle.api.tasks.InputDirectory import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform import javax.inject.Inject abstract class Generator @Inject constructor(objects: ObjectFactory) { @get:InputDirectory + @get:PathSensitive(PathSensitivity.RELATIVE) val location: DirectoryProperty = objects.directoryProperty() @get:Internal val executable: Provider = location.map { g ->