Compare commits
52 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 |
48 changed files with 577 additions and 260 deletions
|
@ -1,4 +1,8 @@
|
||||||
version: 2
|
version: 2.1
|
||||||
|
|
||||||
|
orbs:
|
||||||
|
sdkman: joshdholtz/sdkman@0.2.0
|
||||||
|
|
||||||
defaults: &defaults
|
defaults: &defaults
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
environment:
|
environment:
|
||||||
|
@ -6,18 +10,31 @@ defaults: &defaults
|
||||||
TERM: dumb
|
TERM: dumb
|
||||||
CI_NAME: "CircleCI"
|
CI_NAME: "CircleCI"
|
||||||
|
|
||||||
defaults_gradle: &defaults_bld
|
commands:
|
||||||
|
build_and_test:
|
||||||
|
parameters:
|
||||||
|
reports-dir:
|
||||||
|
type: string
|
||||||
|
default: "build/reports/test_results"
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
- sdkman/setup-sdkman
|
||||||
|
- sdkman/sdkman-install:
|
||||||
|
candidate: kotlin
|
||||||
|
version: 2.1.10
|
||||||
- run:
|
- run:
|
||||||
name: Download the bld dependencies
|
name: Download dependencies
|
||||||
command: ./bld download
|
command: ./bld download
|
||||||
- run:
|
- run:
|
||||||
name: Compile source with bld
|
name: Compile source
|
||||||
command: ./bld compile
|
command: ./bld compile
|
||||||
- run:
|
- run:
|
||||||
name: Run tests with bld
|
name: Run tests
|
||||||
command: ./bld test
|
command: ./bld jacoco -reports-dir=<< parameters.reports-dir >>
|
||||||
|
- store_test_results:
|
||||||
|
path: << parameters.reports-dir >>
|
||||||
|
- store_artifacts:
|
||||||
|
path: build/reports/jacoco/test/html
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
bld_jdk17:
|
bld_jdk17:
|
||||||
|
@ -26,19 +43,20 @@ jobs:
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/openjdk:17.0
|
- image: cimg/openjdk:17.0
|
||||||
|
|
||||||
<<: *defaults_bld
|
steps:
|
||||||
|
- build_and_test
|
||||||
|
|
||||||
bld_jdk20:
|
bld_jdk21:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/openjdk:20.0
|
- image: cimg/openjdk:21.0
|
||||||
|
|
||||||
<<: *defaults_bld
|
steps:
|
||||||
|
- build_and_test
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
|
||||||
bld:
|
bld:
|
||||||
jobs:
|
jobs:
|
||||||
- bld_jdk17
|
- bld_jdk17
|
||||||
- bld_jdk20
|
- bld_jdk21
|
||||||
|
|
55
.github/workflows/bld.yml
vendored
55
.github/workflows/bld.yml
vendored
|
@ -2,48 +2,67 @@ name: bld-ci
|
||||||
|
|
||||||
on: [ push, pull_request, workflow_dispatch ]
|
on: [ push, pull_request, workflow_dispatch ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
COVERAGE_JDK: "21"
|
||||||
|
COVERAGE_KOTLIN: "2.1.20"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-bld-project:
|
build-bld-project:
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
env:
|
|
||||||
COVERAGE_SDK: "17"
|
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [ 17, 20 ]
|
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:
|
steps:
|
||||||
- name: Checkout source repository
|
- name: Checkout source repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up JDK ${{ matrix.java-version }}
|
- name: Set up JDK ${{ matrix.java-version }} with Kotlin ${{ matrix.kotlin-version }}
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: "zulu"
|
||||||
java-version: ${{ matrix.java-version }}
|
java-version: ${{ matrix.java-version }}
|
||||||
|
|
||||||
- name: Grant bld execute permission
|
- name: Download dependencies [bld example]
|
||||||
run: chmod +x bld
|
working-directory: examples/bld
|
||||||
|
|
||||||
- name: Download the bld dependencies
|
|
||||||
run: ./bld download
|
run: ./bld download
|
||||||
|
|
||||||
- name: Compile source with bld
|
- 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
|
run: ./bld compile
|
||||||
|
|
||||||
- name: Run tests with bld
|
- name: Run tests
|
||||||
run: ./bld jacoco
|
run: ./bld jacoco
|
||||||
|
|
||||||
- name: Remove pom.xml
|
- name: Remove pom.xml
|
||||||
if: success() && matrix.java-version == env.COVERAGE_SDK
|
if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN
|
||||||
|
&& matrix.os == 'ubuntu-latest'
|
||||||
run: rm -rf pom.xml
|
run: rm -rf pom.xml
|
||||||
|
|
||||||
- name: SonarCloud Scan
|
- name: SonarCloud Scan
|
||||||
uses: sonarsource/sonarcloud-github-action@master
|
uses: sonarsource/sonarcloud-github-action@master
|
||||||
if: success() && matrix.java-version == env.COVERAGE_SDK
|
if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN
|
||||||
|
&& matrix.os == 'ubuntu-latest'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
|
|
@ -1,8 +1,21 @@
|
||||||
image: openjdk:17
|
image: fedora:latest
|
||||||
|
|
||||||
|
variables:
|
||||||
|
CI_NAME: "GitLab CI"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- dnf -qy update && dnf -y install 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"
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
|
2
.idea/app.iml
generated
2
.idea/app.iml
generated
|
@ -11,6 +11,8 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
<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/main/kotlin" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
<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>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
|
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>
|
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.9.21" />
|
<option name="version" value="2.0.0" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
4
.idea/libraries/bld.xml
generated
4
.idea/libraries/bld.xml
generated
|
@ -2,12 +2,12 @@
|
||||||
<library name="bld">
|
<library name="bld">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.5.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.5-sources.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<excluded>
|
<excluded>
|
||||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
|
4
.idea/libraries/compile.xml
generated
4
.idea/libraries/compile.xml
generated
|
@ -7,7 +7,7 @@
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
4
.idea/libraries/runtime.xml
generated
4
.idea/libraries/runtime.xml
generated
|
@ -8,7 +8,7 @@
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
4
.idea/libraries/test.xml
generated
4
.idea/libraries/test.xml
generated
|
@ -8,7 +8,7 @@
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
16
.idea/misc.xml
generated
16
.idea/misc.xml
generated
|
@ -5,21 +5,11 @@
|
||||||
<pattern value="net.thauvin.erik.crypto.CryptoPriceBuild" method="jacoco" />
|
<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="detekt" />
|
||||||
<pattern value="net.thauvin.erik.crypto.CryptoPriceBuild" method="detektBaseline" />
|
<pattern value="net.thauvin.erik.crypto.CryptoPriceBuild" method="detektBaseline" />
|
||||||
|
<pattern value="net.thauvin.erik.crypto.CryptoPrice.Companion" method="main" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="PDMPlugin">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<option name="customRuleSets">
|
<file type="web" url="file://$PROJECT_DIR$/examples/gradle" />
|
||||||
<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>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build" />
|
<output url="file://$PROJECT_DIR$/build" />
|
||||||
|
|
9
.idea/runConfigurations/Run Tests.xml
generated
9
.idea/runConfigurations/Run Tests.xml
generated
|
@ -1,9 +0,0 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Run Tests" type="Application" factoryName="Application" nameIsGenerated="true">
|
|
||||||
<option name="MAIN_CLASS_NAME" value="net.thauvin.erik.crypto.CryptopriceTest" />
|
|
||||||
<module name="app" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "Run Tests",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "net.thauvin.erik.crypto.CryptopriceTest"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
15
.vscode/settings.json
vendored
15
.vscode/settings.json
vendored
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"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"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
|
Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
|
||||||
|
|
||||||
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:
|
||||||
|
|
34
README.md
34
README.md
|
@ -1,5 +1,6 @@
|
||||||
[](https://opensource.org/licenses/BSD-3-Clause)
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
||||||
[](https://kotlinlang.org/)
|
[](https://kotlinlang.org/)
|
||||||
|
[](https://rife2.com/bld)
|
||||||
[](https://github.com/ethauvin/cryptoprice/releases/latest)
|
[](https://github.com/ethauvin/cryptoprice/releases/latest)
|
||||||
[](https://central.sonatype.com/artifact/net.thauvin.erik/cryptoprice)
|
[](https://central.sonatype.com/artifact/net.thauvin.erik/cryptoprice)
|
||||||
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/cryptoprice/)
|
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/cryptoprice/)
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
|
|
||||||
# Retrieve cryptocurrencies current (buy, sell or spot) prices
|
# Retrieve cryptocurrencies current (buy, sell or spot) prices
|
||||||
|
|
||||||
A simple 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)
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ To use with [bld](https://rife2.com/bld), include the following dependency in yo
|
||||||
repositories = List.of(MAVEN_CENTRAL);
|
repositories = List.of(MAVEN_CENTRAL);
|
||||||
|
|
||||||
scope(compile)
|
scope(compile)
|
||||||
.include(dependency("net.thauvin.erik:cryptoprice:1.0.1"));
|
.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.
|
Be sure to use the [bld Kotlin extension](https://github.com/rife2/bld-kotlin) in your project.
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.thauvin.erik:cryptoprice:1.0.1")
|
implementation("net.thauvin.erik:cryptoprice:1.0.2")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -93,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
|
||||||
|
|
||||||
|
@ -122,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"))
|
||||||
|
@ -145,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"))
|
||||||
|
@ -157,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,10 +1,20 @@
|
||||||
image: openjdk:17
|
image: ubuntu:latest
|
||||||
|
|
||||||
pipelines:
|
pipelines:
|
||||||
default:
|
default:
|
||||||
- step:
|
- step:
|
||||||
name: Test with bld
|
name: Test with bld
|
||||||
script:
|
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 download
|
||||||
- ./bld compile
|
- ./bld compile
|
||||||
- ./bld test
|
- ./bld test
|
||||||
|
|
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>
|
4
examples/bld/.idea/libraries/bld.xml
generated
4
examples/bld/.idea/libraries/bld.xml
generated
|
@ -2,11 +2,11 @@
|
||||||
<library name="bld">
|
<library name="bld">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.5.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.5-sources.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<excluded>
|
<excluded>
|
||||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
|
4
examples/bld/.idea/libraries/compile.xml
generated
4
examples/bld/.idea/libraries/compile.xml
generated
|
@ -7,7 +7,7 @@
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
4
examples/bld/.idea/libraries/runtime.xml
generated
4
examples/bld/.idea/libraries/runtime.xml
generated
|
@ -8,7 +8,7 @@
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
4
examples/bld/.idea/libraries/test.xml
generated
4
examples/bld/.idea/libraries/test.xml
generated
|
@ -8,7 +8,7 @@
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
1
examples/bld/.idea/misc.xml
generated
1
examples/bld/.idea/misc.xml
generated
|
@ -12,6 +12,7 @@
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-checkstyle/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-exec/config/pmd.xml" />
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-testng/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>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
<option name="skipTestSources" value="false" />
|
<option name="skipTestSources" value="false" />
|
||||||
|
|
10
examples/bld/.vscode/settings.json
vendored
10
examples/bld/.vscode/settings.json
vendored
|
@ -3,13 +3,13 @@
|
||||||
"src/main/java",
|
"src/main/java",
|
||||||
"src/main/resources",
|
"src/main/resources",
|
||||||
"src/test/java",
|
"src/test/java",
|
||||||
"src/bld/java"
|
"src/test/resources",
|
||||||
|
"src/bld/java",
|
||||||
|
"src/bld/resources"
|
||||||
],
|
],
|
||||||
"java.configuration.updateBuildConfiguration": "automatic",
|
"java.configuration.updateBuildConfiguration": "automatic",
|
||||||
"java.project.referencedLibraries": [
|
"java.project.referencedLibraries": [
|
||||||
"${HOME}/.bld/dist/bld-1.7.5.jar",
|
"${HOME}/.bld/dist/bld-2.2.1.jar",
|
||||||
"lib/compile/*.jar",
|
"lib/**/*.jar"
|
||||||
"lib/runtime/*.jar",
|
|
||||||
"lib/test/*.jar"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -1,7 +1,7 @@
|
||||||
bld.downloadExtensionJavadoc=false
|
bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
bld.extensions=com.uwyn.rife2:bld-kotlin:0.9.0-SNAPSHOT
|
|
||||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
|
||||||
bld.downloadLocation=
|
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.sourceDirectories=
|
||||||
bld.version=1.7.5
|
bld.version=2.2.1
|
||||||
|
|
|
@ -25,8 +25,8 @@ public class CryptoPriceExampleBuild extends BaseProject {
|
||||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
|
||||||
|
|
||||||
scope(compile)
|
scope(compile)
|
||||||
.include(dependency("net.thauvin.erik", "cryptoprice", version(1, 0, 2, "SNAPSHOT")))
|
.include(dependency("net.thauvin.erik", "cryptoprice", version(1, 0, 3, "SNAPSHOT")))
|
||||||
.include(dependency("org.json", "json", "20231013"));
|
.include(dependency("org.json", "json", "20250107"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ 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} (${e.id})")
|
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)
|
||||||
|
|
2
examples/gradle/.gitignore
vendored
2
examples/gradle/.gitignore
vendored
|
@ -3,3 +3,5 @@
|
||||||
|
|
||||||
# Ignore Gradle build output directory
|
# Ignore Gradle build output directory
|
||||||
build
|
build
|
||||||
|
|
||||||
|
bin
|
||||||
|
|
1
examples/gradle/.idea/misc.xml
generated
1
examples/gradle/.idea/misc.xml
generated
|
@ -10,6 +10,7 @@
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-checkstyle/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-exec/config/pmd.xml" />
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-testng/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>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
<option name="skipTestSources" value="false" />
|
<option name="skipTestSources" value="false" />
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
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<String>) {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("application")
|
id("application")
|
||||||
id("com.github.ben-manes.versions") version "0.50.0"
|
id("com.github.ben-manes.versions") version "0.51.0"
|
||||||
kotlin("jvm") version "1.9.21"
|
kotlin("jvm") version "2.1.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
||||||
|
@ -15,8 +15,8 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.thauvin.erik:cryptoprice:1.0.1-SNAPSHOT")
|
implementation("net.thauvin.erik:cryptoprice:1.0.3-SNAPSHOT")
|
||||||
implementation("org.json:json:20231013")
|
implementation("org.json:json:20240303")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -28,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
BIN
examples/gradle/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
12
examples/gradle/gradlew
vendored
12
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/HEAD/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/.
|
||||||
|
@ -84,7 +86,7 @@ done
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -112,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.
|
||||||
|
@ -203,7 +205,7 @@ fi
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# 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
|
# * 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.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
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.
|
# Stop when "xargs" is not available.
|
||||||
|
|
26
examples/gradle/gradlew.bat
vendored
26
examples/gradle/gradlew.bat
vendored
|
@ -13,6 +13,8 @@
|
||||||
@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 ##########################################################################
|
||||||
|
@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 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
|
||||||
|
|
||||||
|
@ -57,22 +59,22 @@ 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
|
||||||
|
|
|
@ -41,7 +41,7 @@ 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} (${e.id})")
|
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)
|
||||||
|
|
Binary file not shown.
|
@ -1,9 +1,10 @@
|
||||||
bld.downloadExtensionJavadoc=false
|
bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
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.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.sourceDirectories=
|
||||||
bld.version=1.7.5
|
bld.version=2.2.1
|
||||||
|
|
24
pom.xml
24
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<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.2-SNAPSHOT</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>
|
||||||
|
@ -18,31 +18,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib</artifactId>
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
<version>1.9.21</version>
|
<version>2.1.20</version>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-stdlib-common</artifactId>
|
|
||||||
<version>1.9.21</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-stdlib-jdk7</artifactId>
|
|
||||||
<version>1.9.21</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
|
||||||
<version>1.9.21</version>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20231013</version>
|
<version>20250107</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,13 +1,45 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
package net.thauvin.erik.crypto;
|
||||||
|
|
||||||
import rife.bld.BuildCommand;
|
import rife.bld.BuildCommand;
|
||||||
import rife.bld.Project;
|
import rife.bld.Project;
|
||||||
import rife.bld.extension.CompileKotlinOperation;
|
import rife.bld.extension.CompileKotlinOperation;
|
||||||
import rife.bld.extension.DetektOperation;
|
import rife.bld.extension.DetektOperation;
|
||||||
|
import rife.bld.extension.DokkaOperation;
|
||||||
import rife.bld.extension.JacocoReportOperation;
|
import rife.bld.extension.JacocoReportOperation;
|
||||||
import rife.bld.extension.dokka.DokkaOperation;
|
|
||||||
import rife.bld.extension.dokka.LoggingLevel;
|
import rife.bld.extension.dokka.LoggingLevel;
|
||||||
import rife.bld.extension.dokka.OutputFormat;
|
import rife.bld.extension.dokka.OutputFormat;
|
||||||
|
import rife.bld.extension.kotlin.CompileOptions;
|
||||||
import rife.bld.operations.exceptions.ExitStatusException;
|
import rife.bld.operations.exceptions.ExitStatusException;
|
||||||
import rife.bld.publish.PomBuilder;
|
import rife.bld.publish.PomBuilder;
|
||||||
import rife.bld.publish.PublishDeveloper;
|
import rife.bld.publish.PublishDeveloper;
|
||||||
|
@ -18,16 +50,21 @@ import rife.tools.exceptions.FileUtilsErrorException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
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.Repository.*;
|
||||||
import static rife.bld.dependencies.Scope.compile;
|
import static rife.bld.dependencies.Scope.compile;
|
||||||
import static rife.bld.dependencies.Scope.test;
|
import static rife.bld.dependencies.Scope.test;
|
||||||
|
|
||||||
public class CryptoPriceBuild extends Project {
|
public class CryptoPriceBuild extends Project {
|
||||||
|
final File srcMainKotlin = new File(srcMainDirectory(), "kotlin");
|
||||||
|
|
||||||
public CryptoPriceBuild() {
|
public CryptoPriceBuild() {
|
||||||
pkg = "net.thauvin.erik.crypto";
|
pkg = "net.thauvin.erik.crypto";
|
||||||
name = "cryptoprice";
|
name = "cryptoprice";
|
||||||
version = version(1, 0, 2, "SNAPSHOT");
|
version = version(1, 0, 3, "SNAPSHOT");
|
||||||
|
|
||||||
mainClass = "net.thauvin.erik.crypto.CryptoPrice";
|
mainClass = "net.thauvin.erik.crypto.CryptoPrice";
|
||||||
|
|
||||||
|
@ -36,44 +73,40 @@ public class CryptoPriceBuild extends Project {
|
||||||
autoDownloadPurge = true;
|
autoDownloadPurge = true;
|
||||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
|
||||||
|
|
||||||
final var kotlin = version(1, 9, 21);
|
final var kotlin = version(2, 1, 20);
|
||||||
scope(compile)
|
scope(compile)
|
||||||
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin))
|
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin))
|
||||||
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-common", kotlin))
|
.include(dependency("org.json", "json", "20250107"))
|
||||||
.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)));
|
.include(dependency("com.squareup.okhttp3", "okhttp", version(4, 12, 0)));
|
||||||
scope(test)
|
scope(test)
|
||||||
.include(dependency("com.willowtreeapps.assertk", "assertk-jvm", version(0, 27, 0)))
|
.include(dependency("com.willowtreeapps.assertk", "assertk-jvm", version(0, 28, 1)))
|
||||||
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", version(1, 9, 21)))
|
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1)));
|
.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()
|
publishOperation()
|
||||||
.repository(version.isSnapshot() ? repository(SONATYPE_SNAPSHOTS_LEGACY.location())
|
.repository(version.isSnapshot() ? repository(SONATYPE_SNAPSHOTS_LEGACY.location())
|
||||||
.withCredentials(property("sonatype.user"), property("sonatype.password"))
|
.withCredentials(property("sonatype.user"), property("sonatype.password"))
|
||||||
: repository(SONATYPE_RELEASES_LEGACY.location())
|
: repository(SONATYPE_RELEASES_LEGACY.location())
|
||||||
.withCredentials(property("sonatype.user"), property("sonatype.password")))
|
.withCredentials(property("sonatype.user"), property("sonatype.password")))
|
||||||
|
.repository(repository("github"))
|
||||||
.info()
|
.info()
|
||||||
.groupId("net.thauvin.erik")
|
.groupId("net.thauvin.erik")
|
||||||
.artifactId(name)
|
.artifactId(name)
|
||||||
.description("Retrieve cryptocurrencies prices")
|
.description("Retrieve cryptocurrencies prices")
|
||||||
.url("https://github.com/ethauvin/" + name)
|
.url("https://github.com/ethauvin/" + name)
|
||||||
.developer(
|
.developer(new PublishDeveloper()
|
||||||
new PublishDeveloper()
|
|
||||||
.id("ethauvin")
|
.id("ethauvin")
|
||||||
.name("Erik C. Thauvin")
|
.name("Erik C. Thauvin")
|
||||||
.email("erik@thauvin.net")
|
.email("erik@thauvin.net")
|
||||||
.url("https://erik.thauvin.net/")
|
.url("https://erik.thauvin.net/")
|
||||||
)
|
)
|
||||||
.license(
|
.license(new PublishLicense()
|
||||||
new PublishLicense()
|
|
||||||
.name("BSD 3-Clause")
|
.name("BSD 3-Clause")
|
||||||
.url("https://opensource.org/licenses/BSD-3-Clause")
|
.url("https://opensource.org/licenses/BSD-3-Clause")
|
||||||
)
|
)
|
||||||
.scm(
|
.scm(new PublishScm()
|
||||||
new PublishScm()
|
|
||||||
.connection("scm:git:https://github.com/ethauvin/" + name + ".git")
|
.connection("scm:git:https://github.com/ethauvin/" + name + ".git")
|
||||||
.developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
|
.developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
|
||||||
.url("https://github.com/ethauvin/" + name)
|
.url("https://github.com/ethauvin/" + name)
|
||||||
|
@ -81,18 +114,29 @@ public class CryptoPriceBuild extends Project {
|
||||||
.signKey(property("sign.key"))
|
.signKey(property("sign.key"))
|
||||||
.signPassphrase(property("sign.passphrase"));
|
.signPassphrase(property("sign.passphrase"));
|
||||||
|
|
||||||
jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
|
jarSourcesOperation().sourceDirectories(srcMainKotlin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
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);
|
new CryptoPriceBuild().start(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||||
@Override
|
@Override
|
||||||
public void compile() throws IOException {
|
public void compile() throws Exception {
|
||||||
new CompileKotlinOperation()
|
new CompileKotlinOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
|
.compileOptions(new CompileOptions().verbose(true))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,9 +157,10 @@ public class CryptoPriceBuild extends Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(summary = "Generates JaCoCo Reports")
|
@BuildCommand(summary = "Generates JaCoCo Reports")
|
||||||
public void jacoco() throws IOException {
|
public void jacoco() throws Exception {
|
||||||
new JacocoReportOperation()
|
new JacocoReportOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
|
.sourceFiles(srcMainKotlin)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +182,12 @@ public class CryptoPriceBuild extends Project {
|
||||||
pomRoot();
|
pomRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publishLocal() throws Exception {
|
||||||
|
super.publishLocal();
|
||||||
|
pomRoot();
|
||||||
|
}
|
||||||
|
|
||||||
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
|
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
|
||||||
public void pomRoot() throws FileUtilsErrorException {
|
public void pomRoot() throws FileUtilsErrorException {
|
||||||
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
|
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* CryptoException.kt
|
* CryptoException.kt
|
||||||
*
|
*
|
||||||
* Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
|
* Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
|
||||||
*
|
*
|
||||||
* 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:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* CryptoPrice.kt
|
* CryptoPrice.kt
|
||||||
*
|
*
|
||||||
* Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
|
* Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
|
||||||
*
|
*
|
||||||
* 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:
|
||||||
|
@ -42,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.
|
||||||
|
@ -57,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].
|
||||||
*
|
*
|
||||||
|
@ -105,6 +110,9 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
|
||||||
id = "empty_response",
|
id = "empty_response",
|
||||||
message = "Empty response."
|
message = "Empty response."
|
||||||
)
|
)
|
||||||
|
if (logger.isLoggable(Level.FINE)) {
|
||||||
|
logger.fine(body)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
val json = JSONObject(body)
|
val json = JSONObject(body)
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* CryptoPriceTest.kt
|
* CryptoPriceTest.kt
|
||||||
*
|
*
|
||||||
* Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
|
* Copyright 2021-2025 Erik C. Thauvin (erik@thauvin.net)
|
||||||
*
|
*
|
||||||
* 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:
|
||||||
|
@ -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.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.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
|
||||||
|
@ -80,7 +83,6 @@ class CryptoPriceTest {
|
||||||
prop(CryptoPrice::currency).isEqualTo("EUR")
|
prop(CryptoPrice::currency).isEqualTo("EUR")
|
||||||
prop(CryptoPrice::amount).isGreaterThan(BigDecimal(0))
|
prop(CryptoPrice::amount).isGreaterThan(BigDecimal(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,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