diff --git a/.circleci/config.yml b/.circleci/config.yml
index 77889be..c781fdc 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,4 +1,8 @@
-version: 2
+version: 2.1
+
+orbs:
+ sdkman: joshdholtz/sdkman@0.2.0
+
defaults: &defaults
working_directory: ~/repo
environment:
@@ -6,18 +10,31 @@ defaults: &defaults
TERM: dumb
CI_NAME: "CircleCI"
-defaults_gradle: &defaults_bld
- steps:
- - checkout
- - run:
- name: Download the bld dependencies
- command: ./bld download
- - run:
- name: Compile source with bld
- command: ./bld compile
- - run:
- name: Run tests with bld
- command: ./bld test
+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:
bld_jdk17:
@@ -26,19 +43,20 @@ jobs:
docker:
- image: cimg/openjdk:17.0
- <<: *defaults_bld
+ steps:
+ - build_and_test
- bld_jdk20:
+ bld_jdk21:
<<: *defaults
docker:
- - image: cimg/openjdk:20.0
+ - image: cimg/openjdk:21.0
- <<: *defaults_bld
+ steps:
+ - build_and_test
workflows:
- version: 2
bld:
jobs:
- bld_jdk17
- - bld_jdk20
+ - bld_jdk21
diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml
index 7d70d8f..068e6c9 100644
--- a/.github/workflows/bld.yml
+++ b/.github/workflows/bld.yml
@@ -2,50 +2,73 @@ 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:
- runs-on: ubuntu-latest
-
- env:
- COVERAGE_SDK: "17"
-
strategy:
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:
- name: Checkout source repository
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
fetch-depth: 0
- - name: Set up JDK ${{ matrix.java-version }}
- uses: actions/setup-java@v3
+ - name: Set up JDK ${{ matrix.java-version }} with Kotlin ${{ matrix.kotlin-version }}
+ uses: actions/setup-java@v4
with:
- distribution: 'zulu'
+ distribution: "zulu"
java-version: ${{ matrix.java-version }}
- - name: Grant bld execute permission
- run: chmod +x bld
-
- - name: Download the bld dependencies
+ - name: Download dependencies [bld example]
+ working-directory: examples/bld
run: ./bld download
- - name: Compile source with bld
+ - 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 with bld
- env:
- PINBOARD_API_TOKEN: ${{ secrets.PINBOARD_API_TOKEN }}
+ - name: Run tests
run: ./bld jacoco
- 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
- name: SonarCloud Scan
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:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 052df48..10b9b0f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,11 +1,24 @@
-image: openjdk:17
+image: fedora:latest
+
+variables:
+ CI_NAME: "GitLab CI"
stages:
- 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:
stage: test
script:
- - ./bld download
- - ./bld compile
- - ./bld test
+ - ./bld download
+ - ./bld compile
+ - ./bld test
diff --git a/.idea/bld.xml b/.idea/bld.xml
new file mode 100644
index 0000000..6600cee
--- /dev/null
+++ b/.idea/bld.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ 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 6af75f8..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/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 1e01b48..94f28ea 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -4,5 +4,6 @@
+
\ No newline at end of file
diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml
index ca84ff0..153a060 100644
--- a/.idea/libraries/bld.xml
+++ b/.idea/libraries/bld.xml
@@ -2,12 +2,12 @@
-
+
-
+
diff --git a/.idea/libraries/compile.xml b/.idea/libraries/compile.xml
index 9bd86aa..99cc0c0 100644
--- a/.idea/libraries/compile.xml
+++ b/.idea/libraries/compile.xml
@@ -7,7 +7,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/libraries/runtime.xml b/.idea/libraries/runtime.xml
index 2ae5c4b..d4069f2 100644
--- a/.idea/libraries/runtime.xml
+++ b/.idea/libraries/runtime.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/libraries/test.xml b/.idea/libraries/test.xml
index b80486a..57ed5ef 100644
--- a/.idea/libraries/test.xml
+++ b/.idea/libraries/test.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index c80528e..2adb169 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -16,6 +16,7 @@
+
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 133aa45..ba429d0 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -3,13 +3,13 @@
"src/main/java",
"src/main/resources",
"src/test/java",
- "src/bld/java"
+ "src/test/resources",
+ "src/bld/java",
+ "src/bld/resources"
],
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
- "${HOME}/.bld/dist/bld-1.7.5.jar",
- "lib/compile/*.jar",
- "lib/runtime/*.jar",
- "lib/test/*.jar"
+ "${HOME}/.bld/dist/bld-2.2.1.jar",
+ "lib/**/*.jar"
]
}
diff --git a/LICENSE.txt b/LICENSE.txt
index d53e5a1..9926d00 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2017-2023, 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 73561f4..cdf7df5 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
# [Pinboard](https://pinboard.in) Poster for Kotlin, Java and Android
[](https://opensource.org/licenses/BSD-3-Clause)
-[](https://kotlinlang.org/)
+[](https://kotlinlang.org/)
+[](https://rife2.com/bld)
[](https://github.com/ethauvin/pinboard-poster/releases/latest)
[](https://central.sonatype.com/artifact/net.thauvin.erik/pinboard-poster)
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/pinboard-poster/)
@@ -21,9 +22,9 @@ A small library for posting to [Pinboard](https://pinboard.in).
val poster = PinboardPoster("user:TOKEN")
-poster.addPin("https://www.example.com/foo", "This is a test")
-poster.addPin("https://examples.com", "This is a test", tags = arrayOf("foo", "bar"))
-poster.deletePin("https:///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")
```
@@ -35,20 +36,17 @@ poster.deletePin("https:///www.example.com/bar")
final PinboardPoster poster = new PinBboardPoster("user:TOKEN");
-poster.addPin("https://www.example.com/foo", "This is a test");
-poster.addPin(new PinConfig.Builder()
- .url("https://example.com")
- .description("This is a test")
+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:///www.example.com/bar");
+poster.deletePin("https://example.com/bar");
```
[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).
-
## bld
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:
@@ -57,7 +55,7 @@ To use with [bld](https://rife2.com/bld), include the following dependency in yo
repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
scope(compile)
- .include(dependency("net.thauvin.erik:pinboard-poster:1.1.0"));
+ .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.
@@ -73,7 +71,7 @@ repositories {
}
dependencies {
- compile 'net.thauvin.erik:pinboard-poster:1.1.0'
+ compile 'net.thauvin.erik:pinboard-poster:1.2.0'
}
```
@@ -199,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 7c85194..ace99d2 100644
--- a/bitbucket-pipelines.yml
+++ b/bitbucket-pipelines.yml
@@ -1,10 +1,20 @@
-image: openjdk:17
+image: ubuntu:latest
pipelines:
default:
- step:
name: Test with bld
script:
+ # Install latest Java & Kotlin via SDKMAN!
+ - apt-get update -qq && apt-get install -y curl zip
+ - curl -s "https://get.sdkman.io" | bash
+ - echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config
+ - echo sdkman_auto_selfupdate=true >> $HOME/.sdkman/etc/config
+ - source "$HOME/.sdkman/bin/sdkman-init.sh"
+ - sdk install java
+ - sdk install kotlin
+ - source "$HOME/.sdkman/bin/sdkman-init.sh"
+ # Download, compile and test with bld
- ./bld download
- ./bld compile
- ./bld test
diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml
index 6c39509..3f97ec1 100644
--- a/config/detekt/baseline.xml
+++ b/config/detekt/baseline.xml
@@ -1,10 +1,10 @@
-
+
-
+
- LongParameterList:PinConfig.kt$PinConfig$( val url: String, val description: String, val extended: String, val tags: Array<out String>, val dt: ZonedDateTime, val replace: Boolean, val shared: Boolean, val toRead: Boolean )
+ 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
+ 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/.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/libraries/bld.xml b/examples/bld/.idea/libraries/bld.xml
index ca84ff0..153a060 100644
--- a/examples/bld/.idea/libraries/bld.xml
+++ b/examples/bld/.idea/libraries/bld.xml
@@ -2,12 +2,12 @@
-
+
-
+
diff --git a/examples/bld/.idea/libraries/compile.xml b/examples/bld/.idea/libraries/compile.xml
index 9bd86aa..99cc0c0 100644
--- a/examples/bld/.idea/libraries/compile.xml
+++ b/examples/bld/.idea/libraries/compile.xml
@@ -7,7 +7,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/runtime.xml b/examples/bld/.idea/libraries/runtime.xml
index 2ae5c4b..d4069f2 100644
--- a/examples/bld/.idea/libraries/runtime.xml
+++ b/examples/bld/.idea/libraries/runtime.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/test.xml b/examples/bld/.idea/libraries/test.xml
index b80486a..57ed5ef 100644
--- a/examples/bld/.idea/libraries/test.xml
+++ b/examples/bld/.idea/libraries/test.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/bld/.vscode/settings.json b/examples/bld/.vscode/settings.json
index 133aa45..ba429d0 100644
--- a/examples/bld/.vscode/settings.json
+++ b/examples/bld/.vscode/settings.json
@@ -3,13 +3,13 @@
"src/main/java",
"src/main/resources",
"src/test/java",
- "src/bld/java"
+ "src/test/resources",
+ "src/bld/java",
+ "src/bld/resources"
],
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
- "${HOME}/.bld/dist/bld-1.7.5.jar",
- "lib/compile/*.jar",
- "lib/runtime/*.jar",
- "lib/test/*.jar"
+ "${HOME}/.bld/dist/bld-2.2.1.jar",
+ "lib/**/*.jar"
]
}
diff --git a/examples/bld/lib/bld/bld-wrapper.jar b/examples/bld/lib/bld/bld-wrapper.jar
index 44b7c9a..968a8ab 100644
Binary files a/examples/bld/lib/bld/bld-wrapper.jar 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
index 095b48c..1f1009d 100644
--- a/examples/bld/lib/bld/bld-wrapper.properties
+++ b/examples/bld/lib/bld/bld-wrapper.properties
@@ -1,7 +1,7 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
-bld.extensions=com.uwyn.rife2:bld-kotlin:0.9.0-SNAPSHOT
-bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
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=1.7.5
+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
index 6f1eab6..6fc8142 100644
--- 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
@@ -3,6 +3,7 @@ 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;
@@ -25,7 +26,7 @@ public class ExampleBuild extends BaseProject {
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
scope(compile)
- .include(dependency("net.thauvin.erik", "pinboard-poster", version(1, 1, 1)));
+ .include(dependency("net.thauvin.erik", "pinboard-poster", version(1, 2, 1, "SNAPSHOT")));
}
public static void main(String[] args) {
@@ -36,6 +37,7 @@ public class ExampleBuild extends BaseProject {
public void compile() throws Exception {
new CompileKotlinOperation()
.fromProject(this)
+ .compileOptions(new CompileOptions().verbose(true))
.execute();
// Also compile the Java source code
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
index e638a44..1ef224b 100644
--- 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
@@ -31,9 +31,7 @@ public class JavaExample {
if (poster.validate()) {
// Add Pin
- if (poster.addPin(new PinConfig.Builder()
- .url(url)
- .description("Testing")
+ if (poster.addPin(new PinConfig.Builder(url, "Testing")
.extended("Extra")
.tags("test", "java")
.build())) {
diff --git a/examples/gradle/java/.idea/misc.xml b/examples/gradle/java/.idea/misc.xml
index cb3f07e..7adacb2 100644
--- a/examples/gradle/java/.idea/misc.xml
+++ b/examples/gradle/java/.idea/misc.xml
@@ -1,8 +1,8 @@
-
-
+
+
-
+
diff --git a/examples/gradle/java/build.gradle b/examples/gradle/java/build.gradle
index a9a4334..e0eceee 100644
--- a/examples/gradle/java/build.gradle
+++ b/examples/gradle/java/build.gradle
@@ -1,12 +1,14 @@
plugins {
- id 'com.github.ben-manes.versions' version '0.50.0'
+ id 'com.github.ben-manes.versions' version '0.51.0'
id 'java'
id 'application'
}
defaultTasks 'run'
-mainClassName = 'net.thauvin.erik.pinboard.samples.JavaExample'
+application {
+ mainClass = 'net.thauvin.erik.pinboard.samples.JavaExample'
+}
java {
sourceCompatibility = JavaVersion.VERSION_11
@@ -16,8 +18,9 @@ java {
repositories {
mavenLocal()
mavenCentral()
+ maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
}
dependencies {
- implementation 'net.thauvin.erik:pinboard-poster:1.1.1'
+ implementation 'net.thauvin.erik:pinboard-poster:1.2.1-SNAPSHOT'
}
diff --git a/examples/gradle/java/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/java/gradle/wrapper/gradle-wrapper.jar
index 7f93135..9bbc975 100644
Binary files a/examples/gradle/java/gradle/wrapper/gradle-wrapper.jar and b/examples/gradle/java/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/gradle/java/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/java/gradle/wrapper/gradle-wrapper.properties
index 3fa8f86..37f853b 100644
--- a/examples/gradle/java/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/gradle/java/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/examples/gradle/java/gradlew b/examples/gradle/java/gradlew
index 1aa94a4..faf9300 100755
--- a/examples/gradle/java/gradlew
+++ b/examples/gradle/java/gradlew
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (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.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd "${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.
MAX_FD=maximum
@@ -203,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# 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.
# * 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.
diff --git a/examples/gradle/java/gradlew.bat b/examples/gradle/java/gradlew.bat
index 93e3f59..9d21a21 100644
--- a/examples/gradle/java/gradlew.bat
+++ b/examples/gradle/java/gradlew.bat
@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
diff --git a/examples/gradle/java/settings.gradle b/examples/gradle/java/settings.gradle
index e7ecd5d..87b714a 100644
--- a/examples/gradle/java/settings.gradle
+++ b/examples/gradle/java/settings.gradle
@@ -7,4 +7,4 @@
* in the user guide at https://docs.gradle.org/4.8/userguide/multi_project_builds.html
*/
-rootProject.name = 'samples-java'
+rootProject.name = 'pinboard-poster-examples-gradle-java'
diff --git a/examples/gradle/java/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java b/examples/gradle/java/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java
index e638a44..1ef224b 100644
--- a/examples/gradle/java/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java
+++ b/examples/gradle/java/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java
@@ -31,9 +31,7 @@ public class JavaExample {
if (poster.validate()) {
// Add Pin
- if (poster.addPin(new PinConfig.Builder()
- .url(url)
- .description("Testing")
+ if (poster.addPin(new PinConfig.Builder(url, "Testing")
.extended("Extra")
.tags("test", "java")
.build())) {
diff --git a/examples/gradle/kotlin/.idea/.name b/examples/gradle/kotlin/.idea/.name
index 91c6ff0..7379aed 100644
--- a/examples/gradle/kotlin/.idea/.name
+++ b/examples/gradle/kotlin/.idea/.name
@@ -1 +1 @@
-pinboard-poster-examples-gradle-kotlin
\ No newline at end of file
+pinboard-post-examples-gradle-kotlin
\ No newline at end of file
diff --git a/examples/gradle/kotlin/.idea/kotlin.iml b/examples/gradle/kotlin/.idea/kotlin.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/examples/gradle/kotlin/.idea/kotlin.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/gradle/kotlin/.idea/kotlinc.xml b/examples/gradle/kotlin/.idea/kotlinc.xml
index ae3f30a..6d0ee1c 100644
--- a/examples/gradle/kotlin/.idea/kotlinc.xml
+++ b/examples/gradle/kotlin/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/examples/gradle/kotlin/.idea/misc.xml b/examples/gradle/kotlin/.idea/misc.xml
index cb3f07e..034d4d4 100644
--- a/examples/gradle/kotlin/.idea/misc.xml
+++ b/examples/gradle/kotlin/.idea/misc.xml
@@ -4,5 +4,5 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/gradle/kotlin/.idea/modules.xml b/examples/gradle/kotlin/.idea/modules.xml
new file mode 100644
index 0000000..a168080
--- /dev/null
+++ b/examples/gradle/kotlin/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/gradle/kotlin/build.gradle.kts b/examples/gradle/kotlin/build.gradle.kts
index 4359cba..f41881f 100644
--- a/examples/gradle/kotlin/build.gradle.kts
+++ b/examples/gradle/kotlin/build.gradle.kts
@@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("application")
- id("com.github.ben-manes.versions") version "0.50.0"
- kotlin("jvm") version "1.9.21"
+ id("com.github.ben-manes.versions") version "0.51.0"
+ kotlin("jvm") version "2.1.20"
}
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
@@ -11,10 +11,11 @@ defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
repositories {
mavenLocal()
mavenCentral()
+ maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
}
dependencies {
- implementation("net.thauvin.erik:pinboard-poster:1.1.1")
+ implementation("net.thauvin.erik:pinboard-poster:1.2.1-SNAPSHOT")
}
java {
@@ -26,8 +27,6 @@ application {
mainClass.set("net.thauvin.erik.pinboard.samples.KotlinExampleKt")
}
-tasks {
- withType().configureEach {
- kotlinOptions.jvmTarget = java.targetCompatibility.toString()
- }
+kotlin {
+ compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
}
diff --git a/examples/gradle/kotlin/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/kotlin/gradle/wrapper/gradle-wrapper.jar
index 7f93135..9bbc975 100644
Binary files a/examples/gradle/kotlin/gradle/wrapper/gradle-wrapper.jar and b/examples/gradle/kotlin/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/gradle/kotlin/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/kotlin/gradle/wrapper/gradle-wrapper.properties
index 3fa8f86..37f853b 100644
--- a/examples/gradle/kotlin/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/gradle/kotlin/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/examples/gradle/kotlin/gradlew b/examples/gradle/kotlin/gradlew
index 1aa94a4..faf9300 100755
--- a/examples/gradle/kotlin/gradlew
+++ b/examples/gradle/kotlin/gradlew
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (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.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd "${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.
MAX_FD=maximum
@@ -203,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# 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.
# * 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.
diff --git a/examples/gradle/kotlin/gradlew.bat b/examples/gradle/kotlin/gradlew.bat
index 93e3f59..9d21a21 100644
--- a/examples/gradle/kotlin/gradlew.bat
+++ b/examples/gradle/kotlin/gradlew.bat
@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
diff --git a/examples/gradle/kotlin/settings.gradle.kts b/examples/gradle/kotlin/settings.gradle.kts
index 28613c7..5d8ff15 100644
--- a/examples/gradle/kotlin/settings.gradle.kts
+++ b/examples/gradle/kotlin/settings.gradle.kts
@@ -1 +1 @@
-rootProject.name = "samples-kotlin"
+rootProject.name = "pinboard-post-examples-gradle-kotlin"
diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar
index 0690b8c..7add961 100644
Binary files a/lib/bld/bld-wrapper.jar and b/lib/bld/bld-wrapper.jar differ
diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties
index ac34063..fc9463a 100644
--- a/lib/bld/bld-wrapper.properties
+++ b/lib/bld/bld-wrapper.properties
@@ -1,9 +1,10 @@
bld.downloadExtensionJavadoc=false
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.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT
+bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.4-SNAPSHOT
+bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10-SNAPSHOT
+bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
+bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories=
-bld.version=1.7.5
+bld.version=2.2.1
diff --git a/pom.xml b/pom.xml
index 666cbb6..64767c7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
net.thauvin.erik
pinboard-poster
- 1.1.1
+ 1.2.1-SNAPSHOT
pinboard-poster
A small library for posting to Pinboard
https://github.com/ethauvin/pinboard-poster
@@ -18,25 +18,19 @@
org.jetbrains.kotlin
kotlin-stdlib
- 1.9.21
+ 2.1.20
compile
org.jetbrains.kotlin
kotlin-stdlib-common
- 1.9.21
- compile
-
-
- org.jetbrains.kotlin
- kotlin-stdlib-jdk7
- 1.9.21
+ 2.1.20
compile
org.jetbrains.kotlin
kotlin-stdlib-jdk8
- 1.9.21
+ 2.1.20
compile
diff --git a/src/bld/java/net/thauvin/erik/pinboard/PinboardPosterBuild.java b/src/bld/java/net/thauvin/erik/pinboard/PinboardPosterBuild.java
index e8c0149..d4689ac 100644
--- a/src/bld/java/net/thauvin/erik/pinboard/PinboardPosterBuild.java
+++ b/src/bld/java/net/thauvin/erik/pinboard/PinboardPosterBuild.java
@@ -1,7 +1,7 @@
/*
* PinboardPosterBuild.java
*
- * Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2017-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:
@@ -35,10 +35,11 @@ import rife.bld.BuildCommand;
import rife.bld.Project;
import rife.bld.extension.CompileKotlinOperation;
import rife.bld.extension.DetektOperation;
+import rife.bld.extension.DokkaOperation;
import rife.bld.extension.JacocoReportOperation;
-import rife.bld.extension.dokka.DokkaOperation;
import rife.bld.extension.dokka.LoggingLevel;
import rife.bld.extension.dokka.OutputFormat;
+import rife.bld.extension.kotlin.CompileOptions;
import rife.bld.operations.exceptions.ExitStatusException;
import rife.bld.publish.PomBuilder;
import rife.bld.publish.PublishDeveloper;
@@ -49,16 +50,21 @@ import rife.tools.exceptions.FileUtilsErrorException;
import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import static rife.bld.dependencies.Repository.*;
import static rife.bld.dependencies.Scope.compile;
import static rife.bld.dependencies.Scope.test;
public class PinboardPosterBuild extends Project {
+ final File srcMainKotlin = new File(srcMainDirectory(), "kotlin");
+
public PinboardPosterBuild() {
pkg = "net.thauvin.erik";
name = "pinboard-poster";
- version = version(1, 1, 1);
+ version = version(1, 2, 1, "SNAPSHOT");
mainClass = pkg + ".PinboardPoster";
@@ -68,62 +74,73 @@ public class PinboardPosterBuild extends Project {
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
final var okHttp = version(4, 12, 0);
- final var kotlin = version(1, 9, 21);
+ final var kotlin = version(2, 1, 20);
scope(compile)
+ // Kotlin
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-common", kotlin))
- .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk7", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk8", kotlin))
+ // OkHttp
.include(dependency("com.squareup.okhttp3", "okhttp", okHttp))
.include(dependency("com.squareup.okhttp3", "logging-interceptor", okHttp));
scope(test)
- .include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", version(1, 9, 21)))
- .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
- .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1)));
+ .include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
+ .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1)))
+ .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1)))
+ .include(dependency("org.junit.platform", "junit-platform-launcher", version(1, 12, 1)));
publishOperation()
.repository(version.isSnapshot() ? repository(SONATYPE_SNAPSHOTS_LEGACY.location())
.withCredentials(property("sonatype.user"), property("sonatype.password"))
: repository(SONATYPE_RELEASES_LEGACY.location())
.withCredentials(property("sonatype.user"), property("sonatype.password")))
+ .repository(repository("github"))
.info()
.groupId(pkg)
.artifactId(name)
.description("A small library for posting to Pinboard")
.url("https://github.com/ethauvin/" + name)
- .developer(
- new PublishDeveloper()
- .id("ethauvin")
- .name("Erik C. Thauvin")
- .email("erik@thauvin.net")
- .url("https://erik.thauvin.net/")
+ .developer(new PublishDeveloper()
+ .id("ethauvin")
+ .name("Erik C. Thauvin")
+ .email("erik@thauvin.net")
+ .url("https://erik.thauvin.net/")
)
- .license(
- new PublishLicense()
- .name("BSD 3-Clause")
- .url("https://opensource.org/licenses/BSD-3-Clause")
+ .license(new PublishLicense()
+ .name("BSD 3-Clause")
+ .url("https://opensource.org/licenses/BSD-3-Clause")
)
- .scm(
- new PublishScm()
- .connection("scm:git:https://github.com/ethauvin/" + name + ".git")
- .developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
- .url("https://github.com/ethauvin/" + name)
+ .scm(new PublishScm()
+ .connection("scm:git:https://github.com/ethauvin/" + name + ".git")
+ .developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
+ .url("https://github.com/ethauvin/" + name)
)
.signKey(property("sign.key"))
.signPassphrase(property("sign.passphrase"));
- jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
+ jarSourcesOperation().sourceDirectories(srcMainKotlin);
}
public static void main(final String[] args) {
+ // Enable detailed logging for the extensions
+ var level = Level.ALL;
+ var logger = Logger.getLogger("rife.bld.extension");
+ var consoleHandler = new ConsoleHandler();
+
+ consoleHandler.setLevel(level);
+ logger.addHandler(consoleHandler);
+ logger.setLevel(level);
+ logger.setUseParentHandlers(false);
+
new PinboardPosterBuild().start(args);
}
@BuildCommand(summary = "Compiles the Kotlin project")
@Override
- public void compile() throws IOException {
+ public void compile() throws Exception {
new CompileKotlinOperation()
.fromProject(this)
+ .compileOptions(new CompileOptions().verbose(true))
.execute();
}
@@ -145,9 +162,10 @@ public class PinboardPosterBuild extends Project {
}
@BuildCommand(summary = "Generates JaCoCo Reports")
- public void jacoco() throws IOException {
+ public void jacoco() throws Exception {
new JacocoReportOperation()
.fromProject(this)
+ .sourceFiles(srcMainKotlin)
.execute();
}
@@ -169,6 +187,12 @@ public class PinboardPosterBuild extends Project {
pomRoot();
}
+ @Override
+ public void publishLocal() throws Exception {
+ super.publishLocal();
+ pomRoot();
+ }
+
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
public void pomRoot() throws FileUtilsErrorException {
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
diff --git a/src/main/kotlin/net/thauvin/erik/pinboard/PinConfig.kt b/src/main/kotlin/net/thauvin/erik/pinboard/PinConfig.kt
index 32ee785..a41e563 100644
--- a/src/main/kotlin/net/thauvin/erik/pinboard/PinConfig.kt
+++ b/src/main/kotlin/net/thauvin/erik/pinboard/PinConfig.kt
@@ -1,8 +1,7 @@
/*
* PinConfig.kt
*
- * Copyright (c) 2017-2023, Erik C. Thauvin (erik@thauvin.net)
- * All rights reserved.
+ * Copyright (c) 2017-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:
@@ -38,48 +37,74 @@ import java.time.ZonedDateTime
*
* Supports of all the [Pinboard API Parameters](https://pinboard.in/api/#posts_add).
*/
-class PinConfig private constructor(
- val url: String,
- val description: String,
- val extended: String,
- val tags: Array,
- val dt: ZonedDateTime,
- val replace: Boolean,
- val shared: Boolean,
- val toRead: Boolean
-) {
+class PinConfig private constructor(builder: Builder) {
+ val url: String = builder.url
+ val description: String = builder.description
+ val extended = builder.extended
+ val tags = builder.tags
+ val dt = builder.dt
+ val replace = builder.replace
+ val shared = builder.shared
+ val toRead = builder.toRead
+
/**
* Configures the parameters to add a pin.
+ *
+ * @param url The URL of the bookmark.
+ * @param description The title of the bookmark.
*/
- data class Builder(
- private var url: String = "",
- private var description: String = "",
- private var extended: String = "",
- private var tags: Array = emptyArray(),
- private var dt: ZonedDateTime = ZonedDateTime.now(),
- private var replace: Boolean = true,
- private var shared: Boolean = true,
- private var toRead: Boolean = false
- ) {
- fun url(url: String) = apply { this.url = url }
- fun description(description: String) = apply { this.description = description }
- fun extended(extended: String) = apply { this.extended = extended }
- fun tags(vararg tag: String) = apply { this.tags = tag }
- fun dt(datetime: ZonedDateTime) = apply { this.dt = datetime }
- fun replace(replace: Boolean) = apply { this.replace = replace }
- fun shared(shared: Boolean) = apply { this.shared = shared }
- fun toRead(toRead: Boolean) = apply { this.toRead = toRead }
+ data class Builder(var url: String, var description: String) {
+ var extended: String = ""
+ var tags: Array = emptyArray()
+ var dt: ZonedDateTime = ZonedDateTime.now()
+ var replace: Boolean = true
+ var shared: Boolean = true
+ var toRead: Boolean = false
- fun build() = PinConfig(
- url,
- description,
- extended,
- tags,
- dt,
- replace,
- shared,
- toRead
- )
+ /**
+ * The URL of the bookmark.
+ */
+ fun url(url: String): Builder = apply { this.url = url }
+
+ /**
+ * The title of the bookmark.
+ */
+ fun description(description: String): Builder = apply { this.description = description }
+
+ /**
+ * The description of the bookmark.
+ */
+ fun extended(extended: String): Builder = apply { this.extended = extended }
+
+ /**
+ * A list of up to 100 tags.
+ */
+ fun tags(vararg tag: String): Builder = apply { this.tags = tag }
+
+ /**
+ * The creation time of the bookmark.
+ */
+ fun dt(datetime: ZonedDateTime): Builder = apply { this.dt = datetime }
+
+ /**
+ * Replace any existing bookmark with the specified URL. Default `true`.
+ */
+ fun replace(replace: Boolean): Builder = apply { this.replace = replace }
+
+ /**
+ * Make bookmark public. Default is `true`.
+ */
+ fun shared(shared: Boolean): Builder = apply { this.shared = shared }
+
+ /**
+ * Mark the bookmark as unread. Default is `false`.
+ */
+ fun toRead(toRead: Boolean): Builder = apply { this.toRead = toRead }
+
+ /**
+ * Builds a new configuration.
+ */
+ fun build() = PinConfig(this)
override fun equals(other: Any?): Boolean {
if (this === other) return true
@@ -115,7 +140,5 @@ class PinConfig private constructor(
return "Builder(url='$url', description='$description', extended='$extended'," +
"tags=${tags.contentToString()}, dt=$dt, replace=$replace, shared=$shared, toRead=$toRead)"
}
-
-
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt b/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt
index 52555b9..00d2cc1 100644
--- a/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt
+++ b/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt
@@ -1,8 +1,7 @@
/*
* PinboardPoster.kt
*
- * Copyright (c) 2017-2023, Erik C. Thauvin (erik@thauvin.net)
- * All rights reserved.
+ * Copyright (c) 2017-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:
diff --git a/src/test/kotlin/net/thauvin/erik/pinboard/PinboardPosterTest.kt b/src/test/kotlin/net/thauvin/erik/pinboard/PinboardPosterTest.kt
index 043e48a..9281df5 100644
--- a/src/test/kotlin/net/thauvin/erik/pinboard/PinboardPosterTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/pinboard/PinboardPosterTest.kt
@@ -1,8 +1,7 @@
/*
* PinboardPosterTest.kt
*
- * Copyright (c) 2017-2023, Erik C. Thauvin (erik@thauvin.net)
- * All rights reserved.
+ * Copyright (c) 2017-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:
@@ -44,11 +43,13 @@ import kotlin.test.assertFalse
import kotlin.test.assertTrue
class PinboardPosterTest {
- private val url = "http://www.example.com/?random=" + (1000..10000).random()
+ private val url = randomUrl()
private val desc = "This is a test."
private val localProps = Paths.get("local.properties")
private val isCi = "true" == System.getenv("CI")
+ private fun randomUrl(): String = "https://www.example.com/?random=" + (1000..10000).random()
+
@Test
fun testAddPin() {
var poster = PinboardPoster("")
@@ -66,6 +67,7 @@ class PinboardPosterTest {
if (!isCi) {
poster.logger.level = Level.FINE
}
+
assertTrue(poster.validate(), "validate()")
assertTrue(poster.addPin(url, desc), "addPin($url, $desc)")
@@ -82,7 +84,7 @@ class PinboardPosterTest {
assertTrue(poster.validate(), "validate()")
- var config = PinConfig.Builder().url(url).description(desc).extended("extra")
+ var config = PinConfig.Builder(url, desc).extended("extra")
assertTrue(poster.addPin(config.build()), "apiToken: ${Constants.ENV_API_TOKEN}")
@@ -98,13 +100,17 @@ class PinboardPosterTest {
assertTrue(e.message!!.contains("item already exists"))
}
- config = config.replace(true).toRead(true)
+ config = config.description("Yet another test.").replace(true).toRead(true)
assertTrue(poster.addPin(config.build()), "toRead(true)")
config = config.dt(ZonedDateTime.now())
assertTrue(poster.addPin(config.build()), "dt(now)")
assertTrue(poster.deletePin(url), "deletePin($url)")
+
+ config = config.url(randomUrl())
+ assertTrue(poster.addPin(config.build()), "add($url)")
+ assertTrue(poster.deletePin(config.url), "delete($url)")
}
@Test