Skip to content

Commit

Permalink
Merge pull request #5 from ghubstan/make-runnable-from-root-dir
Browse files Browse the repository at this point in the history
Make runnable from root dir
  • Loading branch information
bisq-github-admin-3 authored Jul 13, 2022
2 parents 456db4c + 1e51bae commit bbb2c4c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.gradle
.idea
build
bisq-pricenode
bisq-pricenode.bat
lib

21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
51 changes: 47 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'application'
alias(libs.plugins.osdetector)
alias(libs.plugins.springboot)
}

Expand All @@ -10,6 +11,7 @@ repositories {

group 'bisq'

apply plugin: 'com.google.osdetector'
apply plugin: "org.springframework.boot"
apply plugin: 'io.spring.dependency-management'

Expand All @@ -25,10 +27,6 @@ java {
}
}

compileJava {
options.release = 11
}

jar.manifest.attributes(
"Implementation-Title": project.name,
"Implementation-Version": version
Expand Down Expand Up @@ -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()
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down Expand Up @@ -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' }

0 comments on commit bbb2c4c

Please sign in to comment.