Skip to content

Commit

Permalink
Merge pull request #1084 from alvasw/gradle_make_signature_verificati…
Browse files Browse the repository at this point in the history
…on_task_cachable

build-logic: Make SignatureVerificationTask cachable
  • Loading branch information
alvasw authored Aug 2, 2023
2 parents bbc0924 + 54e2a91 commit 1bb1448
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import java.net.URL
abstract class SignatureVerificationTask : DefaultTask() {

@get:InputFile
abstract val fileToVerify: Property<Provider<RegularFile>>
abstract val fileToVerify: RegularFileProperty

@get:InputFile
abstract val detachedSignatureFile: Property<Provider<RegularFile>>
abstract val detachedSignatureFile: RegularFileProperty

@get:Input
abstract val pgpFingerprintToKeyUrl: MapProperty<String, URL>
Expand All @@ -31,15 +31,15 @@ abstract class SignatureVerificationTask : DefaultTask() {
fun verify() {
val signatureVerifier = SignatureVerifier(pgpFingerprintToKeyUrl.get())
val isSignatureValid = signatureVerifier.verifySignature(
signatureFile = detachedSignatureFile.get().get().asFile,
fileToVerify = fileToVerify.get().get().asFile
signatureFile = detachedSignatureFile.get().asFile,
fileToVerify = fileToVerify.get().asFile
)

resultFile.get().asFile.writeText("$isSignatureValid")

if (!isSignatureValid) {
throw GradleException(
"Signature verification failed for ${fileToVerify.get().get().asFile.absolutePath}."
"Signature verification failed for ${fileToVerify.get().asFile.absolutePath}."
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import bisq.gradle.tasks.download.SignedBinaryDownloader
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.RegularFile
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.create
Expand Down Expand Up @@ -34,8 +35,7 @@ class BisqTorBinaryPlugin : Plugin<Project> {
)
torBinaryDownloader.registerTasks()

val binaryTarFile: Provider<Property<Provider<RegularFile>>> =
torBinaryDownloader.verifySignatureTask.map { it.fileToVerify }
val binaryTarFile: Provider<RegularFile> = torBinaryDownloader.verifySignatureTask.flatMap { it.fileToVerify }
val torBinaryPackager = TorBinaryPackager(project)
torBinaryPackager.registerTasks(binaryTarFile)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class TorBinaryPackager(private val project: Project) {
private const val PROCESSED_DIR = "${BisqTorBinaryPlugin.DOWNLOADS_DIR}/processed"
}

fun registerTasks(tarFile: Provider<Property<Provider<RegularFile>>>) {
fun registerTasks(tarFile: Provider<RegularFile>) {
val unpackTarTask: TaskProvider<Copy> = project.tasks.register<Copy>("unpackTorBinaryTar") {
from(
tarFile.map {
project.tarTree(it.get().get().asFile.absolutePath)
project.tarTree(it.asFile.absolutePath)
}
)

Expand Down

0 comments on commit 1bb1448

Please sign in to comment.