Implement startBitcoindRegtest Gradle Task

This commit is contained in:
Alva Swanson 2023-09-11 16:55:11 +02:00
parent 45c4d16a0c
commit 4575d2a229
No known key found for this signature in database
GPG Key ID: 004760E77F753090
5 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,17 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
id 'org.gradle.kotlin.kotlin-dsl' version '2.4.1'
}
repositories {
mavenCentral()
}
gradlePlugin {
plugins {
simplePlugin {
id = 'bisq.gradle.regtest_plugin.RegtestPlugin'
implementationClass = 'bisq.gradle.regtest_plugin.RegtestPlugin'
}
}
}

View File

@ -0,0 +1,17 @@
package bisq.gradle.regtest_plugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.register
class RegtestPlugin : Plugin<Project> {
override fun apply(project: Project) {
val startBitcoindTask = project.tasks.register<StartBitcoindTask>("startBitcoindRegtest") {
dataDirectory.set(project.layout.projectDirectory.dir(".localnet/bitcoind"))
rpcUser.set("bisqdao")
rpcPassword.set("bsq")
blockNotifyArg.set(".localnet/bitcoind/blocknotify %s")
}
}
}

View File

@ -0,0 +1,47 @@
package bisq.gradle.regtest_plugin
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.TaskAction
abstract class StartBitcoindTask : DefaultTask() {
@get:InputDirectory
abstract val dataDirectory: DirectoryProperty
@get:Input
abstract val rpcUser: Property<String>
@get:Input
abstract val rpcPassword: Property<String>
@get:Input
abstract val blockNotifyArg: Property<String>
@TaskAction
fun run() {
val processBuilder = ProcessBuilder(
"bitcoind",
"-datadir=${dataDirectory.asFile.get().absolutePath}",
"-regtest",
"-prune=0",
"-txindex=1",
"-peerbloomfilters=1",
"-server",
"-rpcuser=${rpcUser.get()}",
"-rpcpassword=${rpcPassword.get()}",
"-blocknotify= ${blockNotifyArg.get()}"
)
processBuilder.redirectErrorStream(true)
processBuilder.redirectOutput(ProcessBuilder.Redirect.DISCARD)
processBuilder.start()
}
}

View File

@ -10,4 +10,5 @@ include 'app-start-plugin'
include 'commons'
include 'gradle-tasks'
include 'packaging'
include 'regtest'
include 'tor-binary'

View File

@ -6,6 +6,10 @@ buildscript {
}
}
plugins {
id 'bisq.gradle.regtest_plugin.RegtestPlugin'
}
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'