Merge pull request #335 from bitsquare/UpdateFX_maven

Add UpdateFX support, switch back to Maven build
This commit is contained in:
Manfred Karrer 2015-03-04 10:46:43 +01:00
commit c582dca17a
686 changed files with 3742 additions and 746 deletions

3
.gitignore vendored
View File

@ -6,7 +6,8 @@
!.idea/copyright/Bitsquare_Affero_GPLv3.xml
!.idea/copyright/profiles_settings.xml
!.idea/codeStyleSettings.xml
bitsquare.iml
*.iml
*/*.iml
*.spvchain
*.wallet
*.ser

View File

@ -1,24 +0,0 @@
language: java
jdk: oraclejdk8
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
notifications:
irc:
channels: chat.freenode.net#bitsquare
template:
- '%{message} (%{repository}#%{build_number}, %{duration})'
- '%{repository}/%{branch} %{commit} %{author}: %{commit_message}'
- '%{build_url}'
on_success: change
on_failure: always
use_notice: true
skip_join: true
env:
- TERM=dumb
after_success:
- ./gradlew jacocoTestReport coveralls

View File

@ -18,44 +18,12 @@ You can read about all of this and more in the [whitepaper](https://bitsquare.io
Status
------
Pre-alpha and under heavy development.
Alpha and under heavy development.
Building from source
--------------------
1. Install the latest JDK (8u20 or better)
2. Clone this repository
3. **Build and launch the Bitsquare JavaFX client** by running:
```
./gradlew run
```
Pass command line arguments to the app via the Gradle `-Pargs` property as follows:
./gradlew run -Pargs="--help"
Or, **build an executable jar** with the `appJar` task:
./gradlew appJar
Run the app as follows:
java -jar build/libs/bitsquare-<version>-app.jar
Pass the `--help` flag to see what options are available:
java -jar build/libs/bitsquare-<version>-app.jar --help
To **build a headless bootstrap node jar**, run the `bootstrapNodeJar` task:
./gradlew bootstrapNodeJar
Run the bootstrap node:
java -jar build/libs/bitsquare-<version>-bootstrapNode.jar
See [doc/build.md](doc/build.md) for additional information.
See [doc/build.md](doc/build.md).
Staying in Touch

View File

@ -1,102 +0,0 @@
import org.apache.tools.ant.filters.ReplaceTokens
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id "com.github.johnrengelman.shadow" version "1.1.2"
id "com.github.kt3k.coveralls" version "2.0.1x"
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: 'jacoco'
wrapper.gradleVersion = '2.1'
version = '0.1.1-SNAPSHOT'
sourceCompatibility = 1.8
sourceSets.main.resources.srcDirs += 'src/main/java'
sourceSets.test.resources.srcDirs += 'src/test/java'
mainClassName = "io.bitsquare.app.gui.BitsquareAppMain"
run {
if (project.hasProperty('args')) {
args project.args.split(',')
}
}
processResources {
from(sourceSets.main.resources.srcDirs) {
include '**/*.properties'
filter(ReplaceTokens, tokens: ['app.version': project.version])
}
}
repositories {
jcenter()
maven { url 'http://tomp2p.net/dev/mvn/' }
}
dependencies {
compile 'org.bitcoinj:bitcoinj-core:0.12.2'
compile 'net.tomp2p:tomp2p-all:5.0-Beta3'
compile 'io.reactivex:rxjava:1.0.0'
compile 'org.springframework:spring-core:4.1.1.RELEASE'
compile 'net.sf.jopt-simple:jopt-simple:4.8'
compile 'org.slf4j:slf4j-api:1.7.7'
compile 'ch.qos.logback:logback-core:1.1.2'
compile 'ch.qos.logback:logback-classic:1.1.2'
compile 'com.google.inject:guice:3.0'
compile 'com.google.guava:guava:16.0.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.controlsfx:controlsfx:8.0.6_20'
compile 'de.jensd:fontawesomefx:8.0.0'
compile 'net.glxn:qrgen:1.3'
compile 'com.google.code.findbugs:jsr305:2.0.3'
compile 'net.jcip:jcip-annotations:1.0'
compile 'org.jetbrains:annotations:13.0'
compile 'eu.hansolo.enzo:Enzo:0.1.5'
compile 'com.vinumeris:updatefx:1.2'
testCompile 'junit:junit:4.11'
testCompile "org.mockito:mockito-core:1.+"
testCompile 'org.springframework:spring-test:4.1.1.RELEASE'
}
shadowJar.classifier = 'app'
task packageNative(type: Exec, dependsOn: shadowJar) {
if (Os.isFamily(Os.FAMILY_MAC))
executable "${project.rootDir}/package/mac.sh"
else if (Os.isFamily(Os.FAMILY_UNIX))
executable "${project.rootDir}/package/linux.sh"
else if (Os.isFamily(Os.FAMILY_WINDOWS))
executable "${project.rootDir}/package/windows.bat"
else
throw new GradleException("Unsupported OS: " + System.properties['os.name'])
args project.version, shadowJar.archivePath, mainClassName
}
task appJar(dependsOn: shadowJar) {
group = "shadow"
description = "Builds a Bitsquare client UI executable jar"
}
task bootstrapNodeJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
group = "shadow"
description = "Builds a Bitsquare bootstrap node executable jar"
manifest.attributes 'Main-Class': 'io.bitsquare.app.cli.BootstrapNodeMain'
classifier = 'bootstrapNode'
from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output)
configurations = [project.configurations.runtime]
exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA')
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}

15
common/pom.xml Executable file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parent</artifactId>
<groupId>io.bitsquare</groupId>
<version>0.1.1-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<dependencies>
</dependencies>
</project>

View File

@ -9,21 +9,21 @@ This guide will walk you through the process of building Bitsquare from source.
For the impatient
-----------------
What follows is explained in detail in the sections below, but for those who know their way around Java, git and Gradle, here are the instructions in a nutshell:
What follows is explained in detail in the sections below, but for those who know their way around Java, git and Maven, here are the instructions in a nutshell:
$ javac -version
javac 1.8.0_20 # must be 1.8.0_20 or better
$ git clone https://github.com/bitsquare/bitsquare.git
$ cd bitsquare
$ ./gradlew appJar # (on *nix)
--- or ---
$ gradlew appJar # (on Windows)
$ mvn package
When the build completes, you will find an excutable jar in the `build/libs` directory. Run it as follows for the help screen:
$ java -jar build/libs/bitsquare-<version>-app.jar --help
When the build completes, you will find an excutable jar: `gui/target/shaded.jar`.
To run it use:
$ java -jar gui/target/shaded.jar
To build the binary needs a bit more preparation as we use [UpdateFX](https://github.com/vinumeris/updatefx) for automatic updates.
You can find more information in the build scripts under package.
Prerequisites
-------------
@ -52,19 +52,20 @@ The preferred approach is to clone the Bitsquare repository using [git](http://w
However, if you're not familiar with git or it is otherwise inconvenient to use, you can also download and extract a zip file of the latest sources at https://github.com/bitsquare/bitsquare/archive/master.zip.
### 2. Build
### 2. Build jar
Bitsquare uses [Gradle](http://www.gradle.org/), and the [Gradle wrapper](http://www.gradle.org/docs/current/userguide/gradle_wrapper.html) as a build system. This means you don't need to download or do anything other than run the following command within the `bitsquare` directory.
./gradlew appJar
> _**NOTE:** on Windows, leave out the `./` and simply run `gradlew appJar`._
Bitsquare uses maven as a build system.
$ cd bitsquare
$ mvn package
### 3. Run
When the build completes, you'll find an executable jar in the `build/libs` directory. See instructions above for how to run it.
When the build completes, you will find an excutable jar: `gui/target/shaded.jar`.
To run it use:
$ java -jar gui/target/shaded.jar
Problems?
---------

29
doc/update_fork_tomp2p.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
cd /Users/mk/Documents/_intellij/TomP2P-master_fork/TomP2P
git reset --hard
git remote add upstream https://github.com/tomp2p/TomP2P.git
git checkout master
git pull upstream master
git push origin master
git checkout published
git reset --hard master
export COMMITHASH=$(git log --oneline -1 | cut -d" " -f1)
git grep -l 5.0-Alpha | xargs perl -p -i -e "s/5.0-Alpha(..?)-SNAPSHOT/5.0-Alpha$1.$COMMITHASH-SNAPSHOT/"
git commit -am"Qualify pom version for publication"
echo $COMMITHASH
mvn clean install -DskipTests
git show bitsquare-published-91276e8:README > README
git add README
git commit -m"Add README with publication instructions"
git tag bitsquare-published-$COMMITHASH published
git push -f origin published
git push --tags
echo $COMMITHASH

View File

@ -1,2 +0,0 @@
org.gradle.jvmargs=-Xmx1024m
org.gradle.daemon=true

Binary file not shown.

View File

@ -1,6 +0,0 @@
#Tue Sep 30 23:44:09 CEST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip

164
gradlew vendored
View File

@ -1,164 +0,0 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored
View File

@ -1,90 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

210
gui/pom.xml Executable file
View File

@ -0,0 +1,210 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parent</artifactId>
<groupId>io.bitsquare</groupId>
<version>0.1.1-SNAPSHOT</version>
</parent>
<artifactId>gui</artifactId>
<build>
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.fxml</include>
<include>**/*.css</include>
</includes>
</resource>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<!-- broken with Java 8 (MSHADE-174), using ProGuard instead. -->
<minimizeJar>false</minimizeJar>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.bitsquare.app.gui.BitsquareAppMain</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<!-- exclude signatures, the bundling process breaks them for some reason -->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>bundled</shadedClassifierName>
<finalName>shaded</finalName>
</configuration>
</execution>
</executions>
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce</id>
<configuration>
<rules>
<DependencyConvergence />
</rules>
</configuration>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>-->
</plugins>
</build>
<repositories>
<repository>
<id>sonatype-oss-snapshot</id>
<snapshots/>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>repository.tomp2p.net</id>
<url>http://tomp2p.net/dev/mvn</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.bitsquare</groupId>
<artifactId>common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>net.tomp2p</groupId>
<artifactId>tomp2p-all</artifactId>
<version>5.0-Beta3</version>
</dependency>
<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId>
<version>4.8</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>8.0.6_20</version>
</dependency>
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx</artifactId>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>13.0</version>
</dependency>
<dependency>
<groupId>eu.hansolo.enzo</groupId>
<artifactId>Enzo</artifactId>
<version>0.1.5</version>
</dependency>
<dependency>
<groupId>org.fxmisc.easybind</groupId>
<artifactId>easybind</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.vinumeris</groupId>
<artifactId>updatefx</artifactId>
<version>1.2</version>
</dependency>
<!--
<dependency>
<groupId>com.vinumeris</groupId>
<artifactId>crashfx-client</artifactId>
<version>1.1</version>
</dependency>
-->
</dependencies>
</project>

View File

@ -45,7 +45,6 @@ public class BitsquareEnvironment extends StandardEnvironment {
public static final String APP_VERSION_KEY = "app.version";
// TODO what is the difference to APP_DATA_DIR ?
public static final String USER_DATA_DIR_KEY = "user.data.dir";
public static final String DEFAULT_USER_DATA_DIR = defaultUserDataDir();
@ -99,7 +98,6 @@ public class BitsquareEnvironment extends StandardEnvironment {
}
}
PropertySource<?> appDirProperties() throws Exception {
String location = String.format("file:%s/bitsquare.properties", appDataDir);
Resource resource = resourceLoader.getResource(location);

View File

@ -58,7 +58,7 @@ import org.springframework.util.FileSystemUtils;
import static io.bitsquare.app.BitsquareEnvironment.*;
public class BitsquareApp extends Application {
private static final Logger log = LoggerFactory.getLogger(BitsquareAppMain.class);
private static final Logger log = LoggerFactory.getLogger(BitsquareApp.class);
private static Environment env;
@ -71,9 +71,7 @@ public class BitsquareApp extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
// For some reason the JavaFX launch process results in us losing the thread context class loader: reset it.
Thread.currentThread().setContextClassLoader(BitsquareApp.class.getClassLoader());
log.trace("BitsquareApp.start");
bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
injector = Guice.createInjector(bitsquareAppModule);
injector.getInstance(InjectorViewFactory.class).setInjector(injector);
@ -107,6 +105,7 @@ public class BitsquareApp extends Application {
// load the main view and create the main scene
log.trace("viewLoader.load(MainView.class)");
ViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
View view = viewLoader.load(MainView.class);
@ -152,6 +151,7 @@ public class BitsquareApp extends Application {
// make the UI visible
log.trace("primaryStage.show");
primaryStage.show();
}

View File

@ -30,6 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.vinumeris.updatefx.UpdateFX;
import joptsimple.OptionException;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
@ -42,14 +43,38 @@ public class BitsquareAppMain extends BitsquareExecutable {
private static final Logger log = LoggerFactory.getLogger(BitsquareAppMain.class);
public static void main(String[] args) throws Exception {
// We don't want to do the whole arg parsing/setup here as that might easily change in update versions
// So we only handle the absolute minimum which is APP_NAME and USER_DATA_DIR
// TODO Not impl. yet, just use default for first testings
UpdateFX.bootstrap(BitsquareAppMain.class, new File(BitsquareEnvironment.DEFAULT_APP_DATA_DIR).toPath(), args);
// We don't want to do the full argument parsing here as that might easily change in update versions
// So we only handle the absolute minimum which is APP_NAME, APP_DATA_DIR_KEY and USER_DATA_DIR
OptionParser parser = new OptionParser();
parser.accepts(USER_DATA_DIR_KEY, description("User data directory", DEFAULT_USER_DATA_DIR))
.withRequiredArg();
parser.accepts(APP_NAME_KEY, description("Application name", DEFAULT_APP_NAME))
.withRequiredArg();
parser.accepts(APP_DATA_DIR_KEY, description("Application data directory", DEFAULT_APP_DATA_DIR))
.withRequiredArg();
OptionSet options;
try {
options = parser.parse(args);
} catch (OptionException ex) {
System.out.println("error: " + ex.getMessage());
System.out.println();
parser.printHelpOn(System.out);
System.exit(EXIT_FAILURE);
return;
}
BitsquareEnvironment bitsquareEnvironment = new BitsquareEnvironment(options);
String updatesDirectory = bitsquareEnvironment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY);
UpdateFX.bootstrap(BitsquareAppMain.class, new File(updatesDirectory).toPath(), args);
}
// That will be called from UpdateFX after updates are checked
public static void realMain(String[] args) throws Exception {
log.trace("realMain");
// For some reason the JavaFX launch process results in us losing the thread context class loader: reset it.
// In order to work around a bug in JavaFX 8u25 and below, you must include the following code as the first line of your realMain method:
Thread.currentThread().setContextClassLoader(BitsquareAppMain.class.getClassLoader());
new BitsquareAppMain().execute(args);
}

View File

@ -61,10 +61,8 @@ class BitsquareAppModule extends BitsquareModule {
bindConstant().annotatedWith(named(Persistence.PREFIX_KEY)).to(env.getRequiredProperty(Persistence.PREFIX_KEY));
bind(Persistence.class).asEagerSingleton();
// TODO UpdateFXHelper needs Environment. Should we just expose the 2 properties needed?
bind(Environment.class).toInstance(env);
// for temp testing with mock
bind(UpdateProcess.class).to(MockUpdateProcess.class).asEagerSingleton();
bind(UpdateProcess.class).asEagerSingleton();
install(messageModule());
install(bitcoinModule());

View File

@ -51,14 +51,15 @@ import rx.subjects.Subject;
public class UpdateProcess {
private static final Logger log = LoggerFactory.getLogger(UpdateProcess.class);
// Edit version for updateFX
private static final int VERSION = 1;
private static final List<ECPoint> UPDATE_SIGNING_KEYS = Crypto.decode(
"028B41BDDCDCAD97B6AE088FEECA16DC369353B717E13319370C729CB97D677A11",
"031E3D80F21A4D10D385A32ABEDC300DACBEDBC839FBA58376FBD5D791D806BA68"
);
private static final int UPDATE_SIGNING_THRESHOLD = 1;
private static final List<ECPoint> UPDATE_SIGNING_KEYS = Crypto.decode("032D7B4073B0B94F0B0AAD72D4CC2B86FDDE7AAE334DE4BE448B0983D887975289");
private static final String UPDATES_BASE_URL = "http://localhost:8000/";
private static final int UPDATE_SIGNING_THRESHOLD = 1;
private static final Path ROOT_CLASS_PATH = UpdateFX.findCodePath(BitsquareAppMain.class);
private Environment environment;
public enum State {
@ -72,22 +73,11 @@ public class UpdateProcess {
protected String errorMessage;
protected final Subject<State, State> process = BehaviorSubject.create();
protected final AnimationTimer timeoutTimer;
protected AnimationTimer timeoutTimer;
@Inject
public UpdateProcess(Environment environment) {
// process.timeout() will cause an error state back but we dont want to break startup in case of an update
// timeout
timeoutTimer = Utilities.setTimeout(10000, new Function<AnimationTimer, Void>() {
@Override
public Void apply(AnimationTimer animationTimer) {
process.onCompleted();
return null;
}
});
timeoutTimer.start();
init(environment);
this.environment = environment;
}
public void restart() {
@ -102,16 +92,26 @@ public class UpdateProcess {
return errorMessage;
}
protected void init(Environment environment) {
log.info("version " + VERSION);
public void init() {
log.info("UpdateFX current version " + VERSION);
// process.timeout() will cause an error state back but we don't want to break startup in case of an timeout
timeoutTimer = Utilities.setTimeout(10000, new Function<AnimationTimer, Void>() {
@Override
public Void apply(AnimationTimer animationTimer) {
process.onCompleted();
return null;
}
});
timeoutTimer.start();
String agent = environment.getProperty(BitsquareEnvironment.APP_NAME_KEY) + VERSION;
Path dataDirPath = new File(environment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY)).toPath();
Updater updater = new Updater(UPDATES_BASE_URL, agent, VERSION, dataDirPath, ROOT_CLASS_PATH,
UPDATE_SIGNING_KEYS, UPDATE_SIGNING_THRESHOLD) {
@Override
protected void updateProgress(long workDone, long max) {
log.debug("updateProgress " + workDone + "/" + max);
//log.trace("updateProgress " + workDone + "/" + max);
super.updateProgress(workDone, max);
}
};
@ -127,24 +127,24 @@ public class UpdateProcess {
updater.setOnSucceeded(event -> {
try {
UpdateSummary summary = updater.get();
if (summary.descriptions.size() > 0) {
log.info("summary " +summary.toString());
if (summary.descriptions != null && summary.descriptions.size() > 0) {
log.info("One liner: {}", summary.descriptions.get(0).getOneLiner());
log.info("{}", summary.descriptions.get(0).getDescription());
}
if (summary.highestVersion > VERSION) {
log.info("UPDATE_AVAILABLE");
state.set(State.UPDATE_AVAILABLE);
// We stop the timeout and treat it not completed.
// The user should click the restart button manually if there are updates available.
timeoutTimer.stop();
}
else if (summary.highestVersion == VERSION) {
log.info("UP_TO_DATE");
state.set(State.UP_TO_DATE);
timeoutTimer.stop();
process.onCompleted();
}
/* if (summary.highestVersion > VERSION) {
log.info("Restarting to get version " + summary.highestVersion);
if (UpdateFX.getVersionPin(dataDirPath) == 0)
UpdateFX.restartApp();
}*/
} catch (Throwable e) {
log.error("Exception at processing UpdateSummary: " + e.getMessage());
@ -172,5 +172,4 @@ public class UpdateProcess {
thread.setDaemon(true);
thread.start();
}
}
}

View File

@ -149,6 +149,8 @@ class MainViewModel implements ViewModel {
}
public void initBackend() {
Platform.runLater(() -> updateProcess.init());
setBitcoinNetworkSyncProgress(-1);
walletService.getDownloadProgress().subscribe(
percentage -> Platform.runLater(() -> {
@ -195,16 +197,16 @@ class MainViewModel implements ViewModel {
log.trace("updateProcess completed");
});
Observable<?> backEnd = Observable.merge(message, wallet, updateProcess);
backEnd.subscribe(
Observable<?> allTasks = Observable.merge(message, wallet, updateProcess);
allTasks.subscribe(
next -> {
},
error -> log.error(error.toString()),
() -> Platform.runLater(() -> backEndCompleted())
() -> Platform.runLater(() -> allTasksCompleted())
);
}
private void backEndCompleted() {
private void allTasksCompleted() {
log.trace("backend completed");
tradeManager.getPendingTrades().addListener(

Some files were not shown because too many files have changed in this diff Show More