diff --git a/build-logic/regtest/build.gradle b/build-logic/regtest/build.gradle new file mode 100644 index 0000000000..8b2d374544 --- /dev/null +++ b/build-logic/regtest/build.gradle @@ -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' + } + } +} diff --git a/build-logic/regtest/src/main/kotlin/bisq/gradle/regtest_plugin/RegtestPlugin.kt b/build-logic/regtest/src/main/kotlin/bisq/gradle/regtest_plugin/RegtestPlugin.kt new file mode 100644 index 0000000000..aee73ee32c --- /dev/null +++ b/build-logic/regtest/src/main/kotlin/bisq/gradle/regtest_plugin/RegtestPlugin.kt @@ -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 { + + override fun apply(project: Project) { + val startBitcoindTask = project.tasks.register("startBitcoindRegtest") { + dataDirectory.set(project.layout.projectDirectory.dir(".localnet/bitcoind")) + rpcUser.set("bisqdao") + rpcPassword.set("bsq") + blockNotifyArg.set(".localnet/bitcoind/blocknotify %s") + } + } +} diff --git a/build-logic/regtest/src/main/kotlin/bisq/gradle/regtest_plugin/StartBitcoindTask.kt b/build-logic/regtest/src/main/kotlin/bisq/gradle/regtest_plugin/StartBitcoindTask.kt new file mode 100644 index 0000000000..9aedb73fbd --- /dev/null +++ b/build-logic/regtest/src/main/kotlin/bisq/gradle/regtest_plugin/StartBitcoindTask.kt @@ -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 + + @get:Input + abstract val rpcPassword: Property + + @get:Input + abstract val blockNotifyArg: Property + + @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() + } +} diff --git a/build-logic/settings.gradle b/build-logic/settings.gradle index dcdcd20fe2..018bf48510 100644 --- a/build-logic/settings.gradle +++ b/build-logic/settings.gradle @@ -10,4 +10,5 @@ include 'app-start-plugin' include 'commons' include 'gradle-tasks' include 'packaging' +include 'regtest' include 'tor-binary' diff --git a/build.gradle b/build.gradle index d142e1256e..402bb8d244 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,10 @@ buildscript { } } +plugins { + id 'bisq.gradle.regtest_plugin.RegtestPlugin' +} + if (hasProperty('buildScan')) { buildScan { termsOfServiceUrl = 'https://gradle.com/terms-of-service'