diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index 64fbb4d..98a831b 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -9,12 +9,13 @@ env: jobs: build-bld-project: - runs-on: ubuntu-latest - strategy: matrix: java-version: [17, 21, 24] kotlin-version: [1.9.25, 2.1.20] + os: [ ubuntu-latest, windows-latest, macos-latest ] + + runs-on: ${{ matrix.os }} steps: - name: Checkout source repository @@ -28,6 +29,24 @@ jobs: distribution: "zulu" java-version: ${{ matrix.java-version }} + - name: Download dependencies [bld example] + working-directory: examples/bld + run: ./bld download + + - name: Compile and run [bld examples] + working-directory: examples/bld + run: | + ./bld compile run + ./bld run-java + + - name: Run example [bld examples] + working-directory: examples/gradle + if: matrix.java-version != '24' + run: | + ./gradlew run + ./gradlew runJava + + - name: Download dependencies run: ./bld download @@ -39,11 +58,12 @@ jobs: - name: Remove pom.xml if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN - run: rm -rf pom.xml + run: rm -rf pom.xmlAdd debug logging - name: SonarCloud Scan uses: sonarsource/sonarcloud-github-action@master if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN + && martix.os == 'unbuntu-latest' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/examples/bld/lib/bld/bld-wrapper.properties b/examples/bld/lib/bld/bld-wrapper.properties index 1ffe3ff..1f1009d 100644 --- a/examples/bld/lib/bld/bld-wrapper.properties +++ b/examples/bld/lib/bld/bld-wrapper.properties @@ -1,7 +1,7 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.4 +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 diff --git a/examples/gradle/build.gradle.kts b/examples/gradle/build.gradle.kts index d1cd136..626d902 100644 --- a/examples/gradle/build.gradle.kts +++ b/examples/gradle/build.gradle.kts @@ -15,7 +15,7 @@ repositories { } dependencies { - implementation("net.thauvin.erik:cryptoprice:1.0.2") + implementation("net.thauvin.erik:cryptoprice:1.0.3-SNAPSHOT") implementation("org.json:json:20240303") } diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 154abb0..fc9463a 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -1,10 +1,10 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.9 -bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.3 -bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.9 -bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.4 +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-SNAPSHOT +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 diff --git a/src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java b/src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java index c3b1c12..f8df8ed 100644 --- a/src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java +++ b/src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java @@ -121,10 +121,9 @@ public class CryptoPriceBuild extends Project { @BuildCommand(summary = "Compiles the Kotlin project") @Override public void compile() throws Exception { - final var options = new CompileOptions().jvmOptions("--enable-native-access=ALL-UNNAMED"); new CompileKotlinOperation() .fromProject(this) - .compileOptions(options) + .compileOptions(new CompileOptions().verbose(true)) .execute(); } diff --git a/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt b/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt index 3d90e21..578efe5 100644 --- a/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt +++ b/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt @@ -42,6 +42,8 @@ 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. @@ -57,6 +59,9 @@ 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]. * @@ -105,6 +110,9 @@ 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 ce539b5..fcc64f2 100644 --- a/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt +++ b/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt @@ -42,9 +42,12 @@ 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 @@ -239,4 +242,16 @@ 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 + } + } + } }