diff --git a/.gitignore b/.gitignore index d73e58b..52ec8f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ .gradle .idea build +bisq-pricenode +bisq-pricenode.bat +lib diff --git a/README.md b/README.md index a39ad72..3622f9b 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,27 @@ To run a pricenode, you will need: - JDK 8 if you want to build and run a node locally. - The `tor` binary (e.g. `brew install tor`) if you want to run a hidden service locally. + +## Building source code + +This repo has a dependency on git submodule [bisq](https://github.com/bisq-network/bisq). There are two ways to clone it before it can be compiled: + +``` +# 1) Use the --recursive option in the clone command: +$ git clone --recursive https://github.com/bisq-network/bisq-pricenode.git + +# 2) Do a normal clone, and pull down the bisq repo dependency with two git submodule commands: +$ git clone https://github.com/bisq-network/bisq-pricenode.git +$ cd bisq-pricenode +$ git submodule init +$ git submodule update +``` + +To build: +``` +$ ./gradlew clean build +``` + ## How to deploy for production diff --git a/build.gradle b/build.gradle index f8c6f86..812a6f0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'application' + alias(libs.plugins.osdetector) alias(libs.plugins.springboot) } @@ -10,6 +11,7 @@ repositories { group 'bisq' +apply plugin: 'com.google.osdetector' apply plugin: "org.springframework.boot" apply plugin: 'io.spring.dependency-management' @@ -25,10 +27,6 @@ java { } } -compileJava { - options.release = 11 -} - jar.manifest.attributes( "Implementation-Title": project.name, "Implementation-Version": version @@ -69,6 +67,51 @@ dependencies { testImplementation libs.mockito.core } +assemble { + doLast { + // Copy generated bisq-pricenode scripts to project's root dir. + copy { + from layout.buildDirectory.dir('scripts') + into projectDir + } + // Copy zipped distribution libs to project's top-level lib dir. + copy { + def distFolderName = project.name + '-' + version + def distZipName = buildDir.name + '/distributions/' + distFolderName + '.zip' + from(zipTree(distZipName)) { + include "$distFolderName/lib/**" + eachFile { fcd -> + fcd.relativePath = new RelativePath(true, fcd.relativePath.segments.drop(2)) + } + includeEmptyDirs = false + } + into "${projectDir}/lib" + } + // Edit generated shell script so it expects to be executed in + // the project's root dir as opposed to a 'bin' subdirectory. + if (osdetector.os != 'windows') { + // Delete the windows .bat script, not the *nix script alone. + delete fileTree(dir: projectDir, include: 'bisq-*.bat') + // Reset APP_HOME variable in *nix script. + def nixScriptFile = file("${projectDir}/${project.name}") + def oldAppHome = 'APP_HOME=$( cd "${APP_HOME:-./}.." && pwd -P ) || exit' + def newAppHome = 'APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit' + nixScriptFile.text = nixScriptFile.text.replace(oldAppHome, newAppHome) + } else { + // Delete the *nix script, not the windows .bat script. + delete fileTree(dir: projectDir, include: 'bisq-*', exclude: '*.bat') + // Reset APP_HOME variable in windows .bat script. + def windowsScriptFile = file("${projectDir}/${project.name}.bat") + windowsScriptFile.text = windowsScriptFile.text.replace('set APP_HOME=%DIRNAME%..', 'set APP_HOME=%DIRNAME%') + } + } +} + +clean.doFirst { + // Remove the project root level 'bisq-*' scripts and 'lib' dir generated at the end of the assemble task. + delete fileTree(dir: projectDir, include: 'bisq-*'), 'lib' +} + test { useJUnitPlatform() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e77a184..4be6eb5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,6 +10,7 @@ knowm-xchange-lib = { strictly = '5.0.13' } logback-lib = { strictly = '1.2.6' } lombok-lib = { strictly = '1.18.22' } mockito-lib = { strictly = '4.0.0' } +osdetector-plugin-lib = { strictly = '1.7.0' } slf4j-lib = { strictly = '1.7.36' } spring-dependency-management-plugin-lib = { strictly = '1.0.12.RELEASE' } spring-plugin-lib = { strictly = '2.5.6' } @@ -61,5 +62,6 @@ knowm-xchange-libs = [ ] [plugins] +osdetector = { id = 'com.google.osdetector', version.ref = 'osdetector-plugin-lib' } springboot = { id = 'org.springframework.boot', version.ref = 'spring-plugin-lib' } springdependency = { id = 'io.spring.dependency-management', version.ref = 'spring-dependency-management-plugin-lib' } \ No newline at end of file