diff --git a/.circleci/config.yml b/.circleci/config.yml index d21cbc7..c781fdc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,54 +1,62 @@ -version: 2 +version: 2.1 + +orbs: + sdkman: joshdholtz/sdkman@0.2.0 + defaults: &defaults working_directory: ~/repo environment: JVM_OPTS: -Xmx3200m TERM: dumb - CI: true + CI_NAME: "CircleCI" -defaults_gradle: &defaults_gradle - steps: - - checkout - - restore_cache: - keys: - - gradle-dependencies-{{ checksum "build.gradle.kts" }} - # fallback to using the latest cache if no exact match is found - - gradle-dependencies- - - run: - name: Gradle Dependencies - command: ./gradlew dependencies - - save_cache: - paths: ~/.m2 - key: gradle-dependencies-{{ checksum "build.gradle.kts" }} - - run: - name: Run All Checks - command: ./gradlew check - - store_artifacts: - path: build/reports/ - destination: reports - - store_test_results: - path: build/reports/ +commands: + build_and_test: + parameters: + reports-dir: + type: string + default: "build/reports/test_results" + steps: + - checkout + - sdkman/setup-sdkman + - sdkman/sdkman-install: + candidate: kotlin + version: 2.1.10 + - run: + name: Download dependencies + command: ./bld download + - run: + name: Compile source + command: ./bld compile + - run: + name: Run tests + command: ./bld jacoco -reports-dir=<< parameters.reports-dir >> + - store_test_results: + path: << parameters.reports-dir >> + - store_artifacts: + path: build/reports/jacoco/test/html jobs: - build_gradle_jdk14: + bld_jdk17: <<: *defaults docker: - - image: openjdk:14-jdk + - image: cimg/openjdk:17.0 - <<: *defaults_gradle + steps: + - build_and_test - build_gradle_jdk8: + bld_jdk21: <<: *defaults docker: - - image: circleci/openjdk:8-jdk + - image: cimg/openjdk:21.0 - <<: *defaults_gradle + steps: + - build_and_test workflows: - version: 2 - gradle: - jobs: - - build_gradle_jdk8 - - build_gradle_jdk14 + bld: + jobs: + - bld_jdk17 + - bld_jdk21 diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml new file mode 100644 index 0000000..068e6c9 --- /dev/null +++ b/.github/workflows/bld.yml @@ -0,0 +1,74 @@ +name: bld-ci + +on: [ push, pull_request, workflow_dispatch ] + +env: + COVERAGE_JDK: "21" + COVERAGE_KOTLIN: "2.1.20" + PINBOARD_API_TOKEN: ${{ secrets.PINBOARD_API_TOKEN }} + +jobs: + build-bld-project: + strategy: + matrix: + java-version: [ 17, 21, 24 ] + kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ] + os: [ ubuntu-latest, windows-latest, macos-latest ] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout source repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK ${{ matrix.java-version }} with Kotlin ${{ matrix.kotlin-version }} + uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: ${{ matrix.java-version }} + + - name: Download dependencies [bld example] + working-directory: examples/bld + run: ./bld download + + - name: Compile and run [bld examples] + working-directory: examples/bld + run: | + ./bld compile run + ./bld run-java + + - name: Run example [gradle java example] + working-directory: examples/gradle/java + if: matrix.java-version != '24' + run: | + ./gradlew run + + - name: Run example [gradle kotlin example] + working-directory: examples/gradle/kotlin + if: matrix.java-version != '24' + run: | + ./gradlew run + + - name: Download dependencies + run: ./bld download + + - name: Compile source + run: ./bld compile + + - name: Run tests + run: ./bld jacoco + + - name: Remove pom.xml + if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN + && matrix.os == 'ubuntu-latest' + run: rm -rf pom.xml + + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN + && matrix.os == 'ubuntu-latest' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 540b054..0000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Java CI with Gradle - -on: [push, pull_request, workflow_dispatch] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Test with Gradle - run: ./gradlew check - env: - PINBOARD_API_TOKEN: ${{ secrets.PINBOARD_API_TOKEN }} diff --git a/.github_changelog_generator b/.github_changelog_generator index 6236107..19e45d2 100644 --- a/.github_changelog_generator +++ b/.github_changelog_generator @@ -1 +1 @@ -future-release=1.0.2 +future-release=1.1.0 diff --git a/.gitignore b/.gitignore index 9dda44b..3402a75 100644 --- a/.gitignore +++ b/.gitignore @@ -1,47 +1,58 @@ -!.vscode/extensions.json -!.vscode/launch.json -!.vscode/settings.json -!.vscode/tasks.json -**/*.class -**/.idea/**/dataSources.ids -**/.idea/**/dataSources.local.xml -**/.idea/**/dataSources/ -**/.idea/**/dbnavigator.xml -**/.idea/**/dictionaries -**/.idea/**/dynamic.xml -**/.idea/**/gradle.xml -**/.idea/**/libraries -**/.idea/**/shelf -**/.idea/**/sqlDataSources.xml -**/.idea/**/tasks.xml -**/.idea/**/uiDesigner.xml -**/.idea/**/usage.statistics.xml -**/.idea/**/workspace.xml -*.code-workspace -*.iws -*.sublime-* -.DS_Store -.classpath .gradle -.kobalt -.nb-gradle -.project -.settings -.vscode/* -/bin -/build -/deploy -/dist -/gen -/gradle.properties -/local.properties -/out -/proguard-project.txt -/project.properties -/target -/test-output -Thumbs.db -ehthumbs.db -kobaltBuild -kobaltw*-test -pom.xml.asc +.DS_Store +build +lib/bld/** +!lib/bld/bld-wrapper.jar +!lib/bld/bld-wrapper.properties +lib/compile/ +lib/runtime/ +lib/standalone/ +lib/test/ + +# IDEA ignores + +# User-specific +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Editor-based Rest Client +.idea/httpRequests + + +local.properties diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 26820aa..10b9b0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,31 +1,24 @@ -image: gradle:alpine +image: fedora:latest variables: - GRADLE_OPTS: "-Dorg.gradle.daemon=false" - -before_script: - - export GRADLE_USER_HOME=`pwd`/.gradle + CI_NAME: "GitLab CI" stages: - - build - test -build: - stage: build - script: ./gradlew --build-cache assemble - cache: - key: "$CI_COMMIT_REF_NAME" - policy: push - paths: - - build - - .gradle +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: stage: test - script: ./gradlew check - cache: - key: "$CI_COMMIT_REF_NAME" - policy: pull - paths: - - build - - .gradle + script: + - ./bld download + - ./bld compile + - ./bld test diff --git a/.idea/app.iml b/.idea/app.iml new file mode 100644 index 0000000..2c1fe21 --- /dev/null +++ b/.idea/app.iml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/bld.iml b/.idea/bld.iml new file mode 100644 index 0000000..e63e11e --- /dev/null +++ b/.idea/bld.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/bld.xml similarity index 54% rename from .idea/encodings.xml rename to .idea/bld.xml index 97626ba..6600cee 100644 --- a/.idea/encodings.xml +++ b/.idea/bld.xml @@ -1,6 +1,6 @@ - - + + \ No newline at end of file diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml deleted file mode 100644 index 95c433c..0000000 --- a/.idea/checkstyle-idea.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index d91f848..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 4e8da37..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/Erik_s_Copyright_Notice.xml b/.idea/copyright/Erik_s_Copyright_Notice.xml index 82870eb..ab1f825 100644 --- a/.idea/copyright/Erik_s_Copyright_Notice.xml +++ b/.idea/copyright/Erik_s_Copyright_Notice.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml index b03a87e..1419e40 100644 --- a/.idea/copyright/profiles_settings.xml +++ b/.idea/copyright/profiles_settings.xml @@ -1,15 +1,3 @@ - - - - - - - - - + \ No newline at end of file diff --git a/.idea/icon.svg b/.idea/icon.svg new file mode 100644 index 0000000..94a6708 --- /dev/null +++ b/.idea/icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 8ff795e..94f28ea 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,53 +1,9 @@ \ No newline at end of file diff --git a/.idea/kotlinScripting.xml b/.idea/kotlinScripting.xml deleted file mode 100644 index bc444de..0000000 --- a/.idea/kotlinScripting.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index 5a05248..0000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml new file mode 100644 index 0000000..153a060 --- /dev/null +++ b/.idea/libraries/bld.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/.idea/libraries/compile.xml b/.idea/libraries/compile.xml new file mode 100644 index 0000000..99cc0c0 --- /dev/null +++ b/.idea/libraries/compile.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/runtime.xml b/.idea/libraries/runtime.xml new file mode 100644 index 0000000..d4069f2 --- /dev/null +++ b/.idea/libraries/runtime.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/test.xml b/.idea/libraries/test.xml new file mode 100644 index 0000000..57ed5ef --- /dev/null +++ b/.idea/libraries/test.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 794aa67..2adb169 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,27 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 0cc12b3..55adcb9 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,16 +2,8 @@ - - - - - - - - - - + + \ No newline at end of file diff --git a/.idea/modules/kotlin.samples-kotlin.iml b/.idea/modules/kotlin.samples-kotlin.iml deleted file mode 100644 index 16c524b..0000000 --- a/.idea/modules/kotlin.samples-kotlin.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/kotlin.samples-kotlin.main.iml b/.idea/modules/kotlin.samples-kotlin.main.iml deleted file mode 100644 index fbd1150..0000000 --- a/.idea/modules/kotlin.samples-kotlin.main.iml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/kotlin.samples-kotlin.test.iml b/.idea/modules/kotlin.samples-kotlin.test.iml deleted file mode 100644 index 2b9c8df..0000000 --- a/.idea/modules/kotlin.samples-kotlin.test.iml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/pinboard-poster.main.iml b/.idea/modules/pinboard-poster.main.iml deleted file mode 100644 index d1e6600..0000000 --- a/.idea/modules/pinboard-poster.main.iml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/pinboard-poster.test.iml b/.idea/modules/pinboard-poster.test.iml deleted file mode 100644 index 72b3d91..0000000 --- a/.idea/modules/pinboard-poster.test.iml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/samples-java.iml b/.idea/modules/samples-java.iml deleted file mode 100644 index 19b4065..0000000 --- a/.idea/modules/samples-java.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/samples-java.main.iml b/.idea/modules/samples-java.main.iml deleted file mode 100644 index 9a2896e..0000000 --- a/.idea/modules/samples-java.main.iml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/samples-java.test.iml b/.idea/modules/samples-java.test.iml deleted file mode 100644 index 100a3c5..0000000 --- a/.idea/modules/samples-java.test.iml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Run Tests.xml b/.idea/runConfigurations/Run Tests.xml new file mode 100644 index 0000000..2d4326e --- /dev/null +++ b/.idea/runConfigurations/Run Tests.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/.idea/scopes/Source.xml b/.idea/scopes/Source.xml deleted file mode 100644 index 942e059..0000000 --- a/.idea/scopes/Source.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 48c5805..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: java -dist: trusty - -env: - global: - - CI=true - -#install: -# - git fetch --unshallow --tags - -addons: - sonarcloud: - organization: "ethauvin-github" - -jdk: - - oraclejdk8 - - openjdk14 - -before_install: - - chmod +x gradlew - -after_success: - - | - if [ "${TRAVIS_TEST_RESULT}" == 0 ] && [ "$TRAVIS_JDK_VERSION" == "openjdk14" ]; then - ./gradlew sonarqube - fi diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f25500c --- /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.pinboard.PinboardPosterTest" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ba429d0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "java.project.sourcePaths": [ + "src/main/java", + "src/main/resources", + "src/test/java", + "src/test/resources", + "src/bld/java", + "src/bld/resources" + ], + "java.configuration.updateBuildConfiguration": "automatic", + "java.project.referencedLibraries": [ + "${HOME}/.bld/dist/bld-2.2.1.jar", + "lib/**/*.jar" + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 366e7bd..9c318e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,26 @@ # Changelog -## [1.0.2](https://github.com/ethauvin/pinboard-poster/tree/1.0.2) (2021-03-21) +## [1.1.0](https://github.com/ethauvin/pinboard-poster/tree/1.1.0) (2023-09-28) + +[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/1.0.3...1.1.0) + +**Implemented enhancements:** + +- Add pin config builder [\#10](https://github.com/ethauvin/pinboard-poster/issues/10) + +**Fixed bugs:** + +- Fixed potential resource leak [\#11](https://github.com/ethauvin/pinboard-poster/issues/11) + +## [1.0.3](https://github.com/ethauvin/pinboard-poster/tree/1.0.3) (2021-03-22) + +[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/1.0.2...1.0.3) + +**Fixed bugs:** + +- 1.0.2 only compiled for Java 15 [\#4](https://github.com/ethauvin/pinboard-poster/issues/4) + +## [1.0.2](https://github.com/ethauvin/pinboard-poster/tree/1.0.2) (2021-03-22) [Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/1.0.1...1.0.2) diff --git a/LICENSE.txt b/LICENSE.txt index 8e33202..9926d00 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2017-2021, Erik C. Thauvin (erik@thauvin.net) +Copyright (c) 2017-2025, Erik C. Thauvin (erik@thauvin.net) All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 2a6f5cf..cdf7df5 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,18 @@ -# [Pinboard](https://pinboard.in) Poster for Kotlin/Java +# [Pinboard](https://pinboard.in) Poster for Kotlin, Java and Android -[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](http://opensource.org/licenses/BSD-3-Clause) [![Release](https://img.shields.io/github/release/ethauvin/pinboard-poster.svg)](https://github.com/ethauvin/pinboard-poster/releases/latest) [![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/pinboard-poster.svg?label=maven%20central)](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22pinboard-poster%22) +[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-3-Clause) +[![Kotlin](https://img.shields.io/badge/kotlin-2.1.20-7f52ff)](https://kotlinlang.org/) +[![bld](https://img.shields.io/badge/2.2.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) +[![Release](https://img.shields.io/github/release/ethauvin/pinboard-poster.svg)](https://github.com/ethauvin/pinboard-poster/releases/latest) +[![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/pinboard-poster.svg?color=blue)](https://central.sonatype.com/artifact/net.thauvin.erik/pinboard-poster) +[![Nexus Snapshot](https://img.shields.io/nexus/s/net.thauvin.erik/pinboard-poster?label=snapshot&server=https%3A%2F%2Foss.sonatype.org%2F)](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/pinboard-poster/) -[![Known Vulnerabilities](https://snyk.io/test/github/ethauvin/pinboard-poster/badge.svg?targetFile=pom.xml)](https://snyk.io/test/github/ethauvin/pinboard-poster?targetFile=pom.xml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_pinboard-poster&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_pinboard-poster) [![Build Status](https://travis-ci.com/ethauvin/pinboard-poster.svg?branch=master)](https://travis-ci.com/ethauvin/pinboard-poster) [![CircleCI](https://circleci.com/gh/ethauvin/pinboard-poster/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/pinboard-poster/tree/master) -A small Kotlin/Java/Android library for posting to [Pinboard](https://pinboard.in). +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_pinboard-poster&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_pinboard-poster) +[![GitHub CI](https://github.com/ethauvin/pinboard-poster/actions/workflows/bld.yml/badge.svg)](https://github.com/ethauvin/pinboard-poster/actions/workflows/bld.yml) +[![CircleCI](https://circleci.com/gh/ethauvin/pinboard-poster/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/pinboard-poster/tree/master) + +A small library for posting to [Pinboard](https://pinboard.in). ## Examples @@ -14,51 +22,80 @@ A small Kotlin/Java/Android library for posting to [Pinboard](https://pinboard.i val poster = PinboardPoster("user:TOKEN") -poster.addPin("http://www.example.com/foo", "This is a test") -poster.deletePin("http:///www.example.com/bar") +poster.addPin("https://example.com/foo", "This is a test") +poster.addPin("https://example.com", "This is a test", tags = arrayOf("foo", "bar")) +poster.deletePin("https://example.com/bar") ``` -[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/samples/kotlin/src/main/kotlin/net/thauvin/erik/pinboard/samples/KotlinExample.kt) + +[View Examples](https://github.com/ethauvin/pinboard-poster/blob/master/examples) ### Java + ```java final PinboardPoster poster = new PinBboardPoster("user:TOKEN"); -poster.addPin("http://www.example.com/foo", "This is a test"); -poster.deletePin("http:///www.example.com/bar"); +poster.addPin("https://example.com/foo", "This is a test"); +poster.addPin(new PinConfig.Builder("https://example.com", "This is a test") + .tags("foo", "bar") + .build()); +poster.deletePin("https://example.com/bar"); ``` -[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/samples/java/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java) + +[View Examples](https://github.com/ethauvin/pinboard-poster/blob/master/examples) Your API authentication token is available on the [Pinboard settings page](https://pinboard.in/settings/password). -## Usage with Gradle, Maven, etc. +## bld -To install and run from Gradle, add the following to the build.gradle file: +To use with [bld](https://rife2.com/bld), include the following dependency in your [build](https://github.com/ethauvin/pinboard-poster/blob/master/examples/bld/src/bld/java/net/thauvin/erik/pinboard/samples/ExampleBuild.java) file: + +```java +repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY); + +scope(compile) + .include(dependency("net.thauvin.erik:pinboard-poster:1.2.0")); +``` +Be sure to use the [bld Kotlin extension](https://github.com/rife2/bld-kotlin) in your project. + +[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/examples/bld/) + +## Gradle, Maven, etc. + +To install and run from Gradle, add the following to the `build.gradle` file: ```gradle +repositories { + mavenCentral() +} + dependencies { - compile 'net.thauvin.erik:pinboard-poster:1.0.2' + compile 'net.thauvin.erik:pinboard-poster:1.2.0' } ``` -[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/samples/java/build.gradle) -[View Kotlin DSL Example](https://github.com/ethauvin/pinboard-poster/blob/master/samples/kotlin/build.gradle.kts) -Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/artifact/net.thauvin.erik/pinboard-poster/1.0.2/jar). +[View Examples](https://github.com/ethauvin/pinboard-poster/blob/master/examples/gradle/) + +Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/pinboard-poster). ## Adding The `addPin` function support all of the [Pinboard API parameters](https://pinboard.in/api/#posts_add): ```kotlin -poster.addPin(url = "http://www.example.com", - description = "This is the title", - extended = "This is the extended description.", - tags = "tag1 tag2 tag3", - dt = "2010-12-11T19:48:02Z", - replace = true, - shared = true, - toRead = false) +import java.time.ZonedDateTime + +poster.addPin( + url = "https://www.example.com", + description = "This is the title", + extended = "This is the extended description.", + tags = arrayOf("tag1", "tag2", "tag3"), + dt = ZonedDateTime.now(), + replace = true, + shared = true, + toRead = false +) ``` `url` and `description` are required. @@ -70,7 +107,7 @@ It returns `true` if the bookmark was added successfully, `false` otherwise. The `deletePin` function support all of the [Pinboard API parameters](https://pinboard.in/api/#posts_delete): ```kotlin -poster.deletePin(url = "http://www.example.com/") +poster.deletePin(url = "https://www.example.com/") ``` It returns `true` if the bookmark was deleted successfully, `false` otherwise. @@ -80,19 +117,24 @@ It returns `true` if the bookmark was deleted successfully, `false` otherwise. The library used [`java.util.logging`](https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html) to log errors. Logging can be configured as follows: #### Kotlin + ```kotlin with(poster.logger) { addHandler(ConsoleHandler().apply { level = Level.FINE }) level = Level.FINE + useParentHandlers = false } ``` + #### Java + ```java final ConsoleHandler consoleHandler = new ConsoleHandler(); consoleHandler.setLevel(Level.FINE); final Logger logger = poster.getLogger(); logger.addHandler(consoleHandler); logger.setLevel(Level.FINE); +logger.setUseParentHandlers(false); ``` or using a logging properties file. @@ -155,3 +197,21 @@ The API end point is automatically configured to `https://api.pinboard.in/v1/`. ```kotlin poster.apiEndPoint = "https://www.example.com/v1" ``` + +## 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/pinboard-poster.git +``` + +Then use [bld](https://rife2.com/bld) to build: + +```console +cd pinboard-poster +./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 7d98402..ace99d2 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -1,9 +1,20 @@ -image: openjdk:8 +image: ubuntu:latest pipelines: default: - step: - caches: - - gradle + name: Test with bld script: - - bash ./gradlew check + # Install latest Java & Kotlin via SDKMAN! + - apt-get update -qq && apt-get install -y curl zip + - curl -s "https://get.sdkman.io" | bash + - echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config + - echo sdkman_auto_selfupdate=true >> $HOME/.sdkman/etc/config + - source "$HOME/.sdkman/bin/sdkman-init.sh" + - sdk install java + - sdk install kotlin + - source "$HOME/.sdkman/bin/sdkman-init.sh" + # Download, compile and test with bld + - ./bld download + - ./bld compile + - ./bld test diff --git a/bld b/bld new file mode 100755 index 0000000..3c1df97 --- /dev/null +++ b/bld @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.pinboard.PinboardPosterBuild "$@" diff --git a/bld.bat b/bld.bat new file mode 100644 index 0000000..1262822 --- /dev/null +++ b/bld.bat @@ -0,0 +1,4 @@ +@echo off +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.pinboard.PinboardPosterBuild %* diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index 7ec04ba..0000000 --- a/build.gradle.kts +++ /dev/null @@ -1,192 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - jacoco - java - kotlin("jvm") version "1.4.31" - `maven-publish` - signing - id("com.github.ben-manes.versions") version "0.38.0" - id("io.gitlab.arturbosch.detekt") version "1.16.0" - id("org.jetbrains.dokka") version "1.4.30" - id("org.sonarqube") version "3.1.1" -} - -group = "net.thauvin.erik" -version = "1.0.2" -description = "Pinboard Poster for Kotlin/Java" - -val gitHub = "ethauvin/$name" -val mavenUrl = "https://github.com/$gitHub" -val deployDir = "deploy" -var isRelease = "release" in gradle.startParameter.taskNames - -val publicationName = "mavenJava" - -object VersionInfo { - const val okhttp = "4.9.1" -} - -val versions: VersionInfo by extra { VersionInfo } - -repositories { - mavenCentral() - jcenter() // needed for Dokka -} - -dependencies { - implementation("com.squareup.okhttp3:okhttp:${versions.okhttp}") - implementation("com.squareup.okhttp3:logging-interceptor:${versions.okhttp}") - - testImplementation("org.testng:testng:7.4.0") -} - -java { - withSourcesJar() -} - -detekt { - baseline = project.rootDir.resolve("config/detekt/baseline.xml") -} - -sonarqube { - properties { - property("sonar.projectKey", "ethauvin_pinboard-poster") - property("sonar.sourceEncoding", "UTF-8") - } -} - -val javadocJar by tasks.creating(Jar::class) { - dependsOn(tasks.dokkaJavadoc) - from(tasks.dokkaJavadoc) - archiveClassifier.set("javadoc") - description = "Assembles a JAR of the generated Javadoc." - group = JavaBasePlugin.DOCUMENTATION_GROUP -} - -tasks { - withType { - useTestNG() - } - - withType { - reports { - xml.isEnabled = true - html.isEnabled = true - } - } - - withType { - kotlinOptions.jvmTarget = "1.8" - } - - withType { - destination = file("$projectDir/pom.xml") - } - - assemble { - dependsOn(javadocJar) - } - - clean { - doLast { - project.delete(fileTree(deployDir)) - } - } - - val copyToDeploy by registering(Copy::class) { - from(configurations.runtime) { - exclude("annotations-*.jar") - } - from(jar) - into(deployDir) - } - - register("deploy") { - description = "Copies all needed files to the $deployDir directory." - group = PublishingPlugin.PUBLISH_TASK_GROUP - dependsOn("build", "jar") - outputs.dir(deployDir) - inputs.files(copyToDeploy) - mustRunAfter("clean") - } - - val gitIsDirty by registering(Exec::class) { - description = "Fails if git has uncommitted changes." - group = "verification" - commandLine("git", "diff", "--quiet", "--exit-code") - } - - val gitTag by registering(Exec::class) { - description = "Tags the local repository with version ${project.version}" - group = PublishingPlugin.PUBLISH_TASK_GROUP - dependsOn(gitIsDirty) - if (isRelease) { - commandLine("git", "tag", "-a", project.version, "-m", "Version ${project.version}") - } - } - - buildScan { - termsOfServiceUrl = "https://gradle.com/terms-of-service" - setTermsOfServiceAgree("yes") - } - - register("release") { - description = "Publishes version ${project.version} to local repository." - group = PublishingPlugin.PUBLISH_TASK_GROUP - dependsOn("wrapper", "deploy", "gitTag", "publishToMavenLocal") - } - - "sonarqube" { - dependsOn("jacocoTestReport") - } -} - -publishing { - publications { - create(publicationName) { - from(components["java"]) - artifact(javadocJar) - pom { - name.set(project.name) - description.set(project.description) - url.set(mavenUrl) - licenses { - license { - name.set("BSD 3-Clause") - url.set("https://opensource.org/licenses/BSD-3-Clause") - } - } - developers { - developer { - id.set("ethauvin") - name.set("Erik C. Thauvin") - email.set("erik@thauvin.net") - url.set("https://erik.thauvin.net/") - } - } - scm { - connection.set("scm:git:git://github.com/$gitHub.git") - developerConnection.set("scm:git:git@github.com:$gitHub.git") - url.set("$mavenUrl") - } - issueManagement { - system.set("GitHub") - url.set("$mavenUrl/issues") - } - } - } - } - repositories { - maven { - name = "ossrh" - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials(PasswordCredentials::class) - } - } -} - -signing { - useGpgCmd() - sign(publishing.publications[publicationName]) -} diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index 23161d0..3f97ec1 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -1,11 +1,11 @@ - - - ComplexMethod:PinboardPoster.kt$PinboardPoster$private fun executeMethod(method: String, params: List<Pair<String, String>>): Boolean - LongParameterList:PinboardPoster.kt$PinboardPoster$( url: String, description: String, extended: String = "", tags: String = "", dt: String = "", replace: Boolean = true, shared: Boolean = true, toRead: Boolean = false ) - NestedBlockDepth:PinboardPoster.kt$PinboardPoster$private fun executeMethod(method: String, params: List<Pair<String, String>>): Boolean - ThrowsCount:PinboardPoster.kt$PinboardPoster$internal fun parseMethodResponse(method: String, response: String) - TooGenericExceptionCaught:PinboardPoster.kt$PinboardPoster$e: Exception - - \ No newline at end of file + + + LongParameterList:PinConfig.kt$PinConfig$( var url: String, var description: String, var extended: String = "", var tags: Array<out String> = emptyArray(), var dt: ZonedDateTime = ZonedDateTime.now(), var replace: Boolean = true, var shared: Boolean = true, var toRead: Boolean = false ) + LongParameterList:PinboardPoster.kt$PinboardPoster$( url: String, description: String, extended: String = "", vararg tags: String = emptyArray(), dt: ZonedDateTime = ZonedDateTime.now(), replace: Boolean = true, shared: Boolean = true, toRead: Boolean = false ) + NestedBlockDepth:PinboardPoster.kt$PinboardPoster$private fun executeMethod(method: String, params: Map<String, String>): Boolean + ThrowsCount:PinboardPoster.kt$PinboardPoster$@Throws(IOException::class) internal fun parseMethodResponse(method: String, response: String) + TooManyFunctions:PinConfig.kt$PinConfig$Builder + + diff --git a/examples/bld/.gitignore b/examples/bld/.gitignore new file mode 100644 index 0000000..a2805aa --- /dev/null +++ b/examples/bld/.gitignore @@ -0,0 +1,55 @@ +.gradle +.DS_Store +build +lib/bld/** +!lib/bld/bld-wrapper.jar +!lib/bld/bld-wrapper.properties +lib/compile/ +lib/runtime/ +lib/standalone/ +lib/test/ + +# IDEA ignores + +# User-specific +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Editor-based Rest Client +.idea/httpRequests \ No newline at end of file diff --git a/examples/bld/.idea/.gitignore b/examples/bld/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/examples/bld/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/examples/bld/.idea/.name b/examples/bld/.idea/.name new file mode 100644 index 0000000..6782949 --- /dev/null +++ b/examples/bld/.idea/.name @@ -0,0 +1 @@ +pinboard-poster-examples-bld \ No newline at end of file diff --git a/examples/bld/.idea/app.iml b/examples/bld/.idea/app.iml new file mode 100644 index 0000000..2d05353 --- /dev/null +++ b/examples/bld/.idea/app.iml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/bld.iml b/examples/bld/.idea/bld.iml new file mode 100644 index 0000000..e63e11e --- /dev/null +++ b/examples/bld/.idea/bld.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/bld.xml b/examples/bld/.idea/bld.xml new file mode 100644 index 0000000..6600cee --- /dev/null +++ b/examples/bld/.idea/bld.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/inspectionProfiles/Project_Default.xml b/examples/bld/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..1e01b48 --- /dev/null +++ b/examples/bld/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/examples/bld/.idea/libraries/bld.xml b/examples/bld/.idea/libraries/bld.xml new file mode 100644 index 0000000..153a060 --- /dev/null +++ b/examples/bld/.idea/libraries/bld.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/examples/bld/.idea/libraries/compile.xml b/examples/bld/.idea/libraries/compile.xml new file mode 100644 index 0000000..99cc0c0 --- /dev/null +++ b/examples/bld/.idea/libraries/compile.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/libraries/runtime.xml b/examples/bld/.idea/libraries/runtime.xml new file mode 100644 index 0000000..d4069f2 --- /dev/null +++ b/examples/bld/.idea/libraries/runtime.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/libraries/test.xml b/examples/bld/.idea/libraries/test.xml new file mode 100644 index 0000000..57ed5ef --- /dev/null +++ b/examples/bld/.idea/libraries/test.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/misc.xml b/examples/bld/.idea/misc.xml new file mode 100644 index 0000000..f522a9e --- /dev/null +++ b/examples/bld/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/examples/bld/.idea/modules.xml b/examples/bld/.idea/modules.xml new file mode 100644 index 0000000..55adcb9 --- /dev/null +++ b/examples/bld/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/runConfigurations/Run Tests.xml b/examples/bld/.idea/runConfigurations/Run Tests.xml new file mode 100644 index 0000000..e5f873f --- /dev/null +++ b/examples/bld/.idea/runConfigurations/Run Tests.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/examples/bld/.idea/vcs.xml b/examples/bld/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/examples/bld/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/examples/bld/.vscode/launch.json b/examples/bld/.vscode/launch.json new file mode 100644 index 0000000..b183bbe --- /dev/null +++ b/examples/bld/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Run Tests", + "request": "launch", + "mainClass": "net.thauvin.erik.pinboard.samples.JavaExampleTest" + } + ] +} diff --git a/examples/bld/.vscode/settings.json b/examples/bld/.vscode/settings.json new file mode 100644 index 0000000..ba429d0 --- /dev/null +++ b/examples/bld/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "java.project.sourcePaths": [ + "src/main/java", + "src/main/resources", + "src/test/java", + "src/test/resources", + "src/bld/java", + "src/bld/resources" + ], + "java.configuration.updateBuildConfiguration": "automatic", + "java.project.referencedLibraries": [ + "${HOME}/.bld/dist/bld-2.2.1.jar", + "lib/**/*.jar" + ] +} diff --git a/examples/bld/README.md b/examples/bld/README.md new file mode 100644 index 0000000..ad5401c --- /dev/null +++ b/examples/bld/README.md @@ -0,0 +1,18 @@ +## Kotlin Example +To compile & run the Kotlin example: + +```console +./bld compile + +./bld run +``` + +## Java Example + +To compile & run the Java example: + +```console +./bld compile + +./bld run-java +``` diff --git a/examples/bld/bld b/examples/bld/bld new file mode 100755 index 0000000..1a39c97 --- /dev/null +++ b/examples/bld/bld @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.pinboard.samples.ExampleBuild "$@" diff --git a/examples/bld/bld.bat b/examples/bld/bld.bat new file mode 100644 index 0000000..6357553 --- /dev/null +++ b/examples/bld/bld.bat @@ -0,0 +1,4 @@ +@echo off +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.pinboard.samples.ExampleBuild %* diff --git a/examples/bld/lib/bld/bld-wrapper.jar b/examples/bld/lib/bld/bld-wrapper.jar new file mode 100644 index 0000000..968a8ab Binary files /dev/null and b/examples/bld/lib/bld/bld-wrapper.jar differ diff --git a/examples/bld/lib/bld/bld-wrapper.properties b/examples/bld/lib/bld/bld-wrapper.properties new file mode 100644 index 0000000..1f1009d --- /dev/null +++ b/examples/bld/lib/bld/bld-wrapper.properties @@ -0,0 +1,7 @@ +bld.downloadExtensionJavadoc=false +bld.downloadExtensionSources=true +bld.downloadLocation= +bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT +bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES +bld.sourceDirectories= +bld.version=2.2.1 diff --git a/examples/bld/src/bld/java/net/thauvin/erik/pinboard/samples/ExampleBuild.java b/examples/bld/src/bld/java/net/thauvin/erik/pinboard/samples/ExampleBuild.java new file mode 100644 index 0000000..6fc8142 --- /dev/null +++ b/examples/bld/src/bld/java/net/thauvin/erik/pinboard/samples/ExampleBuild.java @@ -0,0 +1,54 @@ +package net.thauvin.erik.pinboard.samples; + +import rife.bld.BaseProject; +import rife.bld.BuildCommand; +import rife.bld.extension.CompileKotlinOperation; +import rife.bld.extension.kotlin.CompileOptions; +import rife.bld.operations.RunOperation; + +import java.util.List; + +import static rife.bld.dependencies.Repository.*; +import static rife.bld.dependencies.Scope.compile; + +public class ExampleBuild extends BaseProject { + public ExampleBuild() { + pkg = "net.thauvin.erik.pinboard.samples"; + name = "Example"; + version = version(0, 1, 0); + + mainClass = pkg + ".KotlinExampleKt"; + + javaRelease = 11; + downloadSources = true; + autoDownloadPurge = true; + + repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY); + + scope(compile) + .include(dependency("net.thauvin.erik", "pinboard-poster", version(1, 2, 1, "SNAPSHOT"))); + } + + public static void main(String[] args) { + new ExampleBuild().start(args); + } + + @Override + public void compile() throws Exception { + new CompileKotlinOperation() + .fromProject(this) + .compileOptions(new CompileOptions().verbose(true)) + .execute(); + + // Also compile the Java source code + super.compile(); + } + + @BuildCommand(value = "run-java", summary = "Runs the Java example") + public void runJava() throws Exception { + new RunOperation() + .fromProject(this) + .mainClass(pkg + ".JavaExample") + .execute(); + } +} diff --git a/examples/bld/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java b/examples/bld/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java new file mode 100644 index 0000000..1ef224b --- /dev/null +++ b/examples/bld/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java @@ -0,0 +1,47 @@ +package net.thauvin.erik.pinboard.samples; + +import net.thauvin.erik.pinboard.PinConfig; +import net.thauvin.erik.pinboard.PinboardPoster; + +import java.nio.file.Paths; +import java.util.logging.ConsoleHandler; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class JavaExample { + public static void main(String[] args) { + final String url = "https://example.com/pinboard"; + final PinboardPoster poster; + + if (args.length == 1) { + // API Token is an argument + poster = new PinboardPoster(args[0]); + } else { + // API Token is in local.properties or PINBOARD_API_TOKEN environment variable + poster = new PinboardPoster(Paths.get("local.properties")); + } + + // Set logging levels + final ConsoleHandler consoleHandler = new ConsoleHandler(); + consoleHandler.setLevel(Level.FINE); + final Logger logger = poster.getLogger(); + logger.addHandler(consoleHandler); + logger.setLevel(Level.FINE); + logger.setUseParentHandlers(false); + + if (poster.validate()) { + // Add Pin + if (poster.addPin(new PinConfig.Builder(url, "Testing") + .extended("Extra") + .tags("test", "java") + .build())) { + System.out.println("Added: " + url); + } + + // Delete Pin + if (poster.deletePin(url)) { + System.out.println("Deleted: " + url); + } + } + } +} diff --git a/examples/bld/src/main/kotlin/net/thauvin/erik/pinboard/samples/KotlinExample.kt b/examples/bld/src/main/kotlin/net/thauvin/erik/pinboard/samples/KotlinExample.kt new file mode 100644 index 0000000..1b48e82 --- /dev/null +++ b/examples/bld/src/main/kotlin/net/thauvin/erik/pinboard/samples/KotlinExample.kt @@ -0,0 +1,37 @@ +package net.thauvin.erik.pinboard.samples + +import net.thauvin.erik.pinboard.PinboardPoster +import java.nio.file.Paths +import java.util.logging.ConsoleHandler +import java.util.logging.Level + +fun main(args: Array) { + val url = "https://example.com/pinboard" + + val poster = if (args.size == 1) { + // API Token is an argument + PinboardPoster(args[0]) + } else { + // API Token is in local.properties or PINBOARD_API_TOKEN environment variable + PinboardPoster(Paths.get("local.properties")) + } + + // Set logging levels + with(poster.logger) { + addHandler(ConsoleHandler().apply { level = Level.FINE }) + level = Level.FINE + useParentHandlers = false + } + + if (poster.validate()) { + // Add Pin + if (poster.addPin(url, "Testing", "Extended test", tags = arrayOf("test", "kotlin"))) { + println("Added: $url") + } + + // Delete Pin + if (poster.deletePin(url)) { + println("Deleted: $url") + } + } +} diff --git a/samples/java/.editorconfig b/examples/gradle/java/.editorconfig similarity index 100% rename from samples/java/.editorconfig rename to examples/gradle/java/.editorconfig diff --git a/samples/java/.gitignore b/examples/gradle/java/.gitignore similarity index 100% rename from samples/java/.gitignore rename to examples/gradle/java/.gitignore diff --git a/examples/gradle/java/.idea/.gitignore b/examples/gradle/java/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/examples/gradle/java/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/examples/gradle/java/.idea/.name b/examples/gradle/java/.idea/.name new file mode 100644 index 0000000..4f5dba1 --- /dev/null +++ b/examples/gradle/java/.idea/.name @@ -0,0 +1 @@ +pinboard-poster-examples-gradle-java \ No newline at end of file diff --git a/examples/gradle/java/.idea/compiler.xml b/examples/gradle/java/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/examples/gradle/java/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/examples/gradle/java/.idea/inspectionProfiles/Project_Default.xml b/examples/gradle/java/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..1e01b48 --- /dev/null +++ b/examples/gradle/java/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/examples/gradle/java/.idea/jarRepositories.xml similarity index 84% rename from .idea/jarRepositories.xml rename to examples/gradle/java/.idea/jarRepositories.xml index 3d4ac96..a529ef2 100644 --- a/.idea/jarRepositories.xml +++ b/examples/gradle/java/.idea/jarRepositories.xml @@ -17,9 +17,9 @@