From 46399516e343454b9259be0c810d41006d45a5d8 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Sat, 5 Aug 2023 15:13:31 +0200 Subject: [PATCH 1/2] build-logic: Create 'bisq.application' plugin --- .../src/main/groovy/bisq.application.gradle | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 build-logic/commons/src/main/groovy/bisq.application.gradle diff --git a/build-logic/commons/src/main/groovy/bisq.application.gradle b/build-logic/commons/src/main/groovy/bisq.application.gradle new file mode 100644 index 00000000000..232aae91e62 --- /dev/null +++ b/build-logic/commons/src/main/groovy/bisq.application.gradle @@ -0,0 +1,65 @@ +plugins { + id 'bisq.java-conventions' + id 'application' +} + +build.dependsOn installDist +installDist.destinationDir = file('build/app') +distZip.enabled = false +distTar.enabled = false + +// the 'installDist' and 'startScripts' blocks below configure bisq executables to put +// generated shell scripts in the root project directory, such that users can easily +// discover and invoke e.g. ./bisq-desktop, ./bisq-seednode, etc. +// See https://stackoverflow.com/q/46327736 for details. + +installDist { + doLast { + // copy generated shell scripts, e.g. `bisq-desktop` directly to the project + // root directory for discoverability and ease of use + + copy { + from "$destinationDir/bin" + into rootProject.projectDir + } + // copy libs required for generated shell script classpaths to 'lib' dir under + // the project root directory + copy { + from "$destinationDir/lib" + into "${rootProject.projectDir}/lib" + } + + // edit generated shell scripts such that they expect to be executed in the + // project root dir as opposed to a 'bin' subdirectory + def windowsScriptFile = file("${rootProject.projectDir}/bisq-${applicationName}.bat") + windowsScriptFile.text = windowsScriptFile.text.replace( + 'set APP_HOME=%DIRNAME%..', 'set APP_HOME=%DIRNAME%') + + def unixScriptFile = file("${rootProject.projectDir}/bisq-$applicationName") + unixScriptFile.text = unixScriptFile.text.replace( + 'APP_HOME=$( cd "${APP_HOME:-./}.." && pwd -P ) || exit', 'APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit') + + if (applicationName == 'desktop') { + def script = file("${rootProject.projectDir}/bisq-$applicationName") + script.text = script.text.replace( + 'DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="-XX:MaxRAM=8g -Xss1280k -XX:+UseG1GC ' + + '-XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:+UseStringDeduplication ' + + '-Djava.net.preferIPv4Stack=true"') + } + + if (applicationName == 'apitest') { + // Pass the logback config file as a system property to avoid chatty + // logback startup due to multiple logback.xml files in the classpath + // (:daemon & :cli). + def script = file("${rootProject.projectDir}/bisq-$applicationName") + script.text = script.text.replace( + 'DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="' + + '-Dlogback.configurationFile=apitest/build/resources/main/logback.xml"') + } + } +} + +startScripts { + // rename scripts from, e.g. `desktop` to `bisq-desktop` + applicationName = "bisq-$applicationName" +} From 9ce8f837192c93f720e5f72fdb73d82dfb9b92fb Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Sat, 5 Aug 2023 15:14:04 +0200 Subject: [PATCH 2/2] Gradle: Centralize application setup --- apitest/build.gradle | 2 +- build.gradle | 71 ------------------------------------------ cli/build.gradle | 2 +- daemon/build.gradle | 2 +- desktop/build.gradle | 2 +- seednode/build.gradle | 2 +- statsnode/build.gradle | 2 +- 7 files changed, 6 insertions(+), 77 deletions(-) diff --git a/apitest/build.gradle b/apitest/build.gradle index e99e51b4570..6f9c36ea207 100644 --- a/apitest/build.gradle +++ b/apitest/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'bisq.java-conventions' + id 'bisq.application' } mainClassName = 'bisq.apitest.ApiTestMain' diff --git a/build.gradle b/build.gradle index 933f3e2d93c..0eda1badc2c 100644 --- a/build.gradle +++ b/build.gradle @@ -19,77 +19,6 @@ configure(rootProject) { } } -configure([project(':cli'), - project(':daemon'), - project(':desktop'), - project(':seednode'), - project(':statsnode'), - project(':apitest')]) { - - apply plugin: 'application' - - build.dependsOn installDist - installDist.destinationDir = file('build/app') - distZip.enabled = false - distTar.enabled = false - - // the 'installDist' and 'startScripts' blocks below configure bisq executables to put - // generated shell scripts in the root project directory, such that users can easily - // discover and invoke e.g. ./bisq-desktop, ./bisq-seednode, etc. - // See https://stackoverflow.com/q/46327736 for details. - - installDist { - doLast { - // copy generated shell scripts, e.g. `bisq-desktop` directly to the project - // root directory for discoverability and ease of use - - copy { - from "$destinationDir/bin" - into rootProject.projectDir - } - // copy libs required for generated shell script classpaths to 'lib' dir under - // the project root directory - copy { - from "$destinationDir/lib" - into "${rootProject.projectDir}/lib" - } - - // edit generated shell scripts such that they expect to be executed in the - // project root dir as opposed to a 'bin' subdirectory - def windowsScriptFile = file("${rootProject.projectDir}/bisq-${applicationName}.bat") - windowsScriptFile.text = windowsScriptFile.text.replace( - 'set APP_HOME=%DIRNAME%..', 'set APP_HOME=%DIRNAME%') - - def unixScriptFile = file("${rootProject.projectDir}/bisq-$applicationName") - unixScriptFile.text = unixScriptFile.text.replace( - 'APP_HOME=$( cd "${APP_HOME:-./}.." && pwd -P ) || exit', 'APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit') - - if (applicationName == 'desktop') { - def script = file("${rootProject.projectDir}/bisq-$applicationName") - script.text = script.text.replace( - 'DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="-XX:MaxRAM=8g -Xss1280k -XX:+UseG1GC ' + - '-XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:+UseStringDeduplication ' + - '-Djava.net.preferIPv4Stack=true"') - } - - if (applicationName == 'apitest') { - // Pass the logback config file as a system property to avoid chatty - // logback startup due to multiple logback.xml files in the classpath - // (:daemon & :cli). - def script = file("${rootProject.projectDir}/bisq-$applicationName") - script.text = script.text.replace( - 'DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="' + - '-Dlogback.configurationFile=apitest/build/resources/main/logback.xml"') - } - } - } - - startScripts { - // rename scripts from, e.g. `desktop` to `bisq-desktop` - applicationName = "bisq-$applicationName" - } -} - if (hasProperty('buildScan')) { buildScan { termsOfServiceUrl = 'https://gradle.com/terms-of-service' diff --git a/cli/build.gradle b/cli/build.gradle index af5fc38a35a..8d358eb4908 100644 --- a/cli/build.gradle +++ b/cli/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'bisq.java-conventions' + id 'bisq.application' } distTar.enabled = true diff --git a/daemon/build.gradle b/daemon/build.gradle index d26c2f4d300..7606d288ff3 100644 --- a/daemon/build.gradle +++ b/daemon/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'bisq.java-conventions' + id 'bisq.application' } distTar.enabled = true diff --git a/desktop/build.gradle b/desktop/build.gradle index 8996f6e1ae2..10da8398220 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'bisq.java-conventions' + id 'bisq.application' id 'bisq.javafx' } diff --git a/seednode/build.gradle b/seednode/build.gradle index 9027c94dcf1..8d8622b7884 100644 --- a/seednode/build.gradle +++ b/seednode/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'bisq.java-conventions' + id 'bisq.application' } mainClassName = 'bisq.seednode.SeedNodeMain' diff --git a/statsnode/build.gradle b/statsnode/build.gradle index 60f4d99edc1..b593c42b615 100644 --- a/statsnode/build.gradle +++ b/statsnode/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'bisq.java-conventions' + id 'bisq.application' } mainClassName = 'bisq.statistics.StatisticsMain'