Skip to content

Commit b00e495

Browse files
authored
Boot 3.1 upgrade (#163)
* #162 : Upgrade maven build to Boot 3.1 * #162 : Replaced deprecated @EnableGlobalMethodSecurity with @EnableMethodSecurity * #162 : Removed redundant dev profile prop * #162 : Fixed log4j3 deprecation warns in maven build "WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release" See: https://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax * #162 : Removed banner from test output * #162 : Fix banner startup in log file * #162 : Tone down startup logging * #162 : More startup logging cleanup * #162 : Update maven-assembly-plugin * #162 : Replaced deprecated Spring Security config methods * #162 : Replaced deprecated Base64 encoder in test class * #162 : Fix Sonar issues + introduce Lombok * #162 : Replace deprecated JJWT code * #162 : Use Lombok for logging * #162 : Use Lombok for logging + Sonar fixes * #162 : Use JUnit5 assertions where possible * #162 : Put maven JaCoCo coverage back to 0.8 * #162 : Don't duplicate Sonar report in Gradle CI * #162 : Upgrade Gradle build to Boot 3.1.x + Lombok * #162 : Removed JUnit 5 assert from JUnit4 test * Also removed Sonar token from Gradle CI config. * #162 : Removed Powermock from REST API module Becoming a pain for coverage reporting... * #162 : Upgrade dependencies for maven build * #162 : Upgrade maven wrapper * #162 : Upgrade maven wrapper to latest maven 3.9.4 * #162 : Upgrade dependencies for gradle build * #162 : Upgrade gradle wrapper to 7.6.2 * #162 : Upgrade gradle wrapper to gradle 8.0 * #162 : Upgrade gradle wrapper to gradle 8.0.2 * #162 : Upgrade gradle wrapper to gradle 8.1.1 * #162 : Upgrade gradle wrapper to gradle 8.2.1 * #162 : Upgrade gradle wrapper to gradle 8.3 * #162 : Send Gradle CI build to Sonar too Makes sense to check the sonar plugin works for Gradle too. * #162 : Fix JaCoCo coverage reporting for maven build * #162 : Fix JaCoCo coverage reporting for Gradle build * #162 : Fix JaCoCo coverage for powermock modules for Maven build * #162 : Converted ConfigurationManager to a Spring component * Also removed powermock from bxbot-repository - no longer needed :-) * #162 : Change Gradle indents to 2 + README tweaks * #162 : Cleanup powermock JDK 17 illegal access permissions * #162 : Cleanup more powermock JDK 17 illegal access permissions + Javadoc * #162 : Use Lombok for logging + test cleanup * #162 : Fix some minor Sonar whines * #162 : Removed deprecated test adapter * Also fixed more minor Sonar whines... * #162 : Fix Gradle build - checkstyle * #162 : Really fix Gradle build checkstyle * Looks like Gradle checkstyle plugin no like java text block statements... * #162 : Fixed some Sonar whines * #162 : Use Lombok for logging * #162 : Use Lombok for logging * #162 : Use Lombok for logging * #162 : Fix gradle build checkstyle issue * #162 : Convert ConfigurableComponentFactory to Spring component * A big change, but needed to be done. Less Powermock always a good thing! * #162 : Change Gradle Groovy indentation to 2 spaces * #162 : Use Lombok for logging + misc cleanup * #162 : Use Lombok for logging + misc cleanup * #162 : Fix some minor sonar whines * #162 : Fix some minor sonar whines * #162 : Use Lombok for logging + Sonar fixes
1 parent 452b27a commit b00e495

File tree

157 files changed

+2522
-2662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+2522
-2662
lines changed

.github/workflows/gradle.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ jobs:
2222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2323
# SonarCloud access token should be generated from https://sonarcloud.io/account/security/
2424
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
25+
26+

.mvn/wrapper/maven-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
1818
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ traded at the [spot price](http://www.investopedia.com/terms/s/spotprice.asp).
3232
If you're looking for something more sophisticated with a much richer Trading API, take a look at
3333
[XChange](https://github.com/knowm/XChange).
3434

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

3838
## Architecture
@@ -566,7 +566,7 @@ and started the bot.
566566
The REST API listens for plain HTTP traffic on port `8080` by default - you can change the
567567
`server.port` in the [./config/application.properties](./config/application.properties) file.
568568

569-
**Warning:** The bot must be configured to use TLS if you plan on accessing the REST API over a
569+
The bot _must_ be configured to use TLS if you plan on accessing the REST API over a
570570
public network - see the _[TLS](#tls)_ section below.
571571

572572
You _must_ also change the `bxbot.restapi.jwt.secret` value in the
@@ -609,13 +609,13 @@ JWT before it expires in order to get a new one. Alternatively, you can re-authe
609609
`/api/token` endpoint.
610610

611611
#### TLS
612-
The REST API _must_ be configured to use TLS before accessing it over a public network.
612+
The REST API must be configured to use TLS before accessing it over a public network.
613613

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

618-
``` bash
618+
```bash
619619
keytool -genkeypair -alias rest-api-keystore -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore keystore.p12 -validity 3650
620620
```
621621

@@ -627,7 +627,7 @@ CA signed certificate.
627627
The 'TLS Configuration' section in the [./config/application.properties](./config/application.properties)
628628
file needs the following properties set:
629629

630-
``` properties
630+
```properties
631631
# Spring Boot profile for REST API.
632632
# Must use https profile in Production environment.
633633
spring.profiles.active=https

build.gradle

Lines changed: 222 additions & 239 deletions
Large diffs are not rendered by default.

bxbot-app/build.gradle

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
apply plugin: 'org.springframework.boot'
22

33
bootJar {
4-
mainClassName = 'com.gazbert.bxbot.BxBot'
4+
mainClassName = 'com.gazbert.bxbot.BxBot'
55
}
66

77
dependencies {
88

9-
implementation project(':bxbot-trading-api')
10-
implementation project(':bxbot-strategy-api')
11-
implementation project(':bxbot-exchange-api')
12-
implementation project(':bxbot-strategies')
13-
implementation project(':bxbot-exchanges')
14-
implementation project(':bxbot-domain-objects')
15-
implementation project(':bxbot-yaml-datastore')
16-
implementation project(':bxbot-repository')
17-
implementation project(':bxbot-core')
18-
implementation project(':bxbot-rest-api')
9+
implementation project(':bxbot-trading-api')
10+
implementation project(':bxbot-strategy-api')
11+
implementation project(':bxbot-exchange-api')
12+
implementation project(':bxbot-strategies')
13+
implementation project(':bxbot-exchanges')
14+
implementation project(':bxbot-domain-objects')
15+
implementation project(':bxbot-yaml-datastore')
16+
implementation project(':bxbot-repository')
17+
implementation project(':bxbot-core')
18+
implementation project(':bxbot-rest-api')
1919

20-
// Add your (optional) Trading Strategies here
21-
// implementation group: 'com.gazbert.bxbot', name: 'bxbot-strategies', version: '3.0-SNAPSHOT'
20+
// Add your (optional) Trading Strategies here
21+
// implementation group: 'com.gazbert.bxbot', name: 'bxbot-strategies', version: '3.0-SNAPSHOT'
2222

23-
// Add your (optional) Exchange Adapters here
24-
// implementation group: 'com.your.stuff', name: 'your-custom-exchanges', version: '1.0-SNAPSHOT'
23+
// Add your (optional) Exchange Adapters here
24+
// implementation group: 'com.your.stuff', name: 'your-custom-exchanges', version: '1.0-SNAPSHOT'
2525
}

bxbot-core/src/main/resources/banner.txt renamed to bxbot-app/src/main/resources/banner.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
$$$$$$$\ $$\ $$\ $$\ $$\
34
$$ __$$\ $$ | $$ | $$ | $$ |
45
$$ | $$ |\$$\ $$ | $$$$$$$\ $$$$$$\ $$$$$$\

bxbot-core/build.gradle

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,44 @@ description = 'BX-bot Core'
22

33
dependencies {
44

5-
implementation project(':bxbot-domain-objects')
6-
implementation project(':bxbot-services')
7-
implementation project(':bxbot-trading-api')
8-
implementation project(':bxbot-exchange-api')
9-
implementation project(':bxbot-strategy-api')
10-
implementation project(':bxbot-exchanges')
11-
implementation project(':bxbot-strategies')
12-
13-
implementation libraries.spring_boot_starter
14-
implementation libraries.spring_boot_starter_log4j2
15-
implementation libraries.google_guava
16-
17-
implementation libraries.jakarta_mail_api
18-
implementation libraries.jakarta_mail_sun
19-
20-
implementation libraries.springdoc_openapi_ui
21-
22-
testImplementation libraries.powermock_junit
23-
testImplementation libraries.powermock_api_easymock
24-
testImplementation libraries.easymock
25-
testImplementation libraries.junit_vintage_engine
26-
testImplementation libraries.spring_boot_starter_test
27-
testImplementation libraries.awaitility
5+
implementation project(':bxbot-domain-objects')
6+
implementation project(':bxbot-services')
7+
implementation project(':bxbot-trading-api')
8+
implementation project(':bxbot-exchange-api')
9+
implementation project(':bxbot-strategy-api')
10+
implementation project(':bxbot-exchanges')
11+
implementation project(':bxbot-strategies')
12+
13+
implementation libraries.spring_boot_starter
14+
implementation libraries.spring_boot_starter_log4j2
15+
implementation libraries.google_guava
16+
17+
implementation libraries.jakarta_mail_api
18+
implementation libraries.jakarta_mail_sun
19+
20+
implementation libraries.springdoc_openapi_ui
21+
22+
compileOnly libraries.lombok
23+
annotationProcessor libraries.lombok
24+
25+
testImplementation libraries.easymock
26+
testImplementation libraries.spring_boot_starter_test
27+
testImplementation libraries.awaitility
2828
}
2929

3030
jacocoTestCoverageVerification {
31-
violationRules {
32-
rule {
33-
element = 'BUNDLE'
34-
// Ignore classes tested using Powermock. JaCoCo won't/can't instrument them:
35-
// "... right now there is NO WAY TO USE PowerMock with JaCoCo On-the-fly instrumentation."
36-
// See https://github.com/powermock/powermock/wiki/Code-coverage-with-JaCoCo
37-
excludes = [
38-
'com.gazbert.bxbot.BxBot', // Nothing to test
39-
'com.gazbert.bxbot.core.mail.EmailAlerter*' // Powermock tests
40-
]
41-
limit {
42-
counter = 'LINE'
43-
value = 'COVEREDRATIO'
44-
minimum = 0.7
45-
}
46-
}
31+
violationRules {
32+
rule {
33+
element = 'CLASS'
34+
excludes = [
35+
'com.gazbert.bxbot.core.mail.EmailAlerter*', // Needs static mocking of Transport layer
36+
'com.gazbert.bxbot.BxBot', // Nothing to test
37+
]
38+
limit {
39+
counter = 'LINE'
40+
value = 'COVEREDRATIO'
41+
minimum = 0.8
42+
}
4743
}
44+
}
4845
}

bxbot-core/pom.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
<groupId>org.springdoc</groupId>
8383
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
8484
</dependency>
85+
<dependency>
86+
<groupId>org.projectlombok</groupId>
87+
<artifactId>lombok</artifactId>
88+
</dependency>
8589

8690
<!--
8791
Testing dependencies
@@ -111,31 +115,27 @@
111115
<artifactId>awaitility</artifactId>
112116
<scope>test</scope>
113117
</dependency>
114-
<!--
115-
JUnit4 still needed as Powermock doesn't play with JUnit5 in TestTradingEngine.java + TestEmailAlerter.java
116-
See: https://github.com/powermock/powermock/issues/929
117-
-->
118-
<dependency>
119-
<groupId>org.junit.vintage</groupId>
120-
<artifactId>junit-vintage-engine</artifactId>
121-
<scope>test</scope>
122-
</dependency>
123118
</dependencies>
124119

125120
<build>
126121
<defaultGoal>clean install</defaultGoal>
127122
<plugins>
123+
<plugin>
124+
<groupId>org.apache.maven.plugins</groupId>
125+
<artifactId>maven-surefire-plugin</artifactId>
126+
<configuration>
127+
<skipTests>${skip.unit.tests}</skipTests>
128+
<includes>
129+
<include>**/Test*.java</include>
130+
</includes>
131+
</configuration>
132+
</plugin>
128133
<plugin>
129134
<groupId>org.jacoco</groupId>
130135
<artifactId>jacoco-maven-plugin</artifactId>
131136
<configuration>
132-
<!--
133-
Ignore classes tested using Powermock. JaCoCo won't/can't instrument them:
134-
"... right now there is NO WAY TO USE PowerMock with JaCoCo On-the-fly instrumentation."
135-
See https://github.com/powermock/powermock/wiki/Code-coverage-with-JaCoCo
136-
-->
137137
<excludes>
138-
<exclude>**/EmailAlerter*class</exclude> <!-- Powermock tests -->
138+
<exclude>**/EmailAlerter*class</exclude> <!-- Needs static mocking of Transport layer-->
139139
<exclude>**/BxBot.class</exclude> <!-- Nothing to test -->
140140
</excludes>
141141
</configuration>

bxbot-core/src/main/java/com/gazbert/bxbot/core/config/exchange/ExchangeApiConfigBuilder.java

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,18 @@
2727
import com.gazbert.bxbot.domain.exchange.NetworkConfig;
2828
import java.util.List;
2929
import java.util.Map;
30-
import org.apache.logging.log4j.LogManager;
31-
import org.apache.logging.log4j.Logger;
30+
import lombok.extern.log4j.Log4j2;
3231

3332
/**
3433
* Util class for building the Exchange API config.
3534
*
3635
* @author gazbert
3736
*/
37+
@Log4j2
3838
public final class ExchangeApiConfigBuilder {
3939

40-
private static final Logger LOG = LogManager.getLogger();
41-
4240
private ExchangeApiConfigBuilder() {
41+
// noimpl
4342
}
4443

4544
/**
@@ -63,32 +62,29 @@ public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) {
6362
if (nonFatalErrorCodes != null && !nonFatalErrorCodes.isEmpty()) {
6463
exchangeApiNetworkConfig.setNonFatalErrorCodes(nonFatalErrorCodes);
6564
} else {
66-
LOG.info(
67-
() ->
68-
"No (optional) NetworkConfiguration NonFatalErrorCodes have been set for "
69-
+ "Exchange Adapter: "
70-
+ exchangeConfig.getAdapter());
65+
log.info(
66+
"No (optional) NetworkConfiguration NonFatalErrorCodes have been set for "
67+
+ "Exchange Adapter: "
68+
+ exchangeConfig.getAdapter());
7169
}
7270

7371
final List<String> nonFatalErrorMessages = networkConfig.getNonFatalErrorMessages();
7472
if (nonFatalErrorMessages != null && !nonFatalErrorMessages.isEmpty()) {
7573
exchangeApiNetworkConfig.setNonFatalErrorMessages(nonFatalErrorMessages);
7674
} else {
77-
LOG.info(
78-
() ->
79-
"No (optional) NetworkConfiguration NonFatalErrorMessages have been set for "
80-
+ "Exchange Adapter: "
81-
+ exchangeConfig.getAdapter());
75+
log.info(
76+
"No (optional) NetworkConfiguration NonFatalErrorMessages have been set for "
77+
+ "Exchange Adapter: "
78+
+ exchangeConfig.getAdapter());
8279
}
8380

8481
exchangeApiConfig.setNetworkConfig(exchangeApiNetworkConfig);
85-
LOG.info(() -> "NetworkConfiguration has been set: " + exchangeApiNetworkConfig);
82+
log.info("NetworkConfiguration has been set: " + exchangeApiNetworkConfig);
8683

8784
} else {
88-
LOG.info(
89-
() ->
90-
"No (optional) NetworkConfiguration has been set for Exchange Adapter: "
91-
+ exchangeConfig.getAdapter());
85+
log.info(
86+
"No (optional) NetworkConfiguration has been set for Exchange Adapter: "
87+
+ exchangeConfig.getAdapter());
9288
}
9389

9490
final Map<String, String> authenticationConfig = exchangeConfig.getAuthenticationConfig();
@@ -99,25 +95,22 @@ public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) {
9995
exchangeApiConfig.setAuthenticationConfig(exchangeApiAuthenticationConfig);
10096

10197
// We don't log the creds!
102-
LOG.info(() -> "AuthenticationConfiguration has been set successfully.");
98+
log.info("AuthenticationConfiguration has been set successfully.");
10399

104100
} else {
105-
LOG.info(
106-
() ->
107-
"No (optional) AuthenticationConfiguration has been set for Exchange Adapter: "
108-
+ exchangeConfig.getAdapter());
101+
log.info(
102+
"No (optional) AuthenticationConfiguration has been set for Exchange Adapter: "
103+
+ exchangeConfig.getAdapter());
109104
}
110105

111106
final Map<String, String> otherConfig = exchangeConfig.getOtherConfig();
112107
if (otherConfig != null) {
113108
final OtherConfigImpl exchangeApiOtherConfig = new OtherConfigImpl();
114109
exchangeApiOtherConfig.setItems(otherConfig);
115110
exchangeApiConfig.setOtherConfig(exchangeApiOtherConfig);
116-
LOG.info(() -> "Other Exchange Adapter config has been set: " + exchangeApiOtherConfig);
111+
log.info("Other Exchange Adapter config has been set: " + exchangeApiOtherConfig);
117112
} else {
118-
LOG.info(
119-
() ->
120-
"No Other config has been set for Exchange Adapter: " + exchangeConfig.getAdapter());
113+
log.info("No Other config has been set for Exchange Adapter: " + exchangeConfig.getAdapter());
121114
}
122115

123116
return exchangeApiConfig;

bxbot-core/src/main/java/com/gazbert/bxbot/core/config/exchange/NetworkConfigImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public List<Integer> getNonFatalErrorCodes() {
6565
}
6666

6767
/**
68-
* Sets the non fatal error codes.
68+
* Sets the non-fatal error codes.
6969
*
7070
* @param nonFatalErrorCodes the non fatal error codes.
7171
*/
@@ -81,7 +81,7 @@ public List<String> getNonFatalErrorMessages() {
8181
/**
8282
* Sets the non fatal error messages.
8383
*
84-
* @param nonFatalErrorMessages the non fatal error messages.
84+
* @param nonFatalErrorMessages the non-fatal error messages.
8585
*/
8686
public void setNonFatalErrorMessages(List<String> nonFatalErrorMessages) {
8787
this.nonFatalErrorMessages = nonFatalErrorMessages;

0 commit comments

Comments
 (0)