+
+
+
\ No newline at end of file
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..a97931a
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,11 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "java",
+ "name": "Run Tests",
+ "request": "launch",
+ "mainClass": "net.thauvin.erik.crypto.CryptopriceTest"
+ }
+ ]
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..133aa45
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,15 @@
+{
+ "java.project.sourcePaths": [
+ "src/main/java",
+ "src/main/resources",
+ "src/test/java",
+ "src/bld/java"
+ ],
+ "java.configuration.updateBuildConfiguration": "automatic",
+ "java.project.referencedLibraries": [
+ "${HOME}/.bld/dist/bld-1.7.5.jar",
+ "lib/compile/*.jar",
+ "lib/runtime/*.jar",
+ "lib/test/*.jar"
+ ]
+}
diff --git a/LICENSE.txt b/LICENSE.txt
index e7f7d47..194661d 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
+Copyright 2021-2023 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:
diff --git a/README.md b/README.md
index d36883b..1c583ed 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,5 @@
[](https://opensource.org/licenses/BSD-3-Clause)
-[](https://kotlinlang.org/)
-[](https://rife2.com/bld)
+[](https://kotlinlang.org/)
[](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/)
@@ -11,7 +10,7 @@
# Retrieve cryptocurrencies current (buy, sell or spot) prices
-A simple implementation of the prices [Coinbase Public API](https://docs.cdp.coinbase.com/coinbase-app/docs/api-prices).
+A simple implementation of the prices [Coinbase Public API](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices).
## Examples (TL;DR)
@@ -40,7 +39,7 @@ To use with [bld](https://rife2.com/bld), include the following dependency in yo
repositories = List.of(MAVEN_CENTRAL);
scope(compile)
- .include(dependency("net.thauvin.erik:cryptoprice:1.0.2"));
+ .include(dependency("net.thauvin.erik:cryptoprice:1.0.1"));
```
Be sure to use the [bld Kotlin extension](https://github.com/rife2/bld-kotlin) in your project.
@@ -55,7 +54,7 @@ repositories {
}
dependencies {
- implementation("net.thauvin.erik:cryptoprice:1.0.2")
+ implementation("net.thauvin.erik:cryptoprice:1.0.1")
}
```
@@ -94,7 +93,7 @@ A `CryptoPrice` object is returned defined as follows:
```kotlin
CryptoPrice(val base: String, val currency: String, val amount: BigDecimal)
```
-The parameter names match the [Coinbase API](https://docs.cdp.coinbase.com/coinbase-app/docs/api-prices).
+The parameter names match the [Coinbase API](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices).
#### Format
@@ -123,7 +122,7 @@ println(price.toJson())
{"data":{"base":"BTC","currency":"USD","amount":"34567.89"}}
```
-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:
+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:
```kotlin
println(price.toJson("bitcoin"))
@@ -146,7 +145,7 @@ val eth = """{"ether":{"base":"ETH","currency":"USD","amount":"2345.67"}}""".toP
### Extending
-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):
+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):
```kotlin
apiCall(listOf("exchange-rates"), mapOf("currency" to "usd"))
@@ -158,22 +157,3 @@ will return something like:
```
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.
diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml
index ace99d2..7c85194 100644
--- a/bitbucket-pipelines.yml
+++ b/bitbucket-pipelines.yml
@@ -1,20 +1,10 @@
-image: ubuntu:latest
+image: openjdk:17
pipelines:
default:
- step:
name: Test with bld
script:
- # 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
diff --git a/examples/bld/.idea/bld.xml b/examples/bld/.idea/bld.xml
deleted file mode 100644
index 6600cee..0000000
--- a/examples/bld/.idea/bld.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/bld.xml b/examples/bld/.idea/libraries/bld.xml
index af4608e..cf75013 100644
--- a/examples/bld/.idea/libraries/bld.xml
+++ b/examples/bld/.idea/libraries/bld.xml
@@ -2,11 +2,11 @@
-
+
-
+
diff --git a/examples/bld/.idea/libraries/compile.xml b/examples/bld/.idea/libraries/compile.xml
index 99cc0c0..9bd86aa 100644
--- a/examples/bld/.idea/libraries/compile.xml
+++ b/examples/bld/.idea/libraries/compile.xml
@@ -7,7 +7,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/runtime.xml b/examples/bld/.idea/libraries/runtime.xml
index d4069f2..2ae5c4b 100644
--- a/examples/bld/.idea/libraries/runtime.xml
+++ b/examples/bld/.idea/libraries/runtime.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/test.xml b/examples/bld/.idea/libraries/test.xml
index 57ed5ef..b80486a 100644
--- a/examples/bld/.idea/libraries/test.xml
+++ b/examples/bld/.idea/libraries/test.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/misc.xml b/examples/bld/.idea/misc.xml
index d0c8b16..699ae41 100644
--- a/examples/bld/.idea/misc.xml
+++ b/examples/bld/.idea/misc.xml
@@ -12,7 +12,6 @@
diff --git a/examples/gradle/bin/main/com/example/CryptoPriceExample.kt b/examples/gradle/bin/main/com/example/CryptoPriceExample.kt
new file mode 100644
index 0000000..da169d0
--- /dev/null
+++ b/examples/gradle/bin/main/com/example/CryptoPriceExample.kt
@@ -0,0 +1,47 @@
+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
+
+fun main(args: Array) {
+ try {
+ if (args.isNotEmpty()) {
+ val price = if (args.size == 2) spotPrice(args[0], args[1]) else spotPrice(args[0])
+ 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)
+ } catch (e: IllegalArgumentException) {
+ System.err.println("Could not display the specified currency: ${args[1]}")
+ } catch (e: IOException) {
+ System.err.println(e.message)
+ }
+}
diff --git a/examples/gradle/bin/main/com/example/CryptoPriceSample.class b/examples/gradle/bin/main/com/example/CryptoPriceSample.class
new file mode 100644
index 0000000..feb8e49
Binary files /dev/null and b/examples/gradle/bin/main/com/example/CryptoPriceSample.class differ
diff --git a/examples/gradle/build.gradle.kts b/examples/gradle/build.gradle.kts
index 626d902..ea935f5 100644
--- a/examples/gradle/build.gradle.kts
+++ b/examples/gradle/build.gradle.kts
@@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("application")
- id("com.github.ben-manes.versions") version "0.51.0"
- kotlin("jvm") version "2.1.20"
+ id("com.github.ben-manes.versions") version "0.50.0"
+ kotlin("jvm") version "1.9.21"
}
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
@@ -15,8 +15,8 @@ repositories {
}
dependencies {
- implementation("net.thauvin.erik:cryptoprice:1.0.3-SNAPSHOT")
- implementation("org.json:json:20240303")
+ implementation("net.thauvin.erik:cryptoprice:1.0.1-SNAPSHOT")
+ implementation("org.json:json:20231013")
}
java {
@@ -28,11 +28,11 @@ application {
mainClass.set("com.example.CryptoPriceExampleKt")
}
-kotlin {
- compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
-}
-
tasks {
+ withType().configureEach {
+ kotlinOptions.jvmTarget = java.targetCompatibility.toString()
+ }
+
register("runJava") {
group = "application"
mainClass.set("com.example.CryptoPriceSample")
diff --git a/examples/gradle/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/gradle/wrapper/gradle-wrapper.jar
index 1b33c55..7f93135 100644
Binary files a/examples/gradle/gradle/wrapper/gradle-wrapper.jar and b/examples/gradle/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/gradle/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/gradle/wrapper/gradle-wrapper.properties
index ca025c8..3fa8f86 100644
--- a/examples/gradle/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/gradle/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/examples/gradle/gradlew b/examples/gradle/gradlew
index 23d15a9..1aa94a4 100755
--- a/examples/gradle/gradlew
+++ b/examples/gradle/gradlew
@@ -15,8 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-License-Identifier: Apache-2.0
-#
##############################################################################
#
@@ -57,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/HEAD/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/.
@@ -86,7 +84,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -114,7 +112,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
-CLASSPATH="\\\"\\\""
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -205,7 +203,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# * DEFAULT_JVM_OPTS, JAVA_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.
@@ -213,7 +211,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
- -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
diff --git a/examples/gradle/gradlew.bat b/examples/gradle/gradlew.bat
index db3a6ac..93e3f59 100644
--- a/examples/gradle/gradlew.bat
+++ b/examples/gradle/gradlew.bat
@@ -13,8 +13,6 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
-@rem SPDX-License-Identifier: Apache-2.0
-@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
-echo. 1>&2
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+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
@@ -59,22 +57,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo. 1>&2
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+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=
+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%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+"%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
diff --git a/examples/gradle/src/main/kotlin/com/example/CryptoPriceExample.kt b/examples/gradle/src/main/kotlin/com/example/CryptoPriceExample.kt
index 6aa15fc..4eb0a6c 100644
--- a/examples/gradle/src/main/kotlin/com/example/CryptoPriceExample.kt
+++ b/examples/gradle/src/main/kotlin/com/example/CryptoPriceExample.kt
@@ -41,7 +41,7 @@ fun main(args: Array) {
} catch (e: CryptoException) {
System.err.println("HTTP Status Code: ${e.statusCode}")
System.err.println("${e.message} (${e.id})")
- } catch (ignore: IllegalArgumentException) {
+ } catch (e: IllegalArgumentException) {
System.err.println("Could not display the specified currency: ${args[1]}")
} catch (e: IOException) {
System.err.println(e.message)
diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar
index 19f87d3..e029c6d 100644
Binary files a/lib/bld/bld-wrapper.jar and b/lib/bld/bld-wrapper.jar differ
diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties
index 751133d..ac34063 100644
--- a/lib/bld/bld-wrapper.properties
+++ b/lib/bld/bld-wrapper.properties
@@ -1,10 +1,9 @@
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.extension.jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.1
+bld.extensions=com.uwyn.rife2:bld-kotlin:0.9.0-SNAPSHOT
+bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.0-SNAPSHOT
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
+bld.downloadLocation=
bld.sourceDirectories=
-bld.version=2.2.1
+bld.version=1.7.5
diff --git a/pom.xml b/pom.xml
index f3345e6..47da6a8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0net.thauvin.erikcryptoprice
- 1.0.3-SNAPSHOT
+ 1.0.2-SNAPSHOTcryptopriceRetrieve cryptocurrencies priceshttps://github.com/ethauvin/cryptoprice
@@ -18,13 +18,31 @@
org.jetbrains.kotlinkotlin-stdlib
- 2.1.20
+ 1.9.21
+ compile
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-common
+ 1.9.21
+ compile
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk7
+ 1.9.21
+ compile
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ 1.9.21compileorg.jsonjson
- 20250107
+ 20231013compile
diff --git a/src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java b/src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java
index 18b18ec..c33e9eb 100644
--- a/src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java
+++ b/src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java
@@ -1,45 +1,13 @@
-/*
- * 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.DokkaOperation;
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;
@@ -50,21 +18,16 @@ 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");
+ version = version(1, 0, 2, "SNAPSHOT");
mainClass = "net.thauvin.erik.crypto.CryptoPrice";
@@ -73,70 +36,63 @@ public class CryptoPriceBuild extends Project {
autoDownloadPurge = true;
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
- final var kotlin = version(2, 1, 20);
+ final var kotlin = version(1, 9, 21);
scope(compile)
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin))
- .include(dependency("org.json", "json", "20250107"))
+ .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-common", kotlin))
+ .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk7", kotlin))
+ .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk8", kotlin))
+ .include(dependency("org.json", "json", "20231013"))
.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)));
+ .include(dependency("com.willowtreeapps.assertk", "assertk-jvm", version(0, 27, 0)))
+ .include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", version(1, 9, 21)))
+ .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
+ .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1)));
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/")
+ .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")
+ .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)
+ .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);
+ jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
}
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 {
+ public void compile() throws IOException {
new CompileKotlinOperation()
.fromProject(this)
- .compileOptions(new CompileOptions().verbose(true))
.execute();
}
@@ -157,10 +113,9 @@ public class CryptoPriceBuild extends Project {
}
@BuildCommand(summary = "Generates JaCoCo Reports")
- public void jacoco() throws Exception {
+ public void jacoco() throws IOException {
new JacocoReportOperation()
.fromProject(this)
- .sourceFiles(srcMainKotlin)
.execute();
}
@@ -182,12 +137,6 @@ public class CryptoPriceBuild extends Project {
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(),
diff --git a/src/main/kotlin/net/thauvin/erik/crypto/CryptoException.kt b/src/main/kotlin/net/thauvin/erik/crypto/CryptoException.kt
index a4e599b..38fd2df 100644
--- a/src/main/kotlin/net/thauvin/erik/crypto/CryptoException.kt
+++ b/src/main/kotlin/net/thauvin/erik/crypto/CryptoException.kt
@@ -1,7 +1,7 @@
/*
* CryptoException.kt
*
- * Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2021-2023 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:
diff --git a/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt b/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt
index 578efe5..0940aac 100644
--- a/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt
+++ b/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt
@@ -1,7 +1,7 @@
/*
* CryptoPrice.kt
*
- * Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2021-2023 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:
@@ -42,8 +42,6 @@ import java.math.BigDecimal
import java.text.NumberFormat
import java.time.LocalDate
import java.util.*
-import java.util.logging.Level
-import java.util.logging.Logger
/**
* Retrieves and holds a cryptocurrency price.
@@ -59,9 +57,6 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
// Coinbase API URL
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].
*
@@ -110,9 +105,6 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
id = "empty_response",
message = "Empty response."
)
- if (logger.isLoggable(Level.FINE)) {
- logger.fine(body)
- }
try {
val json = JSONObject(body)
if (response.isSuccessful) {
diff --git a/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt b/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt
index fcc64f2..1ac50e5 100644
--- a/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt
@@ -1,7 +1,7 @@
/*
* CryptoPriceTest.kt
*
- * Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2021-2023 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:
@@ -42,12 +42,9 @@ import net.thauvin.erik.crypto.CryptoPrice.Companion.sellPrice
import net.thauvin.erik.crypto.CryptoPrice.Companion.spotPrice
import net.thauvin.erik.crypto.CryptoPrice.Companion.toPrice
import org.json.JSONObject
-import org.junit.jupiter.api.BeforeAll
import java.math.BigDecimal
import java.time.LocalDate
import java.util.*
-import java.util.logging.ConsoleHandler
-import java.util.logging.Level
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
@@ -83,6 +80,7 @@ class CryptoPriceTest {
prop(CryptoPrice::currency).isEqualTo("EUR")
prop(CryptoPrice::amount).isGreaterThan(BigDecimal(0))
}
+
}
}
@@ -242,16 +240,4 @@ class CryptoPriceTest {
assertEquals(json, price.toString(), "toString()")
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
- }
- }
- }
}