Skip to content

Commit

Permalink
JDK 21 Updates (#166)
Browse files Browse the repository at this point in the history
* #164 : Master to main changes + start on JDK21

* #164 : Maven - Bumped Lombok for JDK21

* Tweaked maven compiler settings for JDK21.
* Fixed Javadoc earnings in exchange adapters.

* #164 : Maven - Bumped to latest Boot 3.1.10 release

* #164 : Fix new Sonar whine

* #164 : Fix build

* #164 : Update maven build deps

* Also updated maven wrapper.
* Enforced maven 3.8+ and JDK21+

* #164 : Update CI config for JDK 21

* Also updated docs for JDK 17 -> JDK 21

* #164 : Update Docker base image for JDK 21

* #164 : Revert Gradle CI build to JDK 17

* Gradle deps need uplifting...

* #164 : Removed discontinued Coinbase Pro adapter

* See: https://www.coinbase.com/en-gb/blog/hello-advanced-trade-goodbye-coinbase-pro

* #164 : Updated Gradle deps for JDK 21

* Also bump to latest Boot patch version.
* Fix SpotBugs whine.

* #164 : Upgrade to Gradle 8.7 + ignore SpotBugs issue
  • Loading branch information
gazbert committed Apr 20, 2024
1 parent ece406b commit 7ddce5b
Show file tree
Hide file tree
Showing 71 changed files with 394 additions and 3,373 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
with:
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21
- name: Cache Maven packages
uses: actions/cache@v1
with:
Expand Down
Binary file modified .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
14 changes: 7 additions & 7 deletions 3rd-party-licenses.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

## Product

* GSON - https://github.com/google/gson/blob/master/LICENSE
* Guava - https://github.com/google/guava/blob/master/COPYING
* GSON - https://github.com/google/gson/blob/main/LICENSE
* Guava - https://github.com/google/guava/blob/main/COPYING
* log4j - https://logging.apache.org/log4j/2.0/license.html
* JavaMail - https://glassfish.java.net/public/CDDL+GPL_1_1.html
* Spring Boot - https://github.com/spring-projects/spring-boot/blob/master/LICENSE.txt
* Spring Boot - https://github.com/spring-projects/spring-boot/blob/main/LICENSE.txt
* Snake YAML - https://bitbucket.org/asomov/snakeyaml/src/default/LICENSE.txt
* H2 - https://www.h2database.com/html/license.html
* JJWT - https://github.com/jwtk/jjwt/blob/master/LICENSE
Expand All @@ -20,14 +20,14 @@

## Build & Test

* JUnit - http://opensource.org/licenses/eclipse-1.0.html
* JUnit - https://opensource.org/licenses/eclipse-1.0.html
* Powermock - https://github.com/jayway/powermock/blob/master/LICENSE.txt
* EasyMock - http://easymock.org/License.html
* Maven - http://www.apache.org/licenses/
* EasyMock - https://easymock.org/License.html
* Maven - https://www.apache.org/licenses/
* Gradle - https://gradle.org/license/
* JsonPath - https://github.com/jayway/JsonPath/blob/master/LICENSE
* Awaitility - https://github.com/awaitility/awaitility/blob/master/LICENSE
* spring-boot-starter-test - http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html
* spring-boot-starter-test - https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html
* SpotBugs - https://spotbugs.github.io/index.html
* JaCoCo - https://www.jacoco.org/license.html
* Checkstyle - https://checkstyle.org/licenses.html
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ To work on something, whether a new feature or a bug fix:


After your PR has been reviewed and signed off, a maintainer will merge it into
the master branch.
the main branch.

## Code conventions and housekeeping

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:17.0.7_7-jdk
FROM eclipse-temurin:21.0.2_13-jdk

RUN apt-get update
RUN apt-get install -y maven
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# BX-bot

[![Gradle CI](https://github.com/gazbert/bxbot/actions/workflows/gradle.yml/badge.svg?branch=master)](https://github.com/gazbert/bxbot/actions/workflows/gradle.yml)
[![Maven CI](https://github.com/gazbert/bxbot/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/gazbert/bxbot/actions/workflows/maven.yml)
[![Gradle CI](https://github.com/gazbert/bxbot/actions/workflows/gradle.yml/badge.svg?branch=main)](https://github.com/gazbert/bxbot/actions/workflows/gradle.yml)
[![Maven CI](https://github.com/gazbert/bxbot/actions/workflows/maven.yml/badge.svg?branch=main)](https://github.com/gazbert/bxbot/actions/workflows/maven.yml)
[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=gazbert_bxbot&metric=alert_status)](https://sonarcloud.io/dashboard?id=gazbert_bxbot)
[![Join the chat at https://gitter.im/BX-bot/Lobby](https://badges.gitter.im/BX-bot/Lobby.svg)](https://gitter.im/BX-bot/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand All @@ -12,13 +12,13 @@
[BX-bot (_Bex_)](https://github.com/gazbert/bxbot) is a simple Bitcoin trading bot written in Java for trading on cryptocurrency
[exchanges](https://bitcoin.org/en/exchanges).

The project contains the basic infrastructure to trade on a [cryptocurrency](http://coinmarketcap.com/) exchange...
The project contains the basic infrastructure to trade on a [cryptocurrency](https://coinmarketcap.com/) exchange...
except for the trading strategies - you'll need to write those yourself! A simple
[`ExampleScalpingStrategy`](./bxbot-strategies/src/main/java/com/gazbert/bxbot/strategies/ExampleScalpingStrategy.java)
is included to get you started with the Trading API - see [Ta4j](https://github.com/ta4j/ta4j) for more ideas.

Exchange Adapters for using [Bitstamp](https://www.bitstamp.net), [Bitfinex](https://www.bitfinex.com),
[Kraken](https://www.kraken.com), [Gemini](https://gemini.com/), and [Coinbase Pro](https://pro.coinbase.com/) are included.
[Kraken](https://www.kraken.com), and [Gemini](https://gemini.com/) are included.
Feel free to improve these or contribute new adapters to the project; that would be
[shiny!](https://en.wikipedia.org/wiki/Firefly_(TV_series))

Expand All @@ -27,13 +27,13 @@ configured by default to delegate public API calls to Bitstamp, but it simulates
API (order management) calls; it's good for testing your initial setup and
[paper trading](https://www.investopedia.com/terms/p/papertrade.asp) without actually sending orders to the exchange.

The Trading API provides support for [limit orders](http://www.investopedia.com/terms/l/limitorder.asp)
traded at the [spot price](http://www.investopedia.com/terms/s/spotprice.asp).
The Trading API provides support for [limit orders](https://www.investopedia.com/terms/l/limitorder.asp)
traded at the [spot price](https://www.investopedia.com/terms/s/spotprice.asp).
If you're looking for something more sophisticated with a much richer Trading API, take a look at
[XChange](https://github.com/knowm/XChange).

**Warning:** Trading cryptocurrency carries significant financial risk; you could lose money. This software is provided 'as is'
and released under the [MIT license](http://opensource.org/licenses/MIT).
and released under the [MIT license](https://opensource.org/licenses/MIT).

## Architecture

Expand All @@ -58,8 +58,8 @@ it will log the error, send an email alert (if configured), and then shut down.

The bot runs on Linux, macOS, and Windows.

BX-bot is supported on the current JDK 17 LTS. You'll need the JDK (e.g. [OpenJDK 17](http://openjdk.java.net/projects/jdk/17) or
[Oracle JDK 17](https://www.oracle.com/uk/java/technologies/downloads/#java17))
BX-bot is supported on the current JDK 21 LTS. You'll need the JDK (e.g. [OpenJDK 21](https://openjdk.java.net/projects/jdk/21) or
[Oracle JDK 21](https://www.oracle.com/uk/java/technologies/downloads/#java21))
installed on the machine you are going to use to build and run the bot.
Be mindful of Oracle's recent [licensing changes](https://www.oracle.com/technetwork/java/javase/overview/oracle-jdk-faqs.html)
and how you intend to use the bot.
Expand Down Expand Up @@ -112,13 +112,13 @@ and evaluate the bot, Docker is the way to go.
Then run: `docker container attach <CONTAINER ID>`

## Build Guide
If you plan on developing the bot, you'll need JDK 17 installed on your dev box.
If you plan on developing the bot, you'll need JDK 21 installed on your dev box.

You can use Gradle or Maven to build the bot and pull down the dependencies.

The instructions below are for Linux/macOS, but equivalent Windows scripts are included.

Clone the repo locally (master branch).
Clone the repo locally (main branch).

### Maven
1. From the project root, run `./mvnw clean install`.
Expand Down Expand Up @@ -149,7 +149,7 @@ The bot has undergone basic unit testing on a _best-effort_ basis.
There is a CI build running on [GitHub Actions](https://github.com/gazbert/bxbot/actions).

The latest stable build can always be found on the [Releases](https://github.com/gazbert/bxbot/releases) page.
The SNAPSHOT builds on master are active development builds, but the tests should always pass and the bot should always
The SNAPSHOT builds on main are active development builds, but the tests should always pass and the bot should always
be deployable.

## User Guide
Expand Down Expand Up @@ -533,7 +533,7 @@ your own jar for your adapters, e.g. `my-adapters.jar`, and include it on BX-bot
see the _[Installation Guide](#the-manual-way)_ for how to do this.

### Logging
Logging for the bot is provided by [log4j](http://logging.apache.org/log4j). The log file is written to `logs/bxbot.log`
Logging for the bot is provided by [log4j](https://logging.apache.org/log4j). The log file is written to `logs/bxbot.log`
using a rolling policy. When a log file size reaches 100 MB or a new day is started, it is archived and a new log file
is created. BX-bot will create up to 7 archives on the same day; these are stored in a directory based on the current
year and month. Only the last 90 archives are kept. Each archive is compressed using gzip. The logging level is set
Expand Down Expand Up @@ -612,7 +612,7 @@ JWT before it expires in order to get a new one. Alternatively, you can re-authe
The REST API must be configured to use TLS before accessing it over a public network.

You will need to
[create a keystore](https://docs.oracle.com/en/java/javase/17/docs/specs/man/keytool.html) - the command to
[create a keystore](https://docs.oracle.com/en/java/javase/21/docs/specs/man/keytool.html) - the command to
create a [PKCS12](https://en.wikipedia.org/wiki/PKCS_12) self-signed certificate is shown below:

```bash
Expand Down
38 changes: 19 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ buildscript {
}

dependencies {
classpath('io.spring.gradle:dependency-management-plugin:1.1.3')
classpath('org.springframework.boot:spring-boot-gradle-plugin:3.1.3')
classpath('io.spring.gradle:dependency-management-plugin:1.1.4')
classpath('org.springframework.boot:spring-boot-gradle-plugin:3.1.11')
}
}

plugins {
id 'org.sonarqube' version '4.3.1.3277' // https://plugins.gradle.org/plugin/org.sonarqube
id 'org.sonarqube' version '5.0.0.4638' // https://plugins.gradle.org/plugin/org.sonarqube
id 'jacoco'
id 'com.github.spotbugs' version '5.1.3' // https://plugins.gradle.org/plugin/com.github.spotbugs
id 'com.github.spotbugs' version '5.2.5' // https://plugins.gradle.org/plugin/com.github.spotbugs
}

buildScan {
Expand All @@ -23,11 +23,11 @@ buildScan {
}

ext.versions = [
springBootVersion : '3.1.3',
springCloudVersion : '4.0.4',
springBootVersion : '3.1.11',
springCloudVersion : '4.0.5',

// Should be same as dependency used by springBootVersion
springCoreVersion : '6.0.11',
springCoreVersion : '6.0.19',

hibernateVaildatorVersion: '8.0.1.Final',
jjwtVersion : '0.11.5'
Expand Down Expand Up @@ -62,20 +62,20 @@ ext.libraries = [
jjwt_impl : dependencies.create("io.jsonwebtoken:jjwt-impl:" + ext.versions.jjwtVersion),
jjwt_jackson : dependencies.create("io.jsonwebtoken:jjwt-jackson:" + ext.versions.jjwtVersion),

google_guava : dependencies.create("com.google.guava:guava:32.1.2-jre"),
google_guava : dependencies.create("com.google.guava:guava:33.1.0-jre"),
google_gson : dependencies.create("com.google.code.gson:gson:2.10.1"),
h2 : dependencies.create("com.h2database:h2:2.2.222"),
h2 : dependencies.create("com.h2database:h2:2.2.224"),

jakarta_mail_api : dependencies.create("jakarta.mail:jakarta.mail-api:2.1.2"),
jakarta_mail_sun : dependencies.create("org.eclipse.angus:angus-mail:2.0.2"),
jakarta_mail_api : dependencies.create("jakarta.mail:jakarta.mail-api:2.1.3"),
jakarta_mail_sun : dependencies.create("org.eclipse.angus:angus-mail:2.0.3"),

jakarta_xml_api : dependencies.create("javax.xml.bind:jaxb-api:2.4.0-b180830.0359"),
jakarta_xml_api : dependencies.create("jakarta.xml.bind:jakarta.xml.bind-api:4.0.2"),

snake_yaml : dependencies.create("org.yaml:snakeyaml:1.33"),

springdoc_openapi_ui : dependencies.create("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0"),

lombok : dependencies.create("org.projectlombok:lombok:1.18.20"),
lombok : dependencies.create("org.projectlombok:lombok:1.18.32"),

validation_api : dependencies.create("jakarta.validation:jakarta.validation-api:3.0.2"),
hibernate_validator : dependencies.create("org.hibernate.validator:hibernate-validator:" + ext.versions.hibernateVaildatorVersion),
Expand All @@ -86,13 +86,13 @@ ext.libraries = [
easymock : dependencies.create("org.easymock:easymock:5.2.0"),

// JUnit 4 still as Powermock does not play with Junit 5: https://github.com/powermock/powermock/issues/929
junit_vintage_engine : dependencies.create("org.junit.vintage:junit-vintage-engine:5.10.0"),
junit_vintage_engine : dependencies.create("org.junit.vintage:junit-vintage-engine:5.10.2"),

spring_boot_starter_test : dependencies.create("org.springframework.boot:spring-boot-starter-test:" + ext.versions.springBootVersion) {
exclude module: "spring-boot-starter-logging"
},
spring_security_test : dependencies.create("org.springframework.security:spring-security-test:6.1.3"),
awaitility : dependencies.create("org.awaitility:awaitility:4.2.0")
spring_security_test : dependencies.create("org.springframework.security:spring-security-test:6.1.8"),
awaitility : dependencies.create("org.awaitility:awaitility:4.2.1")
]

allprojects {
Expand All @@ -117,8 +117,8 @@ subprojects {

apply plugin: 'java'

sourceCompatibility = 1.17
targetCompatibility = 1.17
sourceCompatibility = 1.21
targetCompatibility = 1.21

repositories {
mavenCentral()
Expand Down Expand Up @@ -151,7 +151,7 @@ subprojects {
}

jacoco {
toolVersion = "0.8.9" // https://docs.gradle.org/current/userguide/jacoco_plugin.html
toolVersion = "0.8.11" // https://docs.gradle.org/current/userguide/jacoco_plugin.html
}
jacocoTestReport {
reports {
Expand Down
4 changes: 4 additions & 0 deletions bxbot-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
4 changes: 4 additions & 0 deletions bxbot-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class ExchangeConfigImpl implements ExchangeConfig {
private NetworkConfig networkConfig;
private OtherConfig otherConfig;

/** Creates the Exchange Config impl. */
public ExchangeConfigImpl() {
// No extra init needed.
}

@Override
public String getExchangeName() {
return exchangeName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public final class StrategyConfigItems implements StrategyConfig {

private Map<String, String> items = new HashMap<>();

/** Creates the Strategy Config Items. */
public StrategyConfigItems() {
// No extra init needed.
}

@Override
public String getConfigItem(String key) {
return items.get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public class TradingStrategiesBuilder {

private TradingStrategyFactory tradingStrategyFactory;

/** Creates the Trading Strategies Builder. */
public TradingStrategiesBuilder() {
// No extra init needed.
}

/**
* Sets the trading strategy factory.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
@Log4j2
public class ConfigurableComponentFactory {

/** Creates the Configurable Component Factory. */
public ConfigurableComponentFactory() {
// No extra init needed.
}

/**
* Loads and instantiates a given class and returns it.
*
Expand Down
4 changes: 4 additions & 0 deletions bxbot-domain-objects/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class ExchangeConfig {

@Schema(
requiredMode = Schema.RequiredMode.REQUIRED,
requiredMode = Schema.RequiredMode.REQUIRED,
description =
"The Exchange name. It is used in log statements to display the Exchange's name."
+ " Value must be an alphanumeric string. Spaces are allowed.")
Expand Down Expand Up @@ -69,6 +69,11 @@ public class ExchangeConfig {
+ "any additional config, e.g. buy/sell fees.")
private Map<String, String> otherConfig;

/** Creates the Exchange config. */
public ExchangeConfig() {
// No extra init needed.
}

/**
* Returns the name.
*
Expand Down
Loading

0 comments on commit 7ddce5b

Please sign in to comment.