Skip to content

Commit

Permalink
Add desktopapp module for Bisq 2 app
Browse files Browse the repository at this point in the history
Convert desktop to library
  • Loading branch information
chimp1984 committed Mar 31, 2022
1 parent 60a015e commit df0ac9f
Show file tree
Hide file tree
Showing 32 changed files with 165 additions and 135 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
# 1) Local clearnet scenario
#
# Launch 2 clearnet seeds and several (n) clearnet desktop clients with:
# Launch 2 clearnet seeds and several (n) clearnet desktopapp clients with:
#
# $ make start-clearnet-full-env n=4
#
Expand All @@ -32,7 +32,7 @@
#
# 2) Local tor scenario
#
# Launches 2 tor seeds and several (n) tor desktop clients. This needs 2 steps:
# Launches 2 tor seeds and several (n) tor desktopapp clients. This needs 2 steps:
#
# First step: have the tor seeds generate their tor addresses with:
#
Expand All @@ -45,7 +45,7 @@
# That line indicates the seed has its tor identity. Once both seed outputs have that line,
# stop both seeds with Ctrl+C.
#
# Second step: start a combination of 2 tor seeds and several (n) tor desktop clients with:
# Second step: start a combination of 2 tor seeds and several (n) tor desktopapp clients with:
#
# $ make start-tor-full-env n=4
#
Expand All @@ -58,7 +58,7 @@
#
# 3) Local I2P scenario
#
# Launches 2 I2P seeds and several (n) I2P desktop clients. This needs 2 steps:
# Launches 2 I2P seeds and several (n) I2P desktopapp clients. This needs 2 steps:
#
# First step: have the I2P seeds generate their private key and destinations with:
#
Expand All @@ -68,7 +68,7 @@
# local I2P console at http://127.0.0.1:7657/home . Once two new green entries appear in
# the I2P console, go to the terminal and stop both seeds with Ctrl+C.
#
# Second step: start a combination of 2 I2P seeds and several (n) I2P desktop clients with:
# Second step: start a combination of 2 I2P seeds and several (n) I2P desktopapp clients with:
#
# $ make start-i2p-full-env n=4
#
Expand Down Expand Up @@ -134,7 +134,7 @@ clean:

.start-clearnet-clients:
for i in $$(seq 1 $n); do \
screen -S localtests -X screen -t client-$${i}-clear ./gradlew --console=plain desktop:run \
screen -S localtests -X screen -t client-$${i}-clear ./gradlew --console=plain desktopapp:run \
-Dbisq.application.appName=bisq_client$${i}_test \
-Dbisq.networkServiceConfig.supportedTransportTypes.0=CLEAR \
-Dbisq.networkServiceConfig.seedAddressByTransportType.clear.0=127.0.0.1:8000 \
Expand Down Expand Up @@ -163,7 +163,7 @@ seed2-tor-hostname:
# If any is not known, this will fail
.start-tor-clients: seed1-tor-hostname seed2-tor-hostname
for i in $$(seq 1 $n); do \
screen -S localtests -X screen -t client-$${i}-tor ./gradlew --console=plain desktop:run \
screen -S localtests -X screen -t client-$${i}-tor ./gradlew --console=plain desktopapp:run \
-Dbisq.application.appName=bisq_client$${i}_tor_test \
-Dbisq.networkServiceConfig.supportedTransportTypes.0=TOR \
-Dbisq.networkServiceConfig.seedAddressByTransportType.tor.0=$(file < seed1-tor-hostname):1000 \
Expand Down Expand Up @@ -239,7 +239,7 @@ seed2-i2p-destination:
# the resulting cmd had to be built line by line ;\
# See .demo-send-large-command-to-screen for details ;\
screen -S localtests -X screen -t client-$${i}-i2p ;\
screen -S localtests -X stuff './gradlew --console=plain desktop:run ' ;\
screen -S localtests -X stuff './gradlew --console=plain desktopapp:run ' ;\
screen -S localtests -X stuff "-Dbisq.application.appName=bisq_client$${i}_i2p_test " ;\
screen -S localtests -X stuff '-Dbisq.networkServiceConfig.supportedTransportTypes.0=I2P ' ;\
screen -S localtests -X stuff '-Dbisq.networkServiceConfig.seedAddressByTransportType.i2p.0=$(file < seed1-i2p-destination):5000 ' ;\
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Bisq 2 requires Java 16 and Gradle 7.3.3.

Currently, you need to start the Desktop app from the IntelliJ IDE and not via gradle as there are some open issues with the JFoenix library we are currently using (might get replaced with Gluon).

You can right-click the `bisq.desktop.Main` class in the desktop module to create a run config or create a `run config` in `Run/Edi Configurations`. You need to add the JVM argument: `--add-opens java.base/java.lang.reflect=ALL-UNNAMED` (due the JFoenix issue with Java 16).
You can right-click the `bisq.desktopapp.Main` class in the desktopapp module to create a run config or create a `run config` in `Run/Edi Configurations`. You need to add the JVM argument: `--add-opens java.base/java.lang.reflect=ALL-UNNAMED` (due the JFoenix issue with Java 16).

The desktop app also requires JVM args (the typesafe config lib we use does not support overriding program args, so you have to use JVM args).
- For clearnet use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object ApplicationRunTaskFactory {
cmdLineArgs: List<String>,
dependentTask: TaskProvider<out DefaultTask>?
) {
val desktopProject: Project = project.project("desktop")
val desktopProject: Project = project.project("desktopapp")
registerRunTaskToProject(
project = desktopProject,
taskName = taskName,
Expand Down
58 changes: 3 additions & 55 deletions desktop/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
plugins {
id 'java-library'
alias(libs.plugins.protobuf)
id 'application'
id 'distribution'
id 'org.openjfx.javafxplugin' version '0.0.10'
}

Expand All @@ -12,44 +9,15 @@ repositories {
}

apply from: '../buildSrc/bisq-version.gradle'

application {
project.mainClassName = 'bisq.desktop.Main'
applicationDefaultJvmArgs = ['--add-exports', 'javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED',
'--add-exports', 'javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED']
}

run {
// Pass command-line properties to application
// Normally they'd only be applied to the gradle process, but we need them in the started application
// See https://stackoverflow.com/a/23689696
systemProperties System.getProperties()
}

distributions {
main {
distributionBaseName = 'jfx-dist'
}
}

tasks.named('jar') {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version,
'Main-Class': 'bisq.desktop.Main')
}
}
apply from: '../buildSrc/logging-dependencies.gradle'
apply from: '../buildSrc/test-dependencies.gradle'
apply from: '../buildSrc/lombok-dependencies.gradle'

javafx {
version = '16'
modules = ['javafx.base', 'javafx.controls', 'javafx.graphics']
}

apply from: '../buildSrc/logging-dependencies.gradle'
apply from: '../buildSrc/test-dependencies.gradle'
apply from: '../buildSrc/lombok-dependencies.gradle'

dependencies {
api platform(project(':platforms:common-platform'))

Expand All @@ -70,7 +38,6 @@ dependencies {
implementation project(':application')
implementation project(':wallets')

implementation 'com.google.protobuf:protobuf-java'
implementation libs.guava

implementation 'com.jfoenix:jfoenix:9.0.10'
Expand All @@ -86,22 +53,3 @@ test {
useJUnitPlatform()
exclude '**/**Integration*'
}

ext {
generatedProtoSrcDir = 'build/generated/source/main/java'
}

sourceSets.main {
java.srcDirs += [generatedProtoSrcDir]
}

protobuf {
protoc {
// Append 'osxArch' property to workaround M1 Mac bug.
artifact = "com.google.protobuf:protoc:3.19.4${osxArch}"
}
generateProtoTasks {
all()*.plugins {}
}
generatedFilesBaseDir = "$projectDir/build/generated/source"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop;
package bisq.desktop.common;

import javafx.application.Application;
import javafx.application.HostServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package bisq.desktop.primary;

import bisq.application.DefaultApplicationService;
import bisq.desktop.JavaFxApplicationData;
import bisq.desktop.common.JavaFxApplicationData;
import bisq.desktop.common.Browser;
import bisq.desktop.common.utils.DontShowAgainLookup;
import bisq.desktop.common.utils.Transitions;
Expand Down
2 changes: 1 addition & 1 deletion satoshisquare/TODO.md → desktopapp/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The com.jfoenix.adapters.ReflectionHelper causes with Jav 16 an exception:
A workaround is to add the below JVM option:
`--add-opens java.base/java.lang.reflect=ALL-UNNAMED`

Better would be to get proper module support for the desktop module.
Better would be to get proper module support for the module.
33 changes: 9 additions & 24 deletions satoshisquare/build.gradle → desktopapp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
plugins {
id 'java-library'
alias(libs.plugins.protobuf)
id 'application'
id 'distribution'
/* id 'distribution'*/ //todo as long we dont need a jar we leave that out, speeds up build
id 'org.openjfx.javafxplugin' version '0.0.10'
}

Expand All @@ -14,7 +13,7 @@ repositories {
apply from: '../buildSrc/bisq-version.gradle'

application {
project.mainClassName = 'bisq.satoshisquare.Main'
project.mainClassName = 'bisq.desktopapp.Main'
applicationDefaultJvmArgs = ['--add-exports', 'javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED',
'--add-exports', 'javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED']
Expand All @@ -37,7 +36,7 @@ tasks.named('jar') {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version,
'Main-Class': 'bisq.satoshisquare.Main')
'Main-Class': 'bisq.desktopapp.Main')
}
}

Expand All @@ -59,13 +58,18 @@ dependencies {
implementation project(':security')
implementation project(':identity')
implementation project(':network')
implementation project(':account')
implementation project(':offer')
implementation project(':contract')
implementation project(':protocol')
implementation project(':oracle')
implementation project(':settings')
implementation project(':social')
implementation project(':presentation')
implementation project(':application')
implementation project(':wallets')
implementation project(':desktop')

implementation 'com.google.protobuf:protobuf-java'
implementation libs.guava

implementation 'com.jfoenix:jfoenix:9.0.10'
Expand All @@ -81,22 +85,3 @@ test {
useJUnitPlatform()
exclude '**/**Integration*'
}

ext {
generatedProtoSrcDir = 'build/generated/source/main/java'
}

sourceSets.main {
java.srcDirs += [generatedProtoSrcDir]
}

protobuf {
protoc {
// Append 'osxArch' property to workaround M1 Mac bug.
artifact = "com.google.protobuf:protoc:3.19.4${osxArch}"
}
generateProtoTasks {
all()*.plugins {}
}
generatedFilesBaseDir = "$projectDir/build/generated/source"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop;
package bisq.desktopapp;

import bisq.desktop.common.JavaFxApplicationData;
import javafx.application.Application;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop;
package bisq.desktopapp;

import bisq.application.DefaultApplicationService;
import bisq.application.Executable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bisq.desktop;
package bisq.desktopapp;

import lombok.extern.slf4j.Slf4j;

Expand Down
16 changes: 8 additions & 8 deletions docs/sample-run-configs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### IntelliJ IDEA: Application Run Configs

Here are a few IntelliJ IDEA run configurations for running two seeds and different desktop nodes.
Here are a few IntelliJ IDEA run configurations for running two seeds and different desktopapp nodes.

#### Run Config: `Seed_1` (clearnet + tor + i2p)

Expand Down Expand Up @@ -47,12 +47,12 @@ Copy the `Seed_1` run configuration, rename it to `Seed_2` and change:

Classpath of module (Alt+O)
```
bisq.desktop.main
bisq.desktopapp.main
```

Main Class (Alt+C)
```
bisq.desktop.Main
bisq.desktopapp.Main
```

Program Arguments (Alt+R)
Expand Down Expand Up @@ -97,7 +97,7 @@ Copy the `Alice_clear` run configuration, rename it to `Alice_i2p` and change:

* Create a new IntelliJ IDEA run config of type Gradle
* Choose a config name (e.g. `[gradle] Alice I2P`)
* Choose Gradle Project as `bisq2:desktop`
* Choose Gradle Project as `bisq2:desktopapp`
* Add VM options as necessary, in the format `-Dprop=value` (e.g. `-Dbisq.application.appName=bisq_Alice_i2p`)


Expand Down Expand Up @@ -130,18 +130,18 @@ For example, to start two local seeds, `bisq2_seed1` and `bisq2_seed2`, reachabl
-Dbisq.networkServiceConfig.seedAddressByTransportType.clear.1=127.0.0.1:8001
```

Start a desktop client with:
Start a desktopapp client with:

```
# Using default settings
./gradlew desktop:run
./gradlew desktopapp:run
```

To start a custom desktop client connecting only to clearnet:
To start a custom desktopapp client connecting only to clearnet:

```
# Local client on clearnet only
./gradlew desktop:run \
./gradlew desktopapp:run \
-Dbisq.application.appName=bisq_Alice_clear \
-Dbisq.networkServiceConfig.supportedTransportTypes.0=CLEAR \
-Dbisq.networkServiceConfig.seedAddressByTransportType.clear.0=127.0.0.1:8000 \
Expand Down
6 changes: 3 additions & 3 deletions docs/test-scenarios-i2p.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This document describes a few manual test scenarios with focus on the I2P networ
The requirements to run them are:

- access to a virtualization environment (create / delete VMs)
- each VM can run a seed or a desktop client (JDK 16 or higher)
- each VM can run a seed or a desktopapp client (JDK 16 or higher)
- each VM can run the makefile tests (see Requirements in `Makefile` header)
- each VM can optionally start a local I2P router, for some scenarios
- have a way to copy files between VMs (a good solution is `wormhole`, see [docs](https://github.com/magic-wormhole/magic-wormhole/blob/master/docs/welcome.md))
Expand Down Expand Up @@ -46,7 +46,7 @@ Test steps:
VMs used:

- `vm1`: for 2 seeds
- `vm2`: for 2 desktop clients
- `vm2`: for 2 desktopapp clients

Test steps:

Expand All @@ -60,7 +60,7 @@ Test steps:
- `make start-i2p-clients`
- Both these clients will connect to the seeds, then find each other as peers
- In both clients: wait until 2-3 active connections are established
- For both desktop clients: Under Settings > Network Info, ensure there are 3 connections
- For both desktopapp clients: Under Settings > Network Info, ensure there are 3 connections
- In one client, create a Trade Intent
- In the other client: check if Trade Intent is visible

Expand Down
Loading

0 comments on commit df0ac9f

Please sign in to comment.