Compare commits
82 commits
Author | SHA1 | Date | |
---|---|---|---|
49b0299463 | |||
70e914193d | |||
c688c2445e | |||
9077a75343 | |||
624d93baa3 | |||
34310db95a | |||
29ad34034c | |||
d3f364bf10 | |||
217404b506 | |||
1c5ae516d7 | |||
27070dc3d9 | |||
686174b9cb | |||
926c20e8b2 | |||
ac329058d3 | |||
c49771796e | |||
dbc90b0daa | |||
b5b9a81e13 | |||
f3a060bfab | |||
b4ae856094 | |||
6eb420bdc2 | |||
435985f3a2 | |||
175a1fa2b3 | |||
c350e0742d | |||
4fbf57b83d | |||
cd9af7444b | |||
d551c8b703 | |||
ed29bc6afb | |||
99d7bdf0e0 | |||
78f483bf42 | |||
727eab3de7 | |||
5d94921a82 | |||
d13626fffe | |||
814cf51b7c | |||
7de44c0af4 | |||
925338034b | |||
bc8f5d7670 | |||
e0ed72d8a2 | |||
325ef292bf | |||
1812e7b234 | |||
5bc76f4159 | |||
1163921717 | |||
5f88cec7c4 | |||
88ae027103 | |||
528947f9b1 | |||
6946413549 | |||
bd36eb3320 | |||
79b16e1989 | |||
c2e1c5e193 | |||
e0b7308960 | |||
ee2f4f3e51 | |||
3ba6479e7e | |||
705a8d9b12 | |||
cd4d86969f | |||
1e016de5fb | |||
21b4af20d4 | |||
b21ae45410 | |||
361fdaf815 | |||
dbad341d19 | |||
8267c2ad57 | |||
48e29528a1 | |||
da5aea6b26 | |||
5ec9020a9d | |||
8b0d1bc089 | |||
5776f804c2 | |||
c60da7147c | |||
257cec56b4 | |||
7a658c20e0 | |||
7fb928fbc6 | |||
f5386a7a2b | |||
ff97152646 | |||
a402dc91c0 | |||
7594fcd60f | |||
7c56f1e9b4 | |||
c3a0a26d88 | |||
2c271d9116 | |||
eefd4ee615 | |||
1906a24343 | |||
416a52ec18 | |||
cb8bf44768 | |||
ee74cf0cc4 | |||
656740b748 | |||
9c0cba7906 |
85 changed files with 1643 additions and 932 deletions
|
@ -1,53 +1,62 @@
|
||||||
version: 2
|
version: 2.1
|
||||||
|
|
||||||
|
orbs:
|
||||||
|
sdkman: joshdholtz/sdkman@0.2.0
|
||||||
|
|
||||||
defaults: &defaults
|
defaults: &defaults
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
environment:
|
environment:
|
||||||
JVM_OPTS: -Xmx3200m
|
JVM_OPTS: -Xmx3200m
|
||||||
TERM: dumb
|
TERM: dumb
|
||||||
CI: true
|
CI_NAME: "CircleCI"
|
||||||
|
|
||||||
|
commands:
|
||||||
|
build_and_test:
|
||||||
|
parameters:
|
||||||
|
reports-dir:
|
||||||
|
type: string
|
||||||
|
default: "build/reports/test_results"
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- sdkman/setup-sdkman
|
||||||
|
- sdkman/sdkman-install:
|
||||||
|
candidate: kotlin
|
||||||
|
version: 2.1.10
|
||||||
|
- run:
|
||||||
|
name: Download dependencies
|
||||||
|
command: ./bld download
|
||||||
|
- run:
|
||||||
|
name: Compile source
|
||||||
|
command: ./bld compile
|
||||||
|
- run:
|
||||||
|
name: Run tests
|
||||||
|
command: ./bld jacoco -reports-dir=<< parameters.reports-dir >>
|
||||||
|
- store_test_results:
|
||||||
|
path: << parameters.reports-dir >>
|
||||||
|
- store_artifacts:
|
||||||
|
path: build/reports/jacoco/test/html
|
||||||
|
|
||||||
defaults_gradle: &defaults_gradle
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- gradle-dependencies-{{ checksum "build.gradle.kts" }}
|
|
||||||
# fallback to using the latest cache if no exact match is found
|
|
||||||
- gradle-dependencies-
|
|
||||||
- run:
|
|
||||||
name: Gradle Dependencies
|
|
||||||
command: ./gradlew dependencies
|
|
||||||
- save_cache:
|
|
||||||
paths: ~/.m2
|
|
||||||
key: gradle-dependencies-{{ checksum "build.gradle.kts" }}
|
|
||||||
- run:
|
|
||||||
name: Run All Checks
|
|
||||||
command: ./gradlew check
|
|
||||||
- store_artifacts:
|
|
||||||
path: build/reports/
|
|
||||||
destination: reports
|
|
||||||
- store_test_results:
|
|
||||||
path: build/reports/
|
|
||||||
jobs:
|
jobs:
|
||||||
build_gradle_jdk18:
|
bld_jdk17:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/openjdk:18.0
|
- image: cimg/openjdk:17.0
|
||||||
|
|
||||||
<<: *defaults_gradle
|
steps:
|
||||||
|
- build_and_test
|
||||||
|
|
||||||
build_gradle_jdk11:
|
bld_jdk21:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/openjdk:11.0
|
- image: cimg/openjdk:21.0
|
||||||
|
|
||||||
<<: *defaults_gradle
|
steps:
|
||||||
|
- build_and_test
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
bld:
|
||||||
gradle:
|
|
||||||
jobs:
|
jobs:
|
||||||
- build_gradle_jdk11
|
- bld_jdk17
|
||||||
- build_gradle_jdk18
|
- bld_jdk21
|
||||||
|
|
68
.github/workflows/bld.yml
vendored
Normal file
68
.github/workflows/bld.yml
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
name: bld-ci
|
||||||
|
|
||||||
|
on: [ push, pull_request, workflow_dispatch ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
COVERAGE_JDK: "21"
|
||||||
|
COVERAGE_KOTLIN: "2.1.20"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-bld-project:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
java-version: [ 17, 21, 24 ]
|
||||||
|
kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ]
|
||||||
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout source repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up JDK ${{ matrix.java-version }} with Kotlin ${{ matrix.kotlin-version }}
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: "zulu"
|
||||||
|
java-version: ${{ matrix.java-version }}
|
||||||
|
|
||||||
|
- name: Download dependencies [bld example]
|
||||||
|
working-directory: examples/bld
|
||||||
|
run: ./bld download
|
||||||
|
|
||||||
|
- name: Compile and run examples [bld example]
|
||||||
|
working-directory: examples/bld
|
||||||
|
run: |
|
||||||
|
./bld compile
|
||||||
|
./bld run
|
||||||
|
./bld run-java
|
||||||
|
|
||||||
|
- name: Run examples [gradle example]
|
||||||
|
working-directory: examples/gradle
|
||||||
|
run: |
|
||||||
|
./gradlew run
|
||||||
|
./gradlew runJava
|
||||||
|
|
||||||
|
- name: Download dependencies
|
||||||
|
run: ./bld download
|
||||||
|
|
||||||
|
- name: Compile source
|
||||||
|
run: ./bld compile
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: ./bld jacoco
|
||||||
|
|
||||||
|
- name: Remove pom.xml
|
||||||
|
if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN
|
||||||
|
&& matrix.os == 'ubuntu-latest'
|
||||||
|
run: rm -rf pom.xml
|
||||||
|
|
||||||
|
- name: SonarCloud Scan
|
||||||
|
uses: sonarsource/sonarcloud-github-action@master
|
||||||
|
if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN
|
||||||
|
&& matrix.os == 'ubuntu-latest'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
61
.github/workflows/gradle.yml
vendored
61
.github/workflows/gradle.yml
vendored
|
@ -1,61 +0,0 @@
|
||||||
name: gradle-ci
|
|
||||||
|
|
||||||
on: [push, pull_request, workflow_dispatch]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
env:
|
|
||||||
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-XX:MaxMetaspaceSize=512m"
|
|
||||||
SONAR_JDK: "11"
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
java-version: [ 11, 18 ]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up JDK ${{ matrix.java-version }}
|
|
||||||
uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: ${{ matrix.java-version }}
|
|
||||||
|
|
||||||
- name: Grant execute permission for gradlew
|
|
||||||
run: chmod +x gradlew
|
|
||||||
|
|
||||||
- name: Cache SonarCloud packages
|
|
||||||
if: matrix.java-version == env.SONAR_JDK
|
|
||||||
uses: actions/cache@v1
|
|
||||||
with:
|
|
||||||
path: ~/.sonar/cache
|
|
||||||
key: ${{ runner.os }}-sonar
|
|
||||||
restore-keys: ${{ runner.os }}-sonar
|
|
||||||
|
|
||||||
- name: Cache Gradle packages
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
key: ${{ runner.os }}-gradle-${{ matrix.java-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-gradle-${{ matrix.java-version }}-
|
|
||||||
|
|
||||||
- name: Test with Gradle
|
|
||||||
run: ./gradlew build check --stacktrace
|
|
||||||
|
|
||||||
- name: SonarCloud
|
|
||||||
if: success() && matrix.java-version == env.SONAR_JDK
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
||||||
run: ./gradlew sonarqube
|
|
||||||
|
|
||||||
- name: Cleanup Gradle Cache
|
|
||||||
run: |
|
|
||||||
rm -f ~/.gradle/caches/modules-2/modules-2.lock
|
|
||||||
rm -f ~/.gradle/caches/modules-2/gc.properties
|
|
136
.gitignore
vendored
136
.gitignore
vendored
|
@ -1,85 +1,57 @@
|
||||||
!.vscode/extensions.json
|
|
||||||
!.vscode/launch.json
|
|
||||||
!.vscode/settings.json
|
|
||||||
!.vscode/tasks.json
|
|
||||||
*.class
|
|
||||||
*.code-workspace
|
|
||||||
*.ctxt
|
|
||||||
*.iws
|
|
||||||
*.log
|
|
||||||
*.nar
|
|
||||||
*.rar
|
|
||||||
*.sublime-*
|
|
||||||
*.tar.gz
|
|
||||||
*.zip
|
|
||||||
.DS_Store
|
|
||||||
.classpath
|
|
||||||
.gradle
|
.gradle
|
||||||
.history
|
.DS_Store
|
||||||
.kobalt
|
build
|
||||||
.mtj.tmp/
|
lib/bld/**
|
||||||
.mvn/timing.properties
|
!lib/bld/bld-wrapper.jar
|
||||||
.mvn/wrapper/maven-wrapper.jar
|
!lib/bld/bld-wrapper.properties
|
||||||
.nb-gradle
|
lib/compile/
|
||||||
.project
|
lib/runtime/
|
||||||
.scannerwork
|
lib/standalone/
|
||||||
.settings
|
lib/test/
|
||||||
.vscode/*
|
|
||||||
/**/.idea/$CACHE_FILE$
|
# IDEA ignores
|
||||||
/**/.idea/$PRODUCT_WORKSPACE_FILE$
|
|
||||||
/**/.idea/**/caches/build_file_checksums.ser
|
# User-specific
|
||||||
/**/.idea/**/contentModel.xml
|
.idea/**/workspace.xml
|
||||||
/**/.idea/**/dataSources.ids
|
.idea/**/tasks.xml
|
||||||
/**/.idea/**/dataSources.local.xml
|
.idea/**/usage.statistics.xml
|
||||||
/**/.idea/**/dataSources/
|
.idea/**/dictionaries
|
||||||
/**/.idea/**/dbnavigator.xml
|
.idea/**/shelf
|
||||||
/**/.idea/**/dictionaries
|
|
||||||
/**/.idea/**/dynamic.xml
|
# AWS User-specific
|
||||||
/**/.idea/**/gradle.xml
|
.idea/**/aws.xml
|
||||||
/**/.idea/**/httpRequests
|
|
||||||
/**/.idea/**/libraries
|
# Generated files
|
||||||
/**/.idea/**/mongoSettings.xml
|
.idea/**/contentModel.xml
|
||||||
/**/.idea/**/replstate.xml
|
|
||||||
/**/.idea/**/shelf
|
# Sensitive or high-churn files
|
||||||
/**/.idea/**/shelf/
|
.idea/**/dataSources/
|
||||||
/**/.idea/**/sqlDataSources.xml
|
.idea/**/dataSources.ids
|
||||||
/**/.idea/**/tasks.xml
|
.idea/**/dataSources.local.xml
|
||||||
/**/.idea/**/uiDesigner.xml
|
.idea/**/sqlDataSources.xml
|
||||||
/**/.idea/**/usage.statistics.xml
|
.idea/**/dynamic.xml
|
||||||
/**/.idea/**/workspace.xml
|
.idea/**/uiDesigner.xml
|
||||||
/**/.idea/sonarlint*
|
.idea/**/dbnavigator.xml
|
||||||
/**/.idea_modules/
|
|
||||||
Thumbs.db
|
# Gradle
|
||||||
__pycache__
|
.idea/**/gradle.xml
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
atlassian-ide-plugin.xml
|
atlassian-ide-plugin.xml
|
||||||
bin/
|
|
||||||
build/
|
# Cursive Clojure plugin
|
||||||
cmake-build-*/
|
.idea/replstate.xml
|
||||||
com_crashlytics_export_strings.xml
|
|
||||||
crashlytics-build.properties
|
# SonarLint plugin
|
||||||
crashlytics.properties
|
.idea/sonarlint/
|
||||||
dependency-reduced-pom.xml
|
|
||||||
deploy/
|
# Editor-based Rest Client
|
||||||
dist/
|
.idea/httpRequests
|
||||||
ehthumbs.db
|
|
||||||
fabric.properties
|
|
||||||
gen/
|
|
||||||
gradle.properties
|
|
||||||
hs_err_pid*
|
|
||||||
kobaltBuild
|
|
||||||
kobaltw*-test
|
|
||||||
lib/kotlin*
|
|
||||||
libs/
|
|
||||||
local.properties
|
local.properties
|
||||||
out/
|
|
||||||
pom.xml.asc
|
|
||||||
pom.xml.next
|
|
||||||
pom.xml.releaseBackup
|
|
||||||
pom.xml.tag
|
|
||||||
pom.xml.versionsBackup
|
|
||||||
proguard-project.txt
|
|
||||||
project.properties
|
|
||||||
release.properties
|
|
||||||
target/
|
|
||||||
test-output
|
|
||||||
venv
|
|
||||||
|
|
|
@ -1,31 +1,24 @@
|
||||||
image: gradle:7-jdk11
|
image: fedora:latest
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
CI_NAME: "GitLab CI"
|
||||||
|
|
||||||
before_script:
|
|
||||||
- export GRADLE_USER_HOME=`pwd`/.gradle
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
|
||||||
- test
|
- test
|
||||||
|
|
||||||
build:
|
before_script:
|
||||||
stage: build
|
- dnf -qy update && dnf -y install zip
|
||||||
script: gradle --build-cache assemble
|
- curl -s "https://get.sdkman.io" | bash
|
||||||
cache:
|
- echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config
|
||||||
key: "$CI_COMMIT_REF_NAME"
|
- echo sdkman_auto_selfupdate=true >> $HOME/.sdkman/etc/config
|
||||||
policy: push
|
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||||
paths:
|
- sdk install java
|
||||||
- build
|
- sdk install kotlin
|
||||||
- .gradle
|
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
script: gradle check
|
script:
|
||||||
cache:
|
- ./bld download
|
||||||
key: "$CI_COMMIT_REF_NAME"
|
- ./bld compile
|
||||||
policy: pull
|
- ./bld test
|
||||||
paths:
|
|
||||||
- build
|
|
||||||
- .gradle
|
|
||||||
|
|
32
.idea/app.iml
generated
Normal file
32
.idea/app.iml
generated
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<output url="file://$MODULE_DIR$/build/main" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/test" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" relativeOutputPath="resources" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin/net/thauvin/erik/crypto" type="kotlin-source" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin/net/thauvin/erik/crypto" type="kotlin-test" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module-library" scope="RUNTIME">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$MODULE_DIR$/src/main/resources/templates" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="library" name="compile" level="project" />
|
||||||
|
<orderEntry type="library" scope="RUNTIME" name="runtime" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="test" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
14
.idea/bld.iml
generated
Normal file
14
.idea/bld.iml
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<output url="file://$MODULE_DIR$/build/bld" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/bld" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$/src/bld">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/bld/java" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="bld" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/bld.xml
generated
Normal file
6
.idea/bld.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="BldConfiguration">
|
||||||
|
<events />
|
||||||
|
</component>
|
||||||
|
</project>
|
2
.idea/copyright/Erik_s_Copyright_Notice.xml
generated
2
.idea/copyright/Erik_s_Copyright_Notice.xml
generated
|
@ -1,6 +1,6 @@
|
||||||
<component name="CopyrightManager">
|
<component name="CopyrightManager">
|
||||||
<copyright>
|
<copyright>
|
||||||
<option name="notice" value="&#36;file.fileName Copyright (c) 2021-&#36;today.year, Erik C. Thauvin (erik@thauvin.net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." />
|
<option name="notice" value="&#36;file.fileName Copyright 2021-&#36;today.year Erik C. Thauvin (erik@thauvin.net) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." />
|
||||||
<option name="myName" value="Erik's Copyright Notice" />
|
<option name="myName" value="Erik's Copyright Notice" />
|
||||||
</copyright>
|
</copyright>
|
||||||
</component>
|
</component>
|
37
.idea/inspectionProfiles/Project_Default.xml
generated
37
.idea/inspectionProfiles/Project_Default.xml
generated
|
@ -32,12 +32,49 @@
|
||||||
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||||
<option name="myAdditionalJavadocTags" value="created" />
|
<option name="myAdditionalJavadocTags" value="created" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
|
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ADDITIONAL_TAGS" value="created" />
|
||||||
|
</inspection_tool>
|
||||||
<inspection_tool class="LocalCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="LocalCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
<option name="REPORT_VARIABLES" value="true" />
|
<option name="REPORT_VARIABLES" value="true" />
|
||||||
<option name="REPORT_PARAMETERS" value="true" />
|
<option name="REPORT_PARAMETERS" value="true" />
|
||||||
<option name="REPORT_CATCH_PARAMETERS" value="false" />
|
<option name="REPORT_CATCH_PARAMETERS" value="false" />
|
||||||
<option name="REPORT_IMPLICIT_FINALS" value="false" />
|
<option name="REPORT_IMPLICIT_FINALS" value="false" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
|
<inspection_tool class="MissingJavadoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="PACKAGE_SETTINGS">
|
||||||
|
<Options>
|
||||||
|
<option name="ENABLED" value="false" />
|
||||||
|
</Options>
|
||||||
|
</option>
|
||||||
|
<option name="MODULE_SETTINGS">
|
||||||
|
<Options>
|
||||||
|
<option name="ENABLED" value="false" />
|
||||||
|
</Options>
|
||||||
|
</option>
|
||||||
|
<option name="TOP_LEVEL_CLASS_SETTINGS">
|
||||||
|
<Options>
|
||||||
|
<option name="ENABLED" value="false" />
|
||||||
|
</Options>
|
||||||
|
</option>
|
||||||
|
<option name="INNER_CLASS_SETTINGS">
|
||||||
|
<Options>
|
||||||
|
<option name="ENABLED" value="false" />
|
||||||
|
</Options>
|
||||||
|
</option>
|
||||||
|
<option name="METHOD_SETTINGS">
|
||||||
|
<Options>
|
||||||
|
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||||
|
<option name="ENABLED" value="false" />
|
||||||
|
</Options>
|
||||||
|
</option>
|
||||||
|
<option name="FIELD_SETTINGS">
|
||||||
|
<Options>
|
||||||
|
<option name="ENABLED" value="false" />
|
||||||
|
</Options>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
<inspection_tool class="RedundantExplicitVariableType" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
<inspection_tool class="RedundantExplicitVariableType" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="UsePropertyAccessSyntax" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
204
.idea/intellij-javadocs-4.0.1.xml
generated
Normal file
204
.idea/intellij-javadocs-4.0.1.xml
generated
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaDocConfiguration">
|
||||||
|
<GENERAL>
|
||||||
|
<MODE>UPDATE</MODE>
|
||||||
|
<OVERRIDDEN_METHODS>false</OVERRIDDEN_METHODS>
|
||||||
|
<SPLITTED_CLASS_NAME>true</SPLITTED_CLASS_NAME>
|
||||||
|
<LEVELS>
|
||||||
|
<LEVEL>TYPE</LEVEL>
|
||||||
|
<LEVEL>METHOD</LEVEL>
|
||||||
|
<LEVEL>FIELD</LEVEL>
|
||||||
|
</LEVELS>
|
||||||
|
<VISIBILITIES>
|
||||||
|
<VISIBILITY>DEFAULT</VISIBILITY>
|
||||||
|
<VISIBILITY>PUBLIC</VISIBILITY>
|
||||||
|
<VISIBILITY>PROTECTED</VISIBILITY>
|
||||||
|
</VISIBILITIES>
|
||||||
|
</GENERAL>
|
||||||
|
<TEMPLATES>
|
||||||
|
<CLASSES>
|
||||||
|
<CLASS>
|
||||||
|
<KEY>^.*(public|protected|private)*.+interface\s+\w+.*</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* The interface ${name}.\n
|
||||||
|
<#if element.typeParameters?has_content> * \n
|
||||||
|
</#if>
|
||||||
|
<#list element.typeParameters as typeParameter>
|
||||||
|
* @param <${typeParameter.name}> the type parameter\n
|
||||||
|
</#list>
|
||||||
|
*/</VALUE>
|
||||||
|
</CLASS>
|
||||||
|
<CLASS>
|
||||||
|
<KEY>^.*(public|protected|private)*.+enum\s+\w+.*</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* The enum ${name}.\n
|
||||||
|
*/</VALUE>
|
||||||
|
</CLASS>
|
||||||
|
<CLASS>
|
||||||
|
<KEY>^.*(public|protected|private)*.+class\s+\w+.*</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* The type ${name}.\n
|
||||||
|
<#if element.typeParameters?has_content> * \n
|
||||||
|
</#if>
|
||||||
|
<#list element.typeParameters as typeParameter>
|
||||||
|
* @param <${typeParameter.name}> the type parameter\n
|
||||||
|
</#list>
|
||||||
|
*/</VALUE>
|
||||||
|
</CLASS>
|
||||||
|
<CLASS>
|
||||||
|
<KEY>.+</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* The type ${name}.\n
|
||||||
|
*/</VALUE>
|
||||||
|
</CLASS>
|
||||||
|
</CLASSES>
|
||||||
|
<CONSTRUCTORS>
|
||||||
|
<CONSTRUCTOR>
|
||||||
|
<KEY>.+</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* Instantiates a new ${name}.\n
|
||||||
|
<#if element.parameterList.parameters?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
<#list element.parameterList.parameters as parameter>
|
||||||
|
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
|
||||||
|
</#list>
|
||||||
|
<#if element.throwsList.referenceElements?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
<#list element.throwsList.referenceElements as exception>
|
||||||
|
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
|
||||||
|
</#list>
|
||||||
|
*/</VALUE>
|
||||||
|
</CONSTRUCTOR>
|
||||||
|
</CONSTRUCTORS>
|
||||||
|
<METHODS>
|
||||||
|
<METHOD>
|
||||||
|
<KEY>^.*(public|protected|private)*\s*.*(\w(\s*<.+>)*)+\s+get\w+\s*\(.*\).+</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* Gets ${partName}.\n
|
||||||
|
<#if element.typeParameters?has_content> * \n
|
||||||
|
</#if>
|
||||||
|
<#list element.typeParameters as typeParameter>
|
||||||
|
* @param <${typeParameter.name}> the type parameter\n
|
||||||
|
</#list>
|
||||||
|
<#if element.parameterList.parameters?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
<#list element.parameterList.parameters as parameter>
|
||||||
|
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
|
||||||
|
</#list>
|
||||||
|
<#if isNotVoid>
|
||||||
|
*\n
|
||||||
|
* @return the ${partName}\n
|
||||||
|
</#if>
|
||||||
|
<#if element.throwsList.referenceElements?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
<#list element.throwsList.referenceElements as exception>
|
||||||
|
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
|
||||||
|
</#list>
|
||||||
|
*/</VALUE>
|
||||||
|
</METHOD>
|
||||||
|
<METHOD>
|
||||||
|
<KEY>^.*(public|protected|private)*\s*.*(void|\w(\s*<.+>)*)+\s+set\w+\s*\(.*\).+</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* Sets ${partName}.\n
|
||||||
|
<#if element.typeParameters?has_content> * \n
|
||||||
|
</#if>
|
||||||
|
<#list element.typeParameters as typeParameter>
|
||||||
|
* @param <${typeParameter.name}> the type parameter\n
|
||||||
|
</#list>
|
||||||
|
<#if element.parameterList.parameters?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
<#list element.parameterList.parameters as parameter>
|
||||||
|
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
|
||||||
|
</#list>
|
||||||
|
<#if isNotVoid>
|
||||||
|
*\n
|
||||||
|
* @return the ${partName}\n
|
||||||
|
</#if>
|
||||||
|
<#if element.throwsList.referenceElements?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
<#list element.throwsList.referenceElements as exception>
|
||||||
|
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
|
||||||
|
</#list>
|
||||||
|
*/</VALUE>
|
||||||
|
</METHOD>
|
||||||
|
<METHOD>
|
||||||
|
<KEY>^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* The entry point of application.\n
|
||||||
|
|
||||||
|
<#if element.parameterList.parameters?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
* @param ${element.parameterList.parameters[0].name} the input arguments\n
|
||||||
|
<#if element.throwsList.referenceElements?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
<#list element.throwsList.referenceElements as exception>
|
||||||
|
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
|
||||||
|
</#list>
|
||||||
|
*/</VALUE>
|
||||||
|
</METHOD>
|
||||||
|
<METHOD>
|
||||||
|
<KEY>.+</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* ${name}<#if isNotVoid> ${return}</#if>.\n
|
||||||
|
<#if element.typeParameters?has_content> * \n
|
||||||
|
</#if>
|
||||||
|
<#list element.typeParameters as typeParameter>
|
||||||
|
* @param <${typeParameter.name}> the type parameter\n
|
||||||
|
</#list>
|
||||||
|
<#if element.parameterList.parameters?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
<#list element.parameterList.parameters as parameter>
|
||||||
|
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
|
||||||
|
</#list>
|
||||||
|
<#if isNotVoid>
|
||||||
|
*\n
|
||||||
|
* @return the ${return}\n
|
||||||
|
</#if>
|
||||||
|
<#if element.throwsList.referenceElements?has_content>
|
||||||
|
*\n
|
||||||
|
</#if>
|
||||||
|
<#list element.throwsList.referenceElements as exception>
|
||||||
|
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
|
||||||
|
</#list>
|
||||||
|
*/</VALUE>
|
||||||
|
</METHOD>
|
||||||
|
</METHODS>
|
||||||
|
<FIELDS>
|
||||||
|
<FIELD>
|
||||||
|
<KEY>^.*(public|protected|private)*.+static.*(\w\s\w)+.+</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
* The constant ${element.getName()}.\n
|
||||||
|
*/</VALUE>
|
||||||
|
</FIELD>
|
||||||
|
<FIELD>
|
||||||
|
<KEY>^.*(public|protected|private)*.*(\w\s\w)+.+</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
<#if element.parent.isInterface()>
|
||||||
|
* The constant ${element.getName()}.\n
|
||||||
|
<#else>
|
||||||
|
* The ${name}.\n
|
||||||
|
</#if> */</VALUE>
|
||||||
|
</FIELD>
|
||||||
|
<FIELD>
|
||||||
|
<KEY>.+</KEY>
|
||||||
|
<VALUE>/**\n
|
||||||
|
<#if element.parent.isEnum()>
|
||||||
|
*${name} ${typeName}.\n
|
||||||
|
<#else>
|
||||||
|
* The ${name}.\n
|
||||||
|
</#if>*/</VALUE>
|
||||||
|
</FIELD>
|
||||||
|
</FIELDS>
|
||||||
|
</TEMPLATES>
|
||||||
|
</component>
|
||||||
|
</project>
|
12
.idea/kotlinc.xml
generated
12
.idea/kotlinc.xml
generated
|
@ -1,6 +1,16 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="Kotlin2JsCompilerArguments">
|
||||||
|
<option name="moduleKind" value="plain" />
|
||||||
|
</component>
|
||||||
|
<component name="Kotlin2JvmCompilerArguments">
|
||||||
|
<option name="jvmTarget" value="1.8" />
|
||||||
|
</component>
|
||||||
|
<component name="KotlinCommonCompilerArguments">
|
||||||
|
<option name="apiVersion" value="2.0" />
|
||||||
|
<option name="languageVersion" value="2.0" />
|
||||||
|
</component>
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="1.7.10" />
|
<option name="version" value="2.0.0" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
18
.idea/libraries/bld.xml
generated
Normal file
18
.idea/libraries/bld.xml
generated
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="bld">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
<excluded>
|
||||||
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
</excluded>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/compile.xml
generated
Normal file
13
.idea/libraries/compile.xml
generated
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="compile">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||||
|
</SOURCES>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
14
.idea/libraries/runtime.xml
generated
Normal file
14
.idea/libraries/runtime.xml
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="runtime">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
||||||
|
<root url="file://$PROJECT_DIR$/src/main/resources" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
||||||
|
</SOURCES>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
14
.idea/libraries/test.xml
generated
Normal file
14
.idea/libraries/test.xml
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="test">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||||
|
<root url="file://$PROJECT_DIR$/src/test/resources" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||||
|
</SOURCES>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/misc.xml
generated
13
.idea/misc.xml
generated
|
@ -1,8 +1,17 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<pattern value="net.thauvin.erik.crypto.CryptoPriceBuild" />
|
||||||
|
<pattern value="net.thauvin.erik.crypto.CryptoPriceBuild" method="jacoco" />
|
||||||
|
<pattern value="net.thauvin.erik.crypto.CryptoPriceBuild" method="detekt" />
|
||||||
|
<pattern value="net.thauvin.erik.crypto.CryptoPriceBuild" method="detektBaseline" />
|
||||||
|
<pattern value="net.thauvin.erik.crypto.CryptoPrice.Companion" method="main" />
|
||||||
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$" />
|
<file type="web" url="file://$PROJECT_DIR$/examples/gradle" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="18" project-jdk-type="JavaSDK" />
|
|
||||||
</project>
|
</project>
|
9
.idea/modules.xml
generated
Normal file
9
.idea/modules.xml
generated
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -1,5 +1,4 @@
|
||||||
Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
|
Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
65
README.md
65
README.md
|
@ -1,10 +1,17 @@
|
||||||
[](https://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/cryptoprice/releases/latest) [](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22cryptoprice%22) <!-- [](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/cryptoprice/) -->
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
||||||
|
[](https://kotlinlang.org/)
|
||||||
|
[](https://rife2.com/bld)
|
||||||
|
[](https://github.com/ethauvin/cryptoprice/releases/latest)
|
||||||
|
[](https://central.sonatype.com/artifact/net.thauvin.erik/cryptoprice)
|
||||||
|
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/cryptoprice/)
|
||||||
|
|
||||||
[](https://snyk.io/test/github/ethauvin/cryptoprice?targetFile=pom.xml) [](https://sonarcloud.io/dashboard?id=ethauvin_cryptoprice) [](https://github.com/ethauvin/cryptoprice/actions/workflows/gradle.yml) [](https://circleci.com/gh/ethauvin/cryptoprice/tree/master)
|
[](https://sonarcloud.io/dashboard?id=ethauvin_cryptoprice)
|
||||||
|
[](https://github.com/ethauvin/cryptoprice/actions/workflows/bld.yml)
|
||||||
|
[](https://circleci.com/gh/ethauvin/cryptoprice/tree/master)
|
||||||
|
|
||||||
# Retrieve cryptocurrencies current (buy, sell or spot) prices
|
# Retrieve cryptocurrencies current (buy, sell or spot) prices
|
||||||
|
|
||||||
A simple Kotlin/Java/Android implementation of the prices [Coinbase Public API](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices).
|
A simple implementation of the prices [Coinbase Public API](https://docs.cdp.coinbase.com/coinbase-app/docs/api-prices).
|
||||||
|
|
||||||
## Examples (TL;DR)
|
## Examples (TL;DR)
|
||||||
|
|
||||||
|
@ -23,19 +30,36 @@ val eth = buyPrice("LTC", "GBP") // Litecoin in Pound sterling
|
||||||
println(eth.amount)
|
println(eth.amount)
|
||||||
|
|
||||||
```
|
```
|
||||||
- View [Kotlin](https://github.com/ethauvin/cryptoprice/blob/master/examples/src/main/kotlin/com/example/CryptoPriceExample.kt) or [Java](https://github.com/ethauvin/cryptoprice/blob/master/examples/src/main/java/com/example/CryptoPriceSample.java) Examples.
|
- View [bld](https://github.com/ethauvin/cryptoprice/blob/master/examples/bld) or [Gradle](https://github.com/ethauvin/cryptoprice/blob/master/examples/gradle) Examples.
|
||||||
|
|
||||||
|
### bld
|
||||||
|
|
||||||
|
To use with [bld](https://rife2.com/bld), include the following dependency in your [build](https://github.com/ethauvin/cryptoprice/blob/master/examples/bld/src/bld/java/com/example/CryptoPriceExampleBuild.java) file:
|
||||||
|
|
||||||
|
```java
|
||||||
|
repositories = List.of(MAVEN_CENTRAL);
|
||||||
|
|
||||||
|
scope(compile)
|
||||||
|
.include(dependency("net.thauvin.erik:cryptoprice:1.0.2"));
|
||||||
|
```
|
||||||
|
Be sure to use the [bld Kotlin extension](https://github.com/rife2/bld-kotlin) in your project.
|
||||||
|
|
||||||
### Gradle, Maven, etc.
|
### Gradle, Maven, etc.
|
||||||
|
|
||||||
To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/cryptoprice/blob/master/examples/build.gradle.kts) file:
|
To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/cryptoprice/blob/master/examples/gradle/build.gradle.kts) file:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } // only needed for SNAPSHOT
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.thauvin.erik:cryptoprice:1.0.0")
|
implementation("net.thauvin.erik:cryptoprice:1.0.2")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22cryptoprice%22).
|
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/cryptoprice).
|
||||||
|
|
||||||
### Prices
|
### Prices
|
||||||
|
|
||||||
|
@ -70,7 +94,7 @@ A `CryptoPrice` object is returned defined as follows:
|
||||||
```kotlin
|
```kotlin
|
||||||
CryptoPrice(val base: String, val currency: String, val amount: BigDecimal)
|
CryptoPrice(val base: String, val currency: String, val amount: BigDecimal)
|
||||||
```
|
```
|
||||||
The parameter names match the [Coinbase API](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices).
|
The parameter names match the [Coinbase API](https://docs.cdp.coinbase.com/coinbase-app/docs/api-prices).
|
||||||
|
|
||||||
#### Format
|
#### Format
|
||||||
|
|
||||||
|
@ -81,7 +105,7 @@ val euro = CryptoPrice("BTC", "EUR", 23456.78.toBigDecimal())
|
||||||
println(euro.toCurrency()) // €23,456.78
|
println(euro.toCurrency()) // €23,456.78
|
||||||
|
|
||||||
val krone = CryptoPrice("BTC", "DKK", 123456.78.toBigDecimal())
|
val krone = CryptoPrice("BTC", "DKK", 123456.78.toBigDecimal())
|
||||||
println(krone.toCurrency(Locale("da", "DK"))) // 123.456,78 kr.
|
println(krone.toCurrency(Locale.Builder().setLanguage("da").setRegion("DK").build())) // 123.456,78 kr.
|
||||||
```
|
```
|
||||||
|
|
||||||
##### JSON
|
##### JSON
|
||||||
|
@ -99,7 +123,7 @@ println(price.toJson())
|
||||||
{"data":{"base":"BTC","currency":"USD","amount":"34567.89"}}
|
{"data":{"base":"BTC","currency":"USD","amount":"34567.89"}}
|
||||||
```
|
```
|
||||||
|
|
||||||
The `data` object matches the [Coinbase API](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices). To specify a different (or no) key, use:
|
The `data` object matches the [Coinbase API](https://docs.cdp.coinbase.com/coinbase-app/docs/api-prices). To specify a different (or no) key, use:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
println(price.toJson("bitcoin"))
|
println(price.toJson("bitcoin"))
|
||||||
|
@ -122,7 +146,7 @@ val eth = """{"ether":{"base":"ETH","currency":"USD","amount":"2345.67"}}""".toP
|
||||||
|
|
||||||
### Extending
|
### Extending
|
||||||
|
|
||||||
A generic `apiCall()` function is available to access other [data API endpoints](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-currencies). For example to retrieve the [exchange rates](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates):
|
A generic `apiCall()` function is available to access other [data API endpoints](https://docs.cdp.coinbase.com/coinbase-app/docs/api-currencies). For example to retrieve the [exchange rates](https://docs.cdp.coinbase.com/coinbase-app/docs/api-exchange-rates):
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
apiCall(listOf("exchange-rates"), mapOf("currency" to "usd"))
|
apiCall(listOf("exchange-rates"), mapOf("currency" to "usd"))
|
||||||
|
@ -134,3 +158,22 @@ will return something like:
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [examples](https://github.com/ethauvin/cryptoprice/blob/master/examples/) for more details.
|
See the [examples](https://github.com/ethauvin/cryptoprice/blob/master/examples/) for more details.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
If you want to contribute to this project, all you have to do is clone the GitHub
|
||||||
|
repository:
|
||||||
|
|
||||||
|
```console
|
||||||
|
git clone git@github.com:ethauvin/cryptoprice.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Then use [bld](https://rife2.com/bld) to build:
|
||||||
|
|
||||||
|
```console
|
||||||
|
cd cryptoprice
|
||||||
|
./bld compile
|
||||||
|
```
|
||||||
|
|
||||||
|
The project has an [IntelliJ IDEA](https://www.jetbrains.com/idea/) project structure. You can just open it after all
|
||||||
|
the dependencies were downloaded and peruse the code.
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<SmellBaseline>
|
|
||||||
<ManuallySuppressedIssues/>
|
|
||||||
<CurrentIssues>
|
|
||||||
<ID>ThrowsCount:CryptoPrice.kt$CryptoPrice.Companion$ @JvmStatic @JvmOverloads @Throws(CryptoException::class, IOException::class) fun apiCall(paths: List<String>, params: Map<String, String> = emptyMap()): String</ID>
|
|
||||||
<ID>ThrowsCount:CryptoPrice.kt$CryptoPrice.Companion$@JvmStatic @Throws(CryptoException::class) fun String.toPrice(): CryptoPrice</ID>
|
|
||||||
</CurrentIssues>
|
|
||||||
</SmellBaseline>
|
|
|
@ -1,9 +1,20 @@
|
||||||
image: openjdk:18
|
image: ubuntu:latest
|
||||||
|
|
||||||
pipelines:
|
pipelines:
|
||||||
default:
|
default:
|
||||||
- step:
|
- step:
|
||||||
caches:
|
name: Test with bld
|
||||||
- gradle
|
|
||||||
script:
|
script:
|
||||||
- bash ./gradlew check
|
# Install latest Java & Kotlin via SDKMAN!
|
||||||
|
- apt-get update -qq && apt-get install -y curl zip
|
||||||
|
- curl -s "https://get.sdkman.io" | bash
|
||||||
|
- echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config
|
||||||
|
- echo sdkman_auto_selfupdate=true >> $HOME/.sdkman/etc/config
|
||||||
|
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||||
|
- sdk install java
|
||||||
|
- sdk install kotlin
|
||||||
|
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||||
|
# Download, compile and test with bld
|
||||||
|
- ./bld download
|
||||||
|
- ./bld compile
|
||||||
|
- ./bld test
|
||||||
|
|
2
bld
Executable file
2
bld
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.crypto.CryptoPriceBuild "$@"
|
4
bld.bat
Normal file
4
bld.bat
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
@echo off
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.crypto.CryptoPriceBuild %*
|
195
build.gradle.kts
195
build.gradle.kts
|
@ -1,195 +0,0 @@
|
||||||
import org.jetbrains.dokka.gradle.DokkaTask
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
|
|
||||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("application")
|
|
||||||
id("com.github.ben-manes.versions") version "0.42.0"
|
|
||||||
id("io.gitlab.arturbosch.detekt") version "1.21.0"
|
|
||||||
id("java")
|
|
||||||
id("maven-publish")
|
|
||||||
id("org.jetbrains.dokka") version "1.7.10"
|
|
||||||
id("org.jetbrains.kotlinx.kover") version "0.6.0"
|
|
||||||
id("org.sonarqube") version "3.4.0.2513"
|
|
||||||
id("signing")
|
|
||||||
kotlin("jvm") version "1.7.10"
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
|
||||||
|
|
||||||
description = "Retrieve cryptocurrencies prices."
|
|
||||||
group = "net.thauvin.erik"
|
|
||||||
version = "1.0.0"
|
|
||||||
|
|
||||||
val deployDir = "deploy"
|
|
||||||
val gitHub = "ethauvin/$name"
|
|
||||||
val mavenUrl = "https://github.com/$gitHub"
|
|
||||||
val publicationName = "mavenJava"
|
|
||||||
|
|
||||||
fun isNonStable(version: String): Boolean {
|
|
||||||
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
|
|
||||||
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
|
|
||||||
val isStable = stableKeyword || regex.matches(version)
|
|
||||||
return isStable.not()
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(platform(kotlin("bom")))
|
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
|
||||||
|
|
||||||
implementation("com.squareup.okhttp3:okhttp:4.10.0")
|
|
||||||
implementation("org.json:json:20220320")
|
|
||||||
|
|
||||||
testImplementation(kotlin("test"))
|
|
||||||
}
|
|
||||||
|
|
||||||
application {
|
|
||||||
mainClass.set("net.thauvin.erik.crypto.CryptoPrice")
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
|
||||||
withSourcesJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
detekt {
|
|
||||||
//toolVersion = "main-SNAPSHOT"
|
|
||||||
}
|
|
||||||
|
|
||||||
sonarqube {
|
|
||||||
properties {
|
|
||||||
property("sonar.projectKey", "ethauvin_$name")
|
|
||||||
property("sonar.organization", "ethauvin-github")
|
|
||||||
property("sonar.host.url", "https://sonarcloud.io")
|
|
||||||
property("sonar.sourceEncoding", "UTF-8")
|
|
||||||
property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/xml/report.xml")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val javadocJar by tasks.creating(Jar::class) {
|
|
||||||
dependsOn(tasks.dokkaJavadoc)
|
|
||||||
from(tasks.dokkaJavadoc)
|
|
||||||
archiveClassifier.set("javadoc")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
named<JavaExec>("run") {
|
|
||||||
args = listOf("BTC","ETH","LTC")
|
|
||||||
}
|
|
||||||
|
|
||||||
withType<DependencyUpdatesTask> {
|
|
||||||
rejectVersionIf {
|
|
||||||
isNonStable(candidate.version)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
withType<KotlinCompile>().configureEach {
|
|
||||||
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
withType<Test> {
|
|
||||||
testLogging {
|
|
||||||
exceptionFormat = TestExceptionFormat.FULL
|
|
||||||
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
withType<GenerateMavenPom> {
|
|
||||||
destination = file("$projectDir/pom.xml")
|
|
||||||
}
|
|
||||||
|
|
||||||
clean {
|
|
||||||
doLast {
|
|
||||||
project.delete(fileTree(deployDir))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
withType<DokkaTask>().configureEach {
|
|
||||||
dokkaSourceSets {
|
|
||||||
named("main") {
|
|
||||||
moduleName.set("CryptoPrice")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val copyToDeploy by registering(Copy::class) {
|
|
||||||
from(configurations.runtimeClasspath) {
|
|
||||||
exclude("annotations-*.jar")
|
|
||||||
}
|
|
||||||
from(jar)
|
|
||||||
into(deployDir)
|
|
||||||
}
|
|
||||||
|
|
||||||
register("deploy") {
|
|
||||||
description = "Copies all needed files to the $deployDir directory."
|
|
||||||
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
|
||||||
dependsOn(clean, build, jar)
|
|
||||||
outputs.dir(deployDir)
|
|
||||||
inputs.files(copyToDeploy)
|
|
||||||
mustRunAfter(clean)
|
|
||||||
}
|
|
||||||
|
|
||||||
"sonarqube" {
|
|
||||||
dependsOn(koverReport)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>(publicationName) {
|
|
||||||
from(components["java"])
|
|
||||||
artifact(javadocJar)
|
|
||||||
pom {
|
|
||||||
name.set(project.name)
|
|
||||||
description.set(project.description)
|
|
||||||
url.set(mavenUrl)
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
name.set("BSD 3-Clause")
|
|
||||||
url.set("https://opensource.org/licenses/BSD-3-Clause")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id.set("ethauvin")
|
|
||||||
name.set("Erik C. Thauvin")
|
|
||||||
email.set("erik@thauvin.net")
|
|
||||||
url.set("https://erik.thauvin.net/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scm {
|
|
||||||
connection.set("scm:git:git://github.com/$gitHub.git")
|
|
||||||
developerConnection.set("scm:git:git@github.com:$gitHub.git")
|
|
||||||
url.set(mavenUrl)
|
|
||||||
}
|
|
||||||
issueManagement {
|
|
||||||
system.set("GitHub")
|
|
||||||
url.set("$mavenUrl/issues")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = "ossrh"
|
|
||||||
url = if (project.version.toString().contains("SNAPSHOT"))
|
|
||||||
uri("https://oss.sonatype.org/content/repositories/snapshots/") else
|
|
||||||
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
|
||||||
credentials(PasswordCredentials::class)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signing {
|
|
||||||
useGpgCmd()
|
|
||||||
sign(publishing.publications[publicationName])
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@
|
||||||
<SmellBaseline>
|
<SmellBaseline>
|
||||||
<ManuallySuppressedIssues/>
|
<ManuallySuppressedIssues/>
|
||||||
<CurrentIssues>
|
<CurrentIssues>
|
||||||
|
<ID>NestedBlockDepth:CryptoPrice.kt$CryptoPrice.Companion$@JvmStatic @JvmOverloads @Throws(CryptoException::class, IOException::class) fun apiCall(paths: List<String>, params: Map<String, String> = emptyMap()): String</ID>
|
||||||
<ID>ThrowsCount:CryptoPrice.kt$CryptoPrice.Companion$@JvmStatic @JvmOverloads @Throws(CryptoException::class, IOException::class) fun apiCall(paths: List<String>, params: Map<String, String> = emptyMap()): String</ID>
|
<ID>ThrowsCount:CryptoPrice.kt$CryptoPrice.Companion$@JvmStatic @JvmOverloads @Throws(CryptoException::class, IOException::class) fun apiCall(paths: List<String>, params: Map<String, String> = emptyMap()): String</ID>
|
||||||
</CurrentIssues>
|
</CurrentIssues>
|
||||||
</SmellBaseline>
|
</SmellBaseline>
|
||||||
|
|
55
examples/bld/.gitignore
vendored
Normal file
55
examples/bld/.gitignore
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
.gradle
|
||||||
|
.DS_Store
|
||||||
|
build
|
||||||
|
lib/bld/**
|
||||||
|
!lib/bld/bld-wrapper.jar
|
||||||
|
!lib/bld/bld-wrapper.properties
|
||||||
|
lib/compile/
|
||||||
|
lib/runtime/
|
||||||
|
lib/standalone/
|
||||||
|
lib/test/
|
||||||
|
|
||||||
|
# IDEA ignores
|
||||||
|
|
||||||
|
# User-specific
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# AWS User-specific
|
||||||
|
.idea/**/aws.xml
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# SonarLint plugin
|
||||||
|
.idea/sonarlint/
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
3
examples/bld/.idea/.gitignore
generated
vendored
Normal file
3
examples/bld/.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
1
examples/bld/.idea/.name
generated
Normal file
1
examples/bld/.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
||||||
|
cryptoprice-examples-bld
|
30
examples/bld/.idea/app.iml
generated
Normal file
30
examples/bld/.idea/app.iml
generated
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<output url="file://$MODULE_DIR$/build/main" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/test" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" relativeOutputPath="resources" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/kotln" isTestSource="true" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module-library" scope="RUNTIME">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$MODULE_DIR$/src/main/resources/templates" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="library" name="compile" level="project" />
|
||||||
|
<orderEntry type="library" scope="RUNTIME" name="runtime" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="test" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
14
examples/bld/.idea/bld.iml
generated
Normal file
14
examples/bld/.idea/bld.iml
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<output url="file://$MODULE_DIR$/build/bld" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/bld" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$/src/bld">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/bld/java" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="bld" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
examples/bld/.idea/bld.xml
generated
Normal file
6
examples/bld/.idea/bld.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="BldConfiguration">
|
||||||
|
<events />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
examples/bld/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
8
examples/bld/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ADDITIONAL_TAGS" value="created" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
17
examples/bld/.idea/libraries/bld.xml
generated
Normal file
17
examples/bld/.idea/libraries/bld.xml
generated
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="bld">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
<excluded>
|
||||||
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
</excluded>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
13
examples/bld/.idea/libraries/compile.xml
generated
Normal file
13
examples/bld/.idea/libraries/compile.xml
generated
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="compile">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||||
|
</SOURCES>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
14
examples/bld/.idea/libraries/runtime.xml
generated
Normal file
14
examples/bld/.idea/libraries/runtime.xml
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="runtime">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
||||||
|
<root url="file://$PROJECT_DIR$/src/main/resources" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
||||||
|
</SOURCES>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
14
examples/bld/.idea/libraries/test.xml
generated
Normal file
14
examples/bld/.idea/libraries/test.xml
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="test">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||||
|
<root url="file://$PROJECT_DIR$/src/test/resources" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||||
|
</SOURCES>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
23
examples/bld/.idea/misc.xml
generated
Normal file
23
examples/bld/.idea/misc.xml
generated
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<pattern value="com.example.CryptoPriceExampleBuild" method="runJava" />
|
||||||
|
</component>
|
||||||
|
<component name="PDMPlugin">
|
||||||
|
<option name="customRuleSets">
|
||||||
|
<list>
|
||||||
|
<option value="K:\java\semver\config\pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-pitest/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-jacoco-report/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-checkstyle/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-exec/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-testng/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-generated-version/config/pmd.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="skipTestSources" value="false" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build" />
|
||||||
|
</component>
|
||||||
|
</project>
|
9
examples/bld/.idea/modules.xml
generated
Normal file
9
examples/bld/.idea/modules.xml
generated
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
9
examples/bld/.idea/runConfigurations/Run Tests.xml
generated
Normal file
9
examples/bld/.idea/runConfigurations/Run Tests.xml
generated
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Run Tests" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||||
|
<option name="MAIN_CLASS_NAME" value="com.example.ExampleTest" />
|
||||||
|
<module name="app" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
6
examples/bld/.idea/vcs.xml
generated
Normal file
6
examples/bld/.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
11
examples/bld/.vscode/launch.json
vendored
Normal file
11
examples/bld/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Run Tests",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "com.example.ExampleTest"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
examples/bld/.vscode/settings.json
vendored
Normal file
15
examples/bld/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"java.project.sourcePaths": [
|
||||||
|
"src/main/java",
|
||||||
|
"src/main/resources",
|
||||||
|
"src/test/java",
|
||||||
|
"src/test/resources",
|
||||||
|
"src/bld/java",
|
||||||
|
"src/bld/resources"
|
||||||
|
],
|
||||||
|
"java.configuration.updateBuildConfiguration": "automatic",
|
||||||
|
"java.project.referencedLibraries": [
|
||||||
|
"${HOME}/.bld/dist/bld-2.2.1.jar",
|
||||||
|
"lib/**/*.jar"
|
||||||
|
]
|
||||||
|
}
|
22
examples/bld/README.md
Normal file
22
examples/bld/README.md
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
## Kotlin Example
|
||||||
|
To compile & run the Kotlin example:
|
||||||
|
|
||||||
|
```console
|
||||||
|
./bld compile
|
||||||
|
|
||||||
|
./bld run
|
||||||
|
./bld run --args="btc"
|
||||||
|
./bld run --args="eth eur"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Java Example
|
||||||
|
|
||||||
|
To compile & run the Java example:
|
||||||
|
|
||||||
|
```console
|
||||||
|
./bld compile
|
||||||
|
|
||||||
|
./bld run-java
|
||||||
|
./bld run-java --args="btc"
|
||||||
|
./bld run-java --args="eth eur"
|
||||||
|
```
|
2
examples/bld/bld
Executable file
2
examples/bld/bld
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build com.example.CryptoPriceExampleBuild "$@"
|
4
examples/bld/bld.bat
Normal file
4
examples/bld/bld.bat
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
@echo off
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build com.example.CryptoPriceExampleBuild %*
|
BIN
examples/bld/lib/bld/bld-wrapper.jar
Normal file
BIN
examples/bld/lib/bld/bld-wrapper.jar
Normal file
Binary file not shown.
7
examples/bld/lib/bld/bld-wrapper.properties
Normal file
7
examples/bld/lib/bld/bld-wrapper.properties
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
bld.downloadExtensionJavadoc=false
|
||||||
|
bld.downloadExtensionSources=true
|
||||||
|
bld.downloadLocation=
|
||||||
|
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
|
||||||
|
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
|
bld.sourceDirectories=
|
||||||
|
bld.version=2.2.1
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.example;
|
||||||
|
|
||||||
|
import rife.bld.BuildCommand;
|
||||||
|
import rife.bld.extension.CompileKotlinOperation;
|
||||||
|
import rife.bld.operations.RunOperation;
|
||||||
|
import rife.bld.BaseProject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static rife.bld.dependencies.Repository.*;
|
||||||
|
import static rife.bld.dependencies.Scope.compile;
|
||||||
|
|
||||||
|
public class CryptoPriceExampleBuild extends BaseProject {
|
||||||
|
public CryptoPriceExampleBuild() {
|
||||||
|
pkg = "com.example";
|
||||||
|
name = "Example";
|
||||||
|
version = version(0, 1, 0);
|
||||||
|
|
||||||
|
mainClass = "com.example.CryptoPriceExampleKt";
|
||||||
|
|
||||||
|
javaRelease = 11;
|
||||||
|
downloadSources = true;
|
||||||
|
|
||||||
|
autoDownloadPurge = true;
|
||||||
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
|
||||||
|
|
||||||
|
scope(compile)
|
||||||
|
.include(dependency("net.thauvin.erik", "cryptoprice", version(1, 0, 3, "SNAPSHOT")))
|
||||||
|
.include(dependency("org.json", "json", "20250107"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new CryptoPriceExampleBuild().start(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void compile() throws Exception {
|
||||||
|
new CompileKotlinOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
// Also compile the Java source code
|
||||||
|
super.compile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(value = "run-java", summary = "Runs the Java example")
|
||||||
|
public void runJava() throws Exception {
|
||||||
|
new RunOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.mainClass("com.example.CryptoPriceSample")
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,7 +48,7 @@ public class CryptoPriceSample {
|
||||||
}
|
}
|
||||||
} catch (CryptoException e) {
|
} catch (CryptoException e) {
|
||||||
System.err.println("HTTP Status Code: " + e.getStatusCode());
|
System.err.println("HTTP Status Code: " + e.getStatusCode());
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage() + " (" + e.getId() + ')');
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
System.err.println("Could not display the specified currency: " + args[1]);
|
System.err.println("Could not display the specified currency: " + args[1]);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
|
@ -40,8 +40,8 @@ fun main(args: Array<String>) {
|
||||||
}
|
}
|
||||||
} catch (e: CryptoException) {
|
} catch (e: CryptoException) {
|
||||||
System.err.println("HTTP Status Code: ${e.statusCode}")
|
System.err.println("HTTP Status Code: ${e.statusCode}")
|
||||||
System.err.println(e.message)
|
System.err.println("${e.message} (${e.id})")
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (ignore: IllegalArgumentException) {
|
||||||
System.err.println("Could not display the specified currency: ${args[1]}")
|
System.err.println("Could not display the specified currency: ${args[1]}")
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
System.err.println(e.message)
|
System.err.println(e.message)
|
|
@ -3,3 +3,5 @@
|
||||||
|
|
||||||
# Ignore Gradle build output directory
|
# Ignore Gradle build output directory
|
||||||
build
|
build
|
||||||
|
|
||||||
|
bin
|
3
examples/gradle/.idea/.gitignore
generated
vendored
Normal file
3
examples/gradle/.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
1
examples/gradle/.idea/.name
generated
Normal file
1
examples/gradle/.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
||||||
|
cryptoprice-examples-gradle
|
6
examples/gradle/.idea/compiler.xml
generated
Normal file
6
examples/gradle/.idea/compiler.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="11" />
|
||||||
|
</component>
|
||||||
|
</project>
|
17
examples/gradle/.idea/gradle.xml
generated
Normal file
17
examples/gradle/.idea/gradle.xml
generated
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="#JAVA_HOME" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
8
examples/gradle/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
8
examples/gradle/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ADDITIONAL_TAGS" value="created" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
30
examples/gradle/.idea/jarRepositories.xml
generated
Normal file
30
examples/gradle/.idea/jarRepositories.xml
generated
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenLocal" />
|
||||||
|
<option name="name" value="MavenLocal" />
|
||||||
|
<option name="url" value="file:$MAVEN_REPOSITORY$/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenRepo" />
|
||||||
|
<option name="name" value="MavenRepo" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
examples/gradle/.idea/kotlinc.xml
generated
Normal file
6
examples/gradle/.idea/kotlinc.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="KotlinJpsPluginSettings">
|
||||||
|
<option name="version" value="1.9.21" />
|
||||||
|
</component>
|
||||||
|
</project>
|
19
examples/gradle/.idea/misc.xml
generated
Normal file
19
examples/gradle/.idea/misc.xml
generated
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="PDMPlugin">
|
||||||
|
<option name="customRuleSets">
|
||||||
|
<list>
|
||||||
|
<option value="K:\java\semver\config\pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-pitest/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-jacoco-report/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-checkstyle/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-exec/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-testng/config/pmd.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/../../../../java/bld-generated-version/config/pmd.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="skipTestSources" value="false" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="20" project-jdk-type="JavaSDK" />
|
||||||
|
</project>
|
6
examples/gradle/.idea/vcs.xml
generated
Normal file
6
examples/gradle/.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
18
examples/gradle/README.md
Normal file
18
examples/gradle/README.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
## Kotlin Example
|
||||||
|
To run the Kotlin example:
|
||||||
|
|
||||||
|
```console
|
||||||
|
./gradlew run
|
||||||
|
./gradlew run --args="btc"
|
||||||
|
./gradlew run --args="eth eur"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Java Example
|
||||||
|
|
||||||
|
To run the Java example:
|
||||||
|
|
||||||
|
```console
|
||||||
|
./gradlew runJava
|
||||||
|
./gradlew runJava --args="btc"
|
||||||
|
./gradlew runJava --args="eth eur"
|
||||||
|
```
|
|
@ -2,15 +2,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("application")
|
id("application")
|
||||||
id("com.github.ben-manes.versions") version "0.42.0"
|
id("com.github.ben-manes.versions") version "0.51.0"
|
||||||
kotlin("jvm") version "1.7.10"
|
kotlin("jvm") version "2.1.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ./gradlew run
|
|
||||||
// ./gradlew runJava
|
|
||||||
// ./gradlew run --args="btc"
|
|
||||||
// ./gradlew runJava --args="eth eur"
|
|
||||||
|
|
||||||
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -20,8 +15,8 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.thauvin.erik:cryptoprice:1.0.0")
|
implementation("net.thauvin.erik:cryptoprice:1.0.3-SNAPSHOT")
|
||||||
implementation("org.json:json:20220320")
|
implementation("org.json:json:20240303")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -33,11 +28,11 @@ application {
|
||||||
mainClass.set("com.example.CryptoPriceExampleKt")
|
mainClass.set("com.example.CryptoPriceExampleKt")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
kotlin {
|
||||||
withType<KotlinCompile>().configureEach {
|
compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
|
||||||
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
tasks {
|
||||||
register<JavaExec>("runJava") {
|
register<JavaExec>("runJava") {
|
||||||
group = "application"
|
group = "application"
|
||||||
mainClass.set("com.example.CryptoPriceSample")
|
mainClass.set("com.example.CryptoPriceSample")
|
BIN
examples/gradle/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
examples/gradle/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
|
@ -1,5 +1,7 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
47
examples/gradlew → examples/gradle/gradlew
vendored
47
examples/gradlew → examples/gradle/gradlew
vendored
|
@ -15,6 +15,8 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
|
@ -55,7 +57,7 @@
|
||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
@ -80,13 +82,11 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
@ -114,7 +114,7 @@ case "$( uname )" in #(
|
||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
|
@ -133,22 +133,29 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
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.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
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
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
|
@ -193,18 +200,28 @@ if "$cygwin" || "$msys" ; then
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-classpath "$CLASSPATH" \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
@ -13,8 +13,10 @@
|
||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
|
@ -25,7 +27,8 @@
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -56,32 +59,34 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.example;
|
||||||
|
|
||||||
|
import net.thauvin.erik.crypto.CryptoException;
|
||||||
|
import net.thauvin.erik.crypto.CryptoPrice;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Currency;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class CryptoPriceSample {
|
||||||
|
public static void main(final String[] args) {
|
||||||
|
try {
|
||||||
|
if (args.length > 0) {
|
||||||
|
final String currency;
|
||||||
|
if (args.length == 2) {
|
||||||
|
currency = args[1];
|
||||||
|
} else {
|
||||||
|
currency = Currency.getInstance(Locale.getDefault()).getCurrencyCode();
|
||||||
|
}
|
||||||
|
final var price = CryptoPrice.spotPrice(args[0], currency);
|
||||||
|
System.out.println("The current " + price.getBase() + " price is " + price.toCurrency());
|
||||||
|
} else {
|
||||||
|
// Get current Bitcoin spot price.
|
||||||
|
final var price = CryptoPrice.spotPrice("BTC");
|
||||||
|
System.out.println("The current Bitcoin price is " + price.toCurrency());
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
// Get current Ethereum buy price in Pound sterling.
|
||||||
|
final var gbpPrice = CryptoPrice.buyPrice("ETH", "GBP");
|
||||||
|
System.out.println("The current Ethereum buy price is " + gbpPrice.toCurrency());
|
||||||
|
|
||||||
|
// Get current Litecoin sell price in Euros.
|
||||||
|
final var euroPrice = CryptoPrice.sellPrice("LTC", "EUR");
|
||||||
|
System.out.println("The current Litecoin sell price is " + euroPrice.toCurrency());
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
// Get exchange rate using API.
|
||||||
|
// See: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates
|
||||||
|
final var response = CryptoPrice.apiCall(List.of("exchange-rates"),
|
||||||
|
Collections.singletonMap("currency", "USD"));
|
||||||
|
final var rates = new JSONObject(response).getJSONObject("data").getJSONObject("rates");
|
||||||
|
System.out.println("The USD-EUR exchange rate is: " + rates.getString("EUR"));
|
||||||
|
}
|
||||||
|
} catch (CryptoException e) {
|
||||||
|
System.err.println("HTTP Status Code: " + e.getStatusCode());
|
||||||
|
System.err.println(e.getMessage() + " (" + e.getId() + ')');
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.err.println("Could not display the specified currency: " + args[1]);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.example
|
||||||
|
|
||||||
|
import net.thauvin.erik.crypto.CryptoException
|
||||||
|
import net.thauvin.erik.crypto.CryptoPrice.Companion.apiCall
|
||||||
|
import net.thauvin.erik.crypto.CryptoPrice.Companion.buyPrice
|
||||||
|
import net.thauvin.erik.crypto.CryptoPrice.Companion.sellPrice
|
||||||
|
import net.thauvin.erik.crypto.CryptoPrice.Companion.spotPrice
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
try {
|
||||||
|
if (args.isNotEmpty()) {
|
||||||
|
val currency = if (args.size == 2) args[1] else Currency.getInstance(Locale.getDefault()).currencyCode
|
||||||
|
val price = spotPrice(args[0], currency)
|
||||||
|
println("The current ${price.base} price is ${price.toCurrency()}")
|
||||||
|
} else {
|
||||||
|
// Get current Bitcoin spot price.
|
||||||
|
val price = spotPrice("BTC")
|
||||||
|
println("The current Bitcoin price is ${price.toCurrency()}")
|
||||||
|
|
||||||
|
println()
|
||||||
|
|
||||||
|
// Get current Ethereum sell price in Pound sterling.
|
||||||
|
val gbpPrice = sellPrice("ETH", "GBP")
|
||||||
|
println("The current Ethereum sell price is ${gbpPrice.toCurrency()}")
|
||||||
|
|
||||||
|
// Get current Litecoin buy price in Euro.
|
||||||
|
val euroPrice = buyPrice("LTC", "EUR")
|
||||||
|
println("The current Litecoin buy price is ${euroPrice.toCurrency()}")
|
||||||
|
|
||||||
|
println()
|
||||||
|
|
||||||
|
// Get exchange rate using API.
|
||||||
|
// See: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates
|
||||||
|
val response = apiCall(listOf("exchange-rates"), mapOf("currency" to "usd"))
|
||||||
|
val rates = JSONObject(response).getJSONObject("data").getJSONObject("rates")
|
||||||
|
println("The USD-EUR exchange rate is: ${rates.getString("EUR")}")
|
||||||
|
}
|
||||||
|
} catch (e: CryptoException) {
|
||||||
|
System.err.println("HTTP Status Code: ${e.statusCode}")
|
||||||
|
System.err.println("${e.message} (${e.id})")
|
||||||
|
} catch (ignore: IllegalArgumentException) {
|
||||||
|
System.err.println("Could not display the specified currency: ${args[1]}")
|
||||||
|
} catch (e: IOException) {
|
||||||
|
System.err.println(e.message)
|
||||||
|
}
|
||||||
|
}
|
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +0,0 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
234
gradlew
vendored
234
gradlew
vendored
|
@ -1,234 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright © 2015-2021 the original authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "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
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
|
||||||
#
|
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
app_path=$0
|
|
||||||
|
|
||||||
# Need this for daisy-chained symlinks.
|
|
||||||
while
|
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
||||||
[ -h "$app_path" ]
|
|
||||||
do
|
|
||||||
ls=$( ls -ld "$app_path" )
|
|
||||||
link=${ls#*' -> '}
|
|
||||||
case $link in #(
|
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD=maximum
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "$( uname )" in #(
|
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
|
||||||
Darwin* ) darwin=true ;; #(
|
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
|
||||||
NONSTOP* ) nonstop=true ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
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" && ! "$darwin" && ! "$nonstop" ; then
|
|
||||||
case $MAX_FD in #(
|
|
||||||
max*)
|
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
|
||||||
warn "Could not query maximum file descriptor limit"
|
|
||||||
esac
|
|
||||||
case $MAX_FD in #(
|
|
||||||
'' | soft) :;; #(
|
|
||||||
*)
|
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
|
||||||
# * args from the command line
|
|
||||||
# * the main class name
|
|
||||||
# * -classpath
|
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if "$cygwin" || "$msys" ; then
|
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
for arg do
|
|
||||||
if
|
|
||||||
case $arg in #(
|
|
||||||
-*) false ;; # don't mess with options #(
|
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
|
||||||
|
|
||||||
set -- \
|
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
89
gradlew.bat
vendored
89
gradlew.bat
vendored
|
@ -1,89 +0,0 @@
|
||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@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
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
|
||||||
set APP_BASE_NAME=%~n0
|
|
||||||
set APP_HOME=%DIRNAME%
|
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@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="-Xmx64m" "-Xms64m"
|
|
||||||
|
|
||||||
@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 execute
|
|
||||||
|
|
||||||
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 execute
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
: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 %*
|
|
||||||
|
|
||||||
: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
|
|
BIN
lib/bld/bld-wrapper.jar
Normal file
BIN
lib/bld/bld-wrapper.jar
Normal file
Binary file not shown.
10
lib/bld/bld-wrapper.properties
Normal file
10
lib/bld/bld-wrapper.properties
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
bld.downloadExtensionJavadoc=false
|
||||||
|
bld.downloadExtensionSources=true
|
||||||
|
bld.downloadLocation=
|
||||||
|
bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT
|
||||||
|
bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.4-SNAPSHOT
|
||||||
|
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10
|
||||||
|
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
|
||||||
|
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
|
bld.sourceDirectories=
|
||||||
|
bld.version=2.2.1
|
69
pom.xml
69
pom.xml
|
@ -1,16 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
<!-- This module was also published with a richer model, Gradle metadata, -->
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<!-- which should be used instead. Do not delete the following line which -->
|
|
||||||
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
|
|
||||||
<!-- that they should prefer consuming it instead. -->
|
|
||||||
<!-- do_not_remove: published-with-gradle-metadata -->
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.thauvin.erik</groupId>
|
<groupId>net.thauvin.erik</groupId>
|
||||||
<artifactId>cryptoprice</artifactId>
|
<artifactId>cryptoprice</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.3-SNAPSHOT</version>
|
||||||
<name>cryptoprice</name>
|
<name>cryptoprice</name>
|
||||||
<description>Retrieve cryptocurrencies prices.</description>
|
<description>Retrieve cryptocurrencies prices</description>
|
||||||
<url>https://github.com/ethauvin/cryptoprice</url>
|
<url>https://github.com/ethauvin/cryptoprice</url>
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
|
@ -18,6 +14,26 @@
|
||||||
<url>https://opensource.org/licenses/BSD-3-Clause</url>
|
<url>https://opensource.org/licenses/BSD-3-Clause</url>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
|
<version>2.1.20</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20250107</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>4.12.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>ethauvin</id>
|
<id>ethauvin</id>
|
||||||
|
@ -27,43 +43,8 @@
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git://github.com/ethauvin/cryptoprice.git</connection>
|
<connection>scm:git:https://github.com/ethauvin/cryptoprice.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:ethauvin/cryptoprice.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:ethauvin/cryptoprice.git</developerConnection>
|
||||||
<url>https://github.com/ethauvin/cryptoprice</url>
|
<url>https://github.com/ethauvin/cryptoprice</url>
|
||||||
</scm>
|
</scm>
|
||||||
<issueManagement>
|
|
||||||
<system>GitHub</system>
|
|
||||||
<url>https://github.com/ethauvin/cryptoprice/issues</url>
|
|
||||||
</issueManagement>
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-bom</artifactId>
|
|
||||||
<version>1.7.10</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
|
||||||
<version>1.7.10</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
<version>4.10.0</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20220320</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
plugins {
|
|
||||||
id("com.gradle.enterprise").version("3.6.3")
|
|
||||||
}
|
|
||||||
|
|
||||||
gradleEnterprise {
|
|
||||||
buildScan {
|
|
||||||
link("GitHub", "https://github.com/ethauvin/cryptoprice/tree/master")
|
|
||||||
if (!System.getenv("CI").isNullOrEmpty()) {
|
|
||||||
isUploadInBackground = false
|
|
||||||
publishOnFailure()
|
|
||||||
tag("CI")
|
|
||||||
}
|
|
||||||
termsOfServiceUrl = "https://gradle.com/terms-of-service"
|
|
||||||
termsOfServiceAgree = "yes"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = "cryptoprice"
|
|
7
sonar-project.properties
Normal file
7
sonar-project.properties
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
sonar.organization=ethauvin-github
|
||||||
|
sonar.projectKey=ethauvin_cryptoprice
|
||||||
|
sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml
|
||||||
|
sonar.sources=src/main/kotlin/
|
||||||
|
sonar.tests=src/test/kotlin/
|
||||||
|
sonar.java.binaries=build/main,build/test
|
||||||
|
sonar.java.libraries=lib/compile/*.jar
|
196
src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java
Normal file
196
src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java
Normal file
|
@ -0,0 +1,196 @@
|
||||||
|
/*
|
||||||
|
* CryptoPriceBuild.java
|
||||||
|
*
|
||||||
|
* Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of this project nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.thauvin.erik.crypto;
|
||||||
|
|
||||||
|
import rife.bld.BuildCommand;
|
||||||
|
import rife.bld.Project;
|
||||||
|
import rife.bld.extension.CompileKotlinOperation;
|
||||||
|
import rife.bld.extension.DetektOperation;
|
||||||
|
import rife.bld.extension.DokkaOperation;
|
||||||
|
import rife.bld.extension.JacocoReportOperation;
|
||||||
|
import rife.bld.extension.dokka.LoggingLevel;
|
||||||
|
import rife.bld.extension.dokka.OutputFormat;
|
||||||
|
import rife.bld.extension.kotlin.CompileOptions;
|
||||||
|
import rife.bld.operations.exceptions.ExitStatusException;
|
||||||
|
import rife.bld.publish.PomBuilder;
|
||||||
|
import rife.bld.publish.PublishDeveloper;
|
||||||
|
import rife.bld.publish.PublishLicense;
|
||||||
|
import rife.bld.publish.PublishScm;
|
||||||
|
import rife.tools.exceptions.FileUtilsErrorException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.ConsoleHandler;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static rife.bld.dependencies.Repository.*;
|
||||||
|
import static rife.bld.dependencies.Scope.compile;
|
||||||
|
import static rife.bld.dependencies.Scope.test;
|
||||||
|
|
||||||
|
public class CryptoPriceBuild extends Project {
|
||||||
|
final File srcMainKotlin = new File(srcMainDirectory(), "kotlin");
|
||||||
|
|
||||||
|
public CryptoPriceBuild() {
|
||||||
|
pkg = "net.thauvin.erik.crypto";
|
||||||
|
name = "cryptoprice";
|
||||||
|
version = version(1, 0, 3, "SNAPSHOT");
|
||||||
|
|
||||||
|
mainClass = "net.thauvin.erik.crypto.CryptoPrice";
|
||||||
|
|
||||||
|
javaRelease = 11;
|
||||||
|
downloadSources = true;
|
||||||
|
autoDownloadPurge = true;
|
||||||
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
|
||||||
|
|
||||||
|
final var kotlin = version(2, 1, 20);
|
||||||
|
scope(compile)
|
||||||
|
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin))
|
||||||
|
.include(dependency("org.json", "json", "20250107"))
|
||||||
|
.include(dependency("com.squareup.okhttp3", "okhttp", version(4, 12, 0)));
|
||||||
|
scope(test)
|
||||||
|
.include(dependency("com.willowtreeapps.assertk", "assertk-jvm", version(0, 28, 1)))
|
||||||
|
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
|
||||||
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
|
||||||
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)))
|
||||||
|
.include(dependency("org.junit.platform", "junit-platform-launcher", version(1, 12, 2)));
|
||||||
|
|
||||||
|
publishOperation()
|
||||||
|
.repository(version.isSnapshot() ? repository(SONATYPE_SNAPSHOTS_LEGACY.location())
|
||||||
|
.withCredentials(property("sonatype.user"), property("sonatype.password"))
|
||||||
|
: repository(SONATYPE_RELEASES_LEGACY.location())
|
||||||
|
.withCredentials(property("sonatype.user"), property("sonatype.password")))
|
||||||
|
.repository(repository("github"))
|
||||||
|
.info()
|
||||||
|
.groupId("net.thauvin.erik")
|
||||||
|
.artifactId(name)
|
||||||
|
.description("Retrieve cryptocurrencies prices")
|
||||||
|
.url("https://github.com/ethauvin/" + name)
|
||||||
|
.developer(new PublishDeveloper()
|
||||||
|
.id("ethauvin")
|
||||||
|
.name("Erik C. Thauvin")
|
||||||
|
.email("erik@thauvin.net")
|
||||||
|
.url("https://erik.thauvin.net/")
|
||||||
|
)
|
||||||
|
.license(new PublishLicense()
|
||||||
|
.name("BSD 3-Clause")
|
||||||
|
.url("https://opensource.org/licenses/BSD-3-Clause")
|
||||||
|
)
|
||||||
|
.scm(new PublishScm()
|
||||||
|
.connection("scm:git:https://github.com/ethauvin/" + name + ".git")
|
||||||
|
.developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
|
||||||
|
.url("https://github.com/ethauvin/" + name)
|
||||||
|
)
|
||||||
|
.signKey(property("sign.key"))
|
||||||
|
.signPassphrase(property("sign.passphrase"));
|
||||||
|
|
||||||
|
jarSourcesOperation().sourceDirectories(srcMainKotlin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(final String[] args) {
|
||||||
|
// Enable detailed logging for the extensions
|
||||||
|
final var level = Level.ALL;
|
||||||
|
final var logger = Logger.getLogger("rife.bld.extension");
|
||||||
|
final var consoleHandler = new ConsoleHandler();
|
||||||
|
|
||||||
|
consoleHandler.setLevel(level);
|
||||||
|
logger.addHandler(consoleHandler);
|
||||||
|
logger.setLevel(level);
|
||||||
|
logger.setUseParentHandlers(false);
|
||||||
|
|
||||||
|
new CryptoPriceBuild().start(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||||
|
@Override
|
||||||
|
public void compile() throws Exception {
|
||||||
|
new CompileKotlinOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.compileOptions(new CompileOptions().verbose(true))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(summary = "Checks source with Detekt")
|
||||||
|
public void detekt() throws ExitStatusException, IOException, InterruptedException {
|
||||||
|
new DetektOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(value = "detekt-baseline", summary = "Creates the Detekt baseline")
|
||||||
|
public void detektBaseline() throws ExitStatusException, IOException, InterruptedException {
|
||||||
|
new DetektOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.baseline("detekt-baseline.xml")
|
||||||
|
.createBaseline(true)
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(summary = "Generates JaCoCo Reports")
|
||||||
|
public void jacoco() throws Exception {
|
||||||
|
new JacocoReportOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.sourceFiles(srcMainKotlin)
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void javadoc() throws ExitStatusException, IOException, InterruptedException {
|
||||||
|
new DokkaOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.loggingLevel(LoggingLevel.INFO)
|
||||||
|
.moduleName("CryptoPrice")
|
||||||
|
.moduleVersion(version.toString())
|
||||||
|
.outputDir(new File(buildDirectory(), "javadoc"))
|
||||||
|
.outputFormat(OutputFormat.JAVADOC)
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publish() throws Exception {
|
||||||
|
super.publish();
|
||||||
|
pomRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publishLocal() throws Exception {
|
||||||
|
super.publishLocal();
|
||||||
|
pomRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
|
||||||
|
public void pomRoot() throws FileUtilsErrorException {
|
||||||
|
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
|
||||||
|
new File(workDirectory, "pom.xml"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* CryptoException.kt
|
* CryptoException.kt
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
|
* Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -37,6 +36,7 @@ package net.thauvin.erik.crypto
|
||||||
*/
|
*/
|
||||||
class CryptoException @JvmOverloads constructor(
|
class CryptoException @JvmOverloads constructor(
|
||||||
var statusCode: Int = NO_STATUS,
|
var statusCode: Int = NO_STATUS,
|
||||||
|
var id: String,
|
||||||
message: String,
|
message: String,
|
||||||
cause: Throwable? = null
|
cause: Throwable? = null
|
||||||
) : Exception(message, cause) {
|
) : Exception(message, cause) {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* CryptoPrice.kt
|
* CryptoPrice.kt
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
|
* Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -43,6 +42,8 @@ import java.math.BigDecimal
|
||||||
import java.text.NumberFormat
|
import java.text.NumberFormat
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.logging.Level
|
||||||
|
import java.util.logging.Logger
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves and holds a cryptocurrency price.
|
* Retrieves and holds a cryptocurrency price.
|
||||||
|
@ -58,6 +59,9 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
|
||||||
// Coinbase API URL
|
// Coinbase API URL
|
||||||
private const val COINBASE_API_URL = "https://api.coinbase.com/v2/"
|
private const val COINBASE_API_URL = "https://api.coinbase.com/v2/"
|
||||||
|
|
||||||
|
/** The logger instance. **/
|
||||||
|
val logger: Logger by lazy { Logger.getLogger(CryptoPrice::class.java.simpleName) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts JSON data object to [CryptoPrice].
|
* Converts JSON data object to [CryptoPrice].
|
||||||
*
|
*
|
||||||
|
@ -73,9 +77,9 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
|
||||||
return CryptoPrice(getString("base"), getString("currency"), getString("amount").toBigDecimal())
|
return CryptoPrice(getString("base"), getString("currency"), getString("amount").toBigDecimal())
|
||||||
}
|
}
|
||||||
} catch (e: NumberFormatException) {
|
} catch (e: NumberFormatException) {
|
||||||
throw CryptoException(message = "Could not convert amount to number.", cause = e)
|
throw CryptoException(id = "convert_error", message = "Could not convert amount to number.", cause = e)
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
throw CryptoException(message = "Could not parse price data.", cause = e)
|
throw CryptoException(id = "parse_error", message = "Could not parse price data.", cause = e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,18 +104,38 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
|
||||||
}.build()
|
}.build()
|
||||||
|
|
||||||
val request = Request.Builder().url(httpUrl).build()
|
val request = Request.Builder().url(httpUrl).build()
|
||||||
val response = client.newCall(request).execute()
|
client.newCall(request).execute().use { response ->
|
||||||
val body = response.body?.string() ?: throw CryptoException(response.code, "Empty response.")
|
val body = response.body?.string() ?: throw CryptoException(
|
||||||
try {
|
response.code,
|
||||||
val json = JSONObject(body)
|
id = "empty_response",
|
||||||
if (response.isSuccessful) {
|
message = "Empty response."
|
||||||
return body
|
)
|
||||||
} else {
|
if (logger.isLoggable(Level.FINE)) {
|
||||||
val data = json.getJSONArray("errors")
|
logger.fine(body)
|
||||||
throw CryptoException(response.code, data.getJSONObject(0).getString("message"))
|
}
|
||||||
|
try {
|
||||||
|
val json = JSONObject(body)
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
return body
|
||||||
|
} else {
|
||||||
|
if (json.has("errors")) {
|
||||||
|
val data = json.getJSONArray("errors")
|
||||||
|
throw CryptoException(
|
||||||
|
response.code,
|
||||||
|
data.getJSONObject(0).getString("id"),
|
||||||
|
data.getJSONObject(0).getString("message")
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
throw CryptoException(
|
||||||
|
response.code,
|
||||||
|
json.getString("error"),
|
||||||
|
json.getString("message")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: JSONException) {
|
||||||
|
throw CryptoException(response.code, id = "parse_error", "Could not parse data.", e)
|
||||||
}
|
}
|
||||||
} catch (e: JSONException) {
|
|
||||||
throw CryptoException(response.code, "Could not parse data.", e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,9 +157,13 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
args.forEach {
|
if (args.isEmpty()) {
|
||||||
with(spotPrice(it)) {
|
println("Please specify one or more ticker symbols as arguments.")
|
||||||
println("$base:\t" + "%10s".format(toCurrency()))
|
} else {
|
||||||
|
args.forEach {
|
||||||
|
with(spotPrice(it)) {
|
||||||
|
println("$base:\t" + "%10s".format(toCurrency()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* CryptoPriceTest.kt
|
* CryptoPriceTest.kt
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
|
* Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -32,19 +31,27 @@
|
||||||
|
|
||||||
package net.thauvin.erik.crypto
|
package net.thauvin.erik.crypto
|
||||||
|
|
||||||
|
import assertk.all
|
||||||
|
import assertk.assertThat
|
||||||
|
import assertk.assertions.isEqualTo
|
||||||
|
import assertk.assertions.isGreaterThan
|
||||||
|
import assertk.assertions.prop
|
||||||
import net.thauvin.erik.crypto.CryptoPrice.Companion.apiCall
|
import net.thauvin.erik.crypto.CryptoPrice.Companion.apiCall
|
||||||
import net.thauvin.erik.crypto.CryptoPrice.Companion.buyPrice
|
import net.thauvin.erik.crypto.CryptoPrice.Companion.buyPrice
|
||||||
import net.thauvin.erik.crypto.CryptoPrice.Companion.sellPrice
|
import net.thauvin.erik.crypto.CryptoPrice.Companion.sellPrice
|
||||||
import net.thauvin.erik.crypto.CryptoPrice.Companion.spotPrice
|
import net.thauvin.erik.crypto.CryptoPrice.Companion.spotPrice
|
||||||
import net.thauvin.erik.crypto.CryptoPrice.Companion.toPrice
|
import net.thauvin.erik.crypto.CryptoPrice.Companion.toPrice
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import org.junit.jupiter.api.BeforeAll
|
||||||
|
import java.math.BigDecimal
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.logging.ConsoleHandler
|
||||||
|
import java.util.logging.Level
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertFailsWith
|
import kotlin.test.assertFailsWith
|
||||||
import kotlin.test.assertNotEquals
|
import kotlin.test.assertNotEquals
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [CryptoPrice] Tests
|
* [CryptoPrice] Tests
|
||||||
|
@ -58,9 +65,11 @@ class CryptoPriceTest {
|
||||||
fun testBitcoinPrice() {
|
fun testBitcoinPrice() {
|
||||||
val prices = listOf(spotPrice("BTC"), buyPrice("BTC"), sellPrice("BTC"))
|
val prices = listOf(spotPrice("BTC"), buyPrice("BTC"), sellPrice("BTC"))
|
||||||
for (price in prices) {
|
for (price in prices) {
|
||||||
assertEquals("BTC", price.base, "BTC")
|
assertThat(price).all {
|
||||||
assertEquals("USD", price.currency, "is USD")
|
prop(CryptoPrice::base).isEqualTo("BTC")
|
||||||
assertTrue(price.amount.signum() > 0, "BTC > 0")
|
prop(CryptoPrice::currency).isEqualTo("USD")
|
||||||
|
prop(CryptoPrice::amount).isGreaterThan(BigDecimal(0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,9 +78,11 @@ class CryptoPriceTest {
|
||||||
fun testEtherPrice() {
|
fun testEtherPrice() {
|
||||||
val prices = listOf(spotPrice("ETH", "EUR"), buyPrice("ETH", "EUR"), sellPrice("ETH", "EUR"))
|
val prices = listOf(spotPrice("ETH", "EUR"), buyPrice("ETH", "EUR"), sellPrice("ETH", "EUR"))
|
||||||
for (price in prices) {
|
for (price in prices) {
|
||||||
assertEquals("ETH", price.base, "ETH")
|
assertThat(price).all {
|
||||||
assertEquals("EUR", price.currency, "is EUR")
|
prop(CryptoPrice::base).isEqualTo("ETH")
|
||||||
assertTrue(price.amount.signum() > 0, "ETH > 0")
|
prop(CryptoPrice::currency).isEqualTo("EUR")
|
||||||
|
prop(CryptoPrice::amount).isGreaterThan(BigDecimal(0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +91,11 @@ class CryptoPriceTest {
|
||||||
fun testLitecoinPrice() {
|
fun testLitecoinPrice() {
|
||||||
val prices = listOf(spotPrice("LTC", "GBP"), buyPrice("LTC", "GBP"), sellPrice("LTC", "GBP"))
|
val prices = listOf(spotPrice("LTC", "GBP"), buyPrice("LTC", "GBP"), sellPrice("LTC", "GBP"))
|
||||||
for (price in prices) {
|
for (price in prices) {
|
||||||
assertEquals("LTC", price.base, "LTC")
|
assertThat(price).all {
|
||||||
assertEquals("GBP", price.currency, "is GBP")
|
prop(CryptoPrice::base).isEqualTo("LTC")
|
||||||
assertTrue(price.amount.signum() > 0, "LTC > 0")
|
prop(CryptoPrice::currency).isEqualTo("GBP")
|
||||||
|
prop(CryptoPrice::amount).isGreaterThan(BigDecimal(0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,35 +103,32 @@ class CryptoPriceTest {
|
||||||
@Throws(CryptoException::class)
|
@Throws(CryptoException::class)
|
||||||
fun testBitcoinCashPrice() {
|
fun testBitcoinCashPrice() {
|
||||||
val price = spotPrice("BCH", "GBP", LocalDate.now().minusDays(1))
|
val price = spotPrice("BCH", "GBP", LocalDate.now().minusDays(1))
|
||||||
assertEquals("BCH", price.base, "BCH")
|
assertThat(price, "spotPrice(BCH,GPB)").all {
|
||||||
assertEquals("GBP", price.currency, "is GBP")
|
prop(CryptoPrice::base).isEqualTo("BCH")
|
||||||
assertTrue(price.amount.signum() > 0, "BCH > 0")
|
prop(CryptoPrice::currency).isEqualTo("GBP")
|
||||||
|
prop(CryptoPrice::amount).isGreaterThan(BigDecimal(0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(CryptoException::class)
|
@Throws(CryptoException::class)
|
||||||
fun testApiCall() {
|
fun testApiCall() {
|
||||||
val price = apiCall(listOf("prices", "BTC-USD", "buy"), emptyMap()).toPrice()
|
val price = apiCall(listOf("prices", "BTC-USD", "buy"), emptyMap()).toPrice()
|
||||||
assertEquals("BTC", price.base, "buy BTC")
|
assertThat(price, "apiCall(prices,BTC-USD,buy)").all {
|
||||||
assertEquals("USD", price.currency, "buy BTC is USD")
|
prop(CryptoPrice::base).isEqualTo("BTC")
|
||||||
assertTrue(price.amount.signum() > 0, "buy BTC > 0")
|
prop(CryptoPrice::currency).isEqualTo("USD")
|
||||||
|
prop(CryptoPrice::amount).isGreaterThan(BigDecimal(0))
|
||||||
|
}
|
||||||
val response = apiCall(listOf("exchange-rates"), mapOf("currency" to "usd"))
|
val response = apiCall(listOf("exchange-rates"), mapOf("currency" to "usd"))
|
||||||
val rates = JSONObject(response).getJSONObject("data").getJSONObject("rates")
|
val rates = JSONObject(response).getJSONObject("data").getJSONObject("rates")
|
||||||
assertEquals("1.0", rates.getString("USD"), "usd rate")
|
assertEquals("1.0", rates.getString("USD"), "apiCall(exchange-rates,USD)")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(CryptoException::class)
|
@Throws(CryptoException::class)
|
||||||
fun testPrices() {
|
fun testNotFound() {
|
||||||
assertFailsWith(
|
assertFailsWith(
|
||||||
message = "FOO did not fail",
|
message = "buyPrice(BTC,BAR)",
|
||||||
exceptionClass = CryptoException::class,
|
|
||||||
block = { spotPrice("FOO") }
|
|
||||||
)
|
|
||||||
|
|
||||||
assertFailsWith(
|
|
||||||
message = "BAR did not fail",
|
|
||||||
exceptionClass = CryptoException::class,
|
exceptionClass = CryptoException::class,
|
||||||
block = { buyPrice("BTC", "BAR") }
|
block = { buyPrice("BTC", "BAR") }
|
||||||
)
|
)
|
||||||
|
@ -126,7 +136,11 @@ class CryptoPriceTest {
|
||||||
try {
|
try {
|
||||||
sellPrice("FOOBAR")
|
sellPrice("FOOBAR")
|
||||||
} catch (e: CryptoException) {
|
} catch (e: CryptoException) {
|
||||||
assertNotEquals(400, e.statusCode, "FOOBAR status code is not 400")
|
assertThat(e, "sellPrice(FOOBAR)").all {
|
||||||
|
prop(CryptoException::statusCode).isEqualTo(404)
|
||||||
|
prop(CryptoException::message).isEqualTo("not found")
|
||||||
|
prop(CryptoException::id).isEqualTo("not found")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,33 +149,45 @@ class CryptoPriceTest {
|
||||||
fun testToCurrency() {
|
fun testToCurrency() {
|
||||||
val d = 12345.60.toBigDecimal()
|
val d = 12345.60.toBigDecimal()
|
||||||
val usd = CryptoPrice("BTC", "USD", d)
|
val usd = CryptoPrice("BTC", "USD", d)
|
||||||
assertEquals("$12,345.60", usd.toCurrency(), "USD format")
|
assertEquals("$12,345.60", usd.toCurrency(), "CryptoPrice(BTC,USD)")
|
||||||
|
|
||||||
assertEquals(usd, usd, "USD = USD")
|
assertEquals(usd, usd, "CryptoPrice(BTC,USD) = CryptoPrice(BTC,USD)")
|
||||||
assertNotEquals(usd, CryptoPrice("BTC", "USD", 12345.70.toBigDecimal()), ".60 !- .70")
|
assertNotEquals(
|
||||||
|
usd,
|
||||||
|
CryptoPrice("BTC", "USD", 12345.70.toBigDecimal()),
|
||||||
|
"CryptoPrice(BTC,USD) = CryptoPrice(BTC,USD,BigDecimal)"
|
||||||
|
)
|
||||||
|
|
||||||
val eur = CryptoPrice("BTC", "EUR", d)
|
val eur = CryptoPrice("BTC", "EUR", d)
|
||||||
assertEquals("€12,345.60", eur.toCurrency(), "EUR format")
|
assertEquals("€12,345.60", eur.toCurrency(), "CryptoPrice(BTC,EUR)")
|
||||||
|
|
||||||
assertNotEquals(usd.hashCode(), eur.hashCode(), "hashCode()")
|
assertNotEquals(
|
||||||
assertNotEquals(usd, eur, "USD != EUR")
|
usd.hashCode(),
|
||||||
|
eur.hashCode(),
|
||||||
|
"CryptoPrice(BTC,USD).hashCode != CryptoPrice(BTC,EUR).hashCode"
|
||||||
|
)
|
||||||
|
assertNotEquals(usd, eur, "CryptoPrice(BTC,USD) != CryptoPrice(BTC,EUR)")
|
||||||
|
|
||||||
val gbp = CryptoPrice("ETH", "GBP", d)
|
val gbp = CryptoPrice("ETH", "GBP", d)
|
||||||
assertEquals("£12,345.60", gbp.toCurrency(), "GBP format")
|
assertEquals("£12,345.60", gbp.toCurrency(), "CryptoPrice(ETH,GBP)")
|
||||||
|
|
||||||
assertNotEquals(usd, gbp, "BTC != ETH")
|
assertNotEquals(usd, gbp, "CryptoPrice(BTC,USD) != CryptoPrice(BTC,GBP)")
|
||||||
|
|
||||||
val aud = CryptoPrice("LTC", "AUD", d)
|
val aud = CryptoPrice("LTC", "AUD", d)
|
||||||
assertEquals("A$12,345.60", aud.toCurrency(), "AUD format")
|
assertEquals("A$12,345.60", aud.toCurrency(), "CryptoPrice(LTC,AUD)")
|
||||||
|
|
||||||
val dk = CryptoPrice("BCH", "DKK", d)
|
val dk = CryptoPrice("BCH", "DKK", d)
|
||||||
assertEquals("12.345,60 kr.", dk.toCurrency(Locale("da", "DK")), "EUR-DKK format")
|
assertEquals(
|
||||||
|
"12.345,60 kr.", dk.toCurrency(
|
||||||
|
Locale.Builder().setLanguage("da").setRegion("DK").build()
|
||||||
|
), "CryptoPrice(BCH,DKK)"
|
||||||
|
)
|
||||||
|
|
||||||
val jp = CryptoPrice("BTC", "JPY", d)
|
val jp = CryptoPrice("BTC", "JPY", d)
|
||||||
assertEquals("¥12,345.60", jp.toCurrency(Locale.JAPAN), "EUR-JPY format")
|
assertEquals("¥12,345.60", jp.toCurrency(Locale.JAPAN), "CryptoPrice(BTC,JPY)")
|
||||||
|
|
||||||
assertEquals("$12,345.6000", usd.toCurrency(minFractionDigits = 4), "minFractionDigits = 4")
|
assertEquals("$12,345.6000", usd.toCurrency(minFractionDigits = 4), "toCurrency(minFractionDigits = 4)")
|
||||||
assertEquals("$12,345.6", usd.toCurrency(minFractionDigits = 0), "minFractionDigits = 0")
|
assertEquals("$12,345.6", usd.toCurrency(minFractionDigits = 0), "toCurrency(minFractionDigits = 0)")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -175,34 +201,35 @@ class CryptoPriceTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(CryptoException::class)
|
@Throws(CryptoException::class)
|
||||||
fun testToPrice() {
|
fun testToPrice() {
|
||||||
val d = "57515.60"
|
val d = "57515.60"
|
||||||
val data = jsonData.format(d)
|
val data = jsonData.format(d)
|
||||||
val price = data.toPrice()
|
val price = data.toPrice()
|
||||||
assertEquals("BTC", price.base, "base is BTC")
|
assertThat(price, "toPrice()").all {
|
||||||
assertEquals("USD", price.currency, "currency is USD")
|
prop(CryptoPrice::base).isEqualTo("BTC")
|
||||||
assertEquals(d, price.amount.toString(), "amount is $d")
|
prop(CryptoPrice::currency).isEqualTo("USD")
|
||||||
|
prop(CryptoPrice::amount).isEqualTo(BigDecimal(d))
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals(price, price.toString().toPrice(""), "toPrice('')")
|
assertEquals(price, price.toString().toPrice(""), "toPrice('')")
|
||||||
assertEquals(price, price.toJson("test").toPrice("test"), "toPrice(test)")
|
assertEquals(price, price.toJson("test").toPrice("test"), "toPrice(test)")
|
||||||
|
|
||||||
assertFailsWith(
|
assertFailsWith(
|
||||||
message = "amount conversion did not fail",
|
message = "a.toPrice()",
|
||||||
exceptionClass = CryptoException::class,
|
exceptionClass = CryptoException::class,
|
||||||
block = { data.replace("5", "a").toPrice() }
|
block = { data.replace("5", "a").toPrice() }
|
||||||
)
|
)
|
||||||
|
|
||||||
assertFailsWith(
|
assertFailsWith(
|
||||||
message = "empty did not fail",
|
message = "{}.toPrice()",
|
||||||
exceptionClass = CryptoException::class,
|
exceptionClass = CryptoException::class,
|
||||||
block = { "{}".toPrice() }
|
block = { "{}".toPrice() }
|
||||||
)
|
)
|
||||||
|
|
||||||
assertFailsWith(
|
assertFailsWith(
|
||||||
message = "no base did not fail",
|
message = "foo.toPrice()",
|
||||||
exceptionClass = CryptoException::class,
|
exceptionClass = CryptoException::class,
|
||||||
block = { data.replace("base", "foo").toPrice() }
|
block = { data.replace("base", "foo").toPrice() }
|
||||||
)
|
)
|
||||||
|
@ -215,4 +242,16 @@ class CryptoPriceTest {
|
||||||
assertEquals(json, price.toString(), "toString()")
|
assertEquals(json, price.toString(), "toString()")
|
||||||
assertEquals(price.toString(), price.toJson(""), "toString() = toJson('')")
|
assertEquals(price.toString(), price.toJson(""), "toString() = toJson('')")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
@BeforeAll
|
||||||
|
fun beforeAll() {
|
||||||
|
with(CryptoPrice.logger) {
|
||||||
|
addHandler(ConsoleHandler().apply { level = Level.FINE })
|
||||||
|
level = Level.FINE
|
||||||
|
useParentHandlers = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue