diff --git a/.circleci/config.yml b/.circleci/config.yml
index c781fdc..d21cbc7 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,62 +1,54 @@
-version: 2.1
-
-orbs:
- sdkman: joshdholtz/sdkman@0.2.0
-
+version: 2
defaults: &defaults
working_directory: ~/repo
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
- CI_NAME: "CircleCI"
+ CI: true
-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
+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/
jobs:
- bld_jdk17:
+ build_gradle_jdk14:
<<: *defaults
docker:
- - image: cimg/openjdk:17.0
+ - image: openjdk:14-jdk
- steps:
- - build_and_test
+ <<: *defaults_gradle
- bld_jdk21:
+ build_gradle_jdk8:
<<: *defaults
docker:
- - image: cimg/openjdk:21.0
+ - image: circleci/openjdk:8-jdk
- steps:
- - build_and_test
+ <<: *defaults_gradle
workflows:
- bld:
- jobs:
- - bld_jdk17
- - bld_jdk21
+ version: 2
+ gradle:
+ jobs:
+ - build_gradle_jdk8
+ - build_gradle_jdk14
diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml
deleted file mode 100644
index 639d0d6..0000000
--- a/.github/workflows/bld.yml
+++ /dev/null
@@ -1,68 +0,0 @@
-name: bld-ci
-
-on: [push, pull_request, workflow_dispatch]
-
-env:
- COVERAGE_JDK: "21"
- COVERAGE_KOTLIN: "2.0.21"
-
-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 examples [bld example]
- working-directory: examples/bld
- run: |
- ./bld compile
- ./bld run --args='https://www.example.com https://is.gd/Pt2sET'
- ./bld run-java --args='https://www.example.com https://is.gd/Pt2sET'
-
- - name: Run examples [gradle example]
- working-directory: examples/gradle
- run: |
- ./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
- ./gradlew runJava --args='https://www.example.com https://is.gd/Pt2sET'
-
- - 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_changelog_generator b/.github_changelog_generator
deleted file mode 100644
index a12ba88..0000000
--- a/.github_changelog_generator
+++ /dev/null
@@ -1 +0,0 @@
-future-release=1.0.0
diff --git a/.gitignore b/.gitignore
index 1808834..f007981 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,61 +1,84 @@
-.gradle
+.vscode/*
+!.vscode/extensions.json
+!.vscode/launch.json
+!.vscode/settings.json
+!.vscode/tasks.json
+
+__pycache__
+.classpath
.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
+.gradle
+.history
+.kobalt
+.mtj.tmp/
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
+.nb-gradle
+.project
+.scannerwork
+.settings
+*.class
+*.code-workspace
+*.ctxt
+*.iws
+*.log
+*.nar
+*.rar
+*.sublime-*
+*.tar.gz
+*.zip
+/**/.idea_modules/
+/**/.idea/**/caches/build_file_checksums.ser
+/**/.idea/**/contentModel.xml
+/**/.idea/**/dataSources.ids
+/**/.idea/**/dataSources.local.xml
+/**/.idea/**/dataSources/
+/**/.idea/**/dbnavigator.xml
+/**/.idea/**/dictionaries
+/**/.idea/**/dynamic.xml
+/**/.idea/**/gradle.xml
+/**/.idea/**/httpRequests
+/**/.idea/**/libraries
+/**/.idea/**/mongoSettings.xml
+/**/.idea/**/replstate.xml
+/**/.idea/**/shelf
+/**/.idea/**/shelf/
+/**/.idea/**/sqlDataSources.xml
+/**/.idea/**/tasks.xml
+/**/.idea/**/uiDesigner.xml
+/**/.idea/**/usage.statistics.xml
+/**/.idea/**/workspace.xml
+/**/.idea/$CACHE_FILE$
+/**/.idea/$PRODUCT_WORKSPACE_FILE$
atlassian-ide-plugin.xml
-
-# Cursive Clojure plugin
-.idea/replstate.xml
-
-# SonarLint plugin
-.idea/sonarlint/
-
-# Editor-based Rest Client
-.idea/httpRequests
-
-bin
-deploy
-target
+bin/
+build/
+cmake-build-*/
+com_crashlytics_export_strings.xml
+crashlytics-build.properties
+crashlytics.properties
+dependency-reduced-pom.xml
+deploy/
+dist/
+ehthumbs.db
+fabric.properties
+gen/
+gradle.properties
+hs_err_pid*
+kobaltBuild
+kobaltw*-test
+lib/kotlin*
+libs/
local.properties
-
+out/
+pom.xml.next
+pom.xml.releaseBackup
+pom.xml.tag
+pom.xml.versionsBackup
+proguard-project.txt
+project.properties
+release.properties
+target/
+test-output
+Thumbs.db
+venv
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
deleted file mode 100644
index 10b9b0f..0000000
--- a/.gitlab-ci.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-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
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/app.iml b/.idea/app.iml
deleted file mode 100644
index 2c1fe21..0000000
--- a/.idea/app.iml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/bld.iml b/.idea/bld.iml
deleted file mode 100644
index e63e11e..0000000
--- a/.idea/bld.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/bld.xml b/.idea/bld.xml
deleted file mode 100644
index 6600cee..0000000
--- a/.idea/bld.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/compiler.xml b/.idea/compiler.xml
similarity index 75%
rename from examples/gradle/.idea/compiler.xml
rename to .idea/compiler.xml
index fb7f4a8..61a9130 100644
--- a/examples/gradle/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/copyright/BSD_3.xml b/.idea/copyright/BSD_3.xml
deleted file mode 100644
index dcac8a6..0000000
--- a/.idea/copyright/BSD_3.xml
+++ /dev/null
@@ -1,6 +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
new file mode 100644
index 0000000..08660a1
--- /dev/null
+++ b/.idea/copyright/Erik_s_Copyright_Notice.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
index 3203074..1419e40 100644
--- a/.idea/copyright/profiles_settings.xml
+++ b/.idea/copyright/profiles_settings.xml
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 94f28ea..9c38803 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -1,9 +1,50 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/isgd-shorten.iml b/.idea/isgd-shorten.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/.idea/isgd-shorten.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/examples/gradle/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
similarity index 73%
rename from examples/gradle/.idea/jarRepositories.xml
rename to .idea/jarRepositories.xml
index 4e9cedf..ac476f9 100644
--- a/examples/gradle/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -11,20 +11,20 @@
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
deleted file mode 100644
index 9d6ea82..0000000
--- a/.idea/kotlinc.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml
deleted file mode 100644
index 153a060..0000000
--- a/.idea/libraries/bld.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.idea/libraries/compile.xml b/.idea/libraries/compile.xml
deleted file mode 100644
index 99cc0c0..0000000
--- a/.idea/libraries/compile.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/runtime.xml b/.idea/libraries/runtime.xml
deleted file mode 100644
index d4069f2..0000000
--- a/.idea/libraries/runtime.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/test.xml b/.idea/libraries/test.xml
deleted file mode 100644
index 57ed5ef..0000000
--- a/.idea/libraries/test.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 3131f62..f126aa3 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,26 +1,13 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 55adcb9..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Run Tests.xml b/.idea/runConfigurations/Run Tests.xml
deleted file mode 100644
index 3217d0c..0000000
--- a/.idea/runConfigurations/Run Tests.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 35eb1dd..94a25f7 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
new file mode 100644
index 0000000..48c5805
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,26 @@
+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/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index 48ea182..0000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# Changelog
-
-## [1.0.0](https://github.com/ethauvin/isgd-shorten/tree/1.0.0) (2023-09-25)
-
-[Full Changelog](https://github.com/ethauvin/isgd-shorten/compare/0.9.1...1.0.0)
-
-**Implemented enhancements:**
-
-- Add config builder [\#3](https://github.com/ethauvin/isgd-shorten/issues/3)
-- Use UrlEncoder instead of java.net.URLEncoder [\#2](https://github.com/ethauvin/isgd-shorten/issues/2)
-- Implement a way to retrieve the error response message. [\#1](https://github.com/ethauvin/isgd-shorten/issues/1)
-
-## [0.9.1](https://github.com/ethauvin/isgd-shorten/tree/0.9.1) (2020-06-10)
-
-[Full Changelog](https://github.com/ethauvin/isgd-shorten/compare/60c449feed0ddced600d7135766243e7058d683a...0.9.1)
-
-
-
-\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
diff --git a/LICENSE.txt b/LICENSE.txt
index 75e61da..2fadd27 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,5 @@
-Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
+Copyright (c) 2020, Erik C. Thauvin (erik@thauvin.net)
+All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
diff --git a/README.md b/README.md
index 7bff2fb..a345094 100644
--- a/README.md
+++ b/README.md
@@ -1,34 +1,26 @@
-[](https://opensource.org/licenses/BSD-3-Clause)
-[](https://kotlinlang.org/)
-[](https://rife2.com/bld)
-[](https://github.com/ethauvin/isgd-shorten/releases/latest)
-[](https://central.sonatype.com/artifact/net.thauvin.erik/isgd-shorten)
-[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/isgd-shorten/)
+[](http://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/isgd-shorten/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten) [](https://bintray.com/ethauvin/maven/isgd-shorten/_latestVersion) \
+[](https://snyk.io/test/github/ethauvin/isgd-shorten?targetFile=pom.xml) [](https://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten) [](https://travis-ci.com/ethauvin/isgd-shorten) [](https://circleci.com/gh/ethauvin/isgd-shorten/tree/master)
+# [is.gd](https://is.gd/developers.php) Shortener for Kotlin/Java
-[](https://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten)
-[](https://github.com/ethauvin/isgd-shorten/actions/workflows/bld.yml)
-[](https://circleci.com/gh/ethauvin/isgd-shorten/tree/master)
-
-# [is.gd](https://is.gd/developers.php) Shortener for Kotlin, Java & Android
-
-A simple implementation of the [is.gd](https://is.gd/) URL shortening and lookup [APIs](https://is.gd/developers.php).
+A simple implementation of the [is.gd API](https://is.gd/developers.php).
## Examples (TL;DR)
```kotlin
import net.thauvin.erik.isgd.Isgd
-// ...
+...
Isgd.shorten("https://www.example.com/") // returns https://is.gd/Pt2sET
Isgd.lookup("https://is.gd/Pt2sET") // returns https://www.example.com
```
-- View [bld](https://github.com/ethauvin/isgd-shorten/blob/master/examples/bld) or [Gradle](https://github.com/ethauvin/isgd-shorten/blob/master/examples/gradle) Examples.
+ - View [Kotlin](https://github.com/ethauvin/isgd-shorten/blob/master/examples/src/main/kotlin/com/example/IsgdExample.kt) or [Java](https://github.com/ethauvin/isgd-shorten/blob/master/examples/src/main/java/com/example/IsgdSample.java) Examples.
-## JSON or XML
+
+### JSON or XML
The [is.gd API](https://is.gd/developers.php) can return data in plain text (default), JSON or XML.
@@ -42,117 +34,36 @@ returns:
{ "shorturl": "https://is.gd/Pt2sET" }
```
-## Parameters
+### Parameters
All of the [is.gd API](https://is.gd/developers.php) parameters are supported:
```kotlin
-Isgd.shorten(
- url = url,
- shorturl="foobar",
- callback = "test",
- logstats = true,
- format = Format.JSON)
+Isgd.shorten(url = url, shorturl="foobar", callback = "test", logstats = true, format = Format.JSON)
```
-
returns:
-```js
+```json
test({ "shorturl": "https://is.gd/foobar" });
```
+### Gradle
-## bld
-
-To use with [bld](https://rife2.com/bld), include the following dependency in your [build](https://github.com/ethauvin/isgd-shorten/blob/master/examples/bld/src/bld/java/com/example/ExampleBuild.java) file:
-
-```java
-repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
-
-scope(compile)
- .include("net.thauvin.erik:isgd-shorten:1.1.0");
-```
-
-## Gradle, Maven, etc...
-
-To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/isgd-shorten/blob/master/examples/gradle/build.gradle.kts) file:
+To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/isgd-shorten/blob/master/examples/build.gradle.kts) file:
```gradle
repositories {
- mavenCentral()
- maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } // only needed for SNAPSHOT
+ jcenter()
}
dependencies {
- implementation("net.thauvin.erik:isgd-shorten:1.1.0")
+ implementation("net.thauvin.erik:isgd-shorten:0.9.1")
}
```
-Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/isgd-shorten).
-
-## Java
-
-To make it easier to use the library with Java, configuration builders are available:
-
-```java
-var config = new ShortenConfig.Builder("https://www.example.com/")
- .shorturl("foobar")
- .callback("test")
- .logstats(true)
- .format(Format.JSON)
- .build();
-
-Isgd.shorten(config);
-```
-
-```java
-var config = new LookupConfig.Builder("https://is.gd/Pt2sET")
- .callback("test")
- .format(Format.XML)
- .build();
-
-Isgd.lookup(config);
-```
-
-## Errors
-
-An `IsgdException` is thrown when an API error occurs. The error message (text, XML or JSON) and HTTP status code can be retrieved as follows:
-
-```kotlin
-try {
- Isgd.shorten("https://is.gd/Pt2sET") // already shorten
-} catch (e: IsgdException)
- println("Status Code: ${e.statusCode}")
- println("${e.message})
-}
-```
-
-```console
-Status Code: 400
-Error: Sorry, the URL you entered is on our internal blacklist. It may have been used abusively in the past, or it may link to another URL redirection service.
-```
-
-## v.gd
+### v.gd
Additionally, link can be shortened using [v.gd](https://v.gd/) by setting the `isVgd` flag:
```kotlin
Isgd.shorten("https://www.example.com/", isVgd = true) // returns https://v.gd/2z2ncj
```
-
-## 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/isgd-shorten.git
-```
-
-Then use [bld](https://rife2.com/bld) to build:
-
-```console
-cd isgd-shorten
-./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
deleted file mode 100644
index ace99d2..0000000
--- a/bitbucket-pipelines.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-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/bld b/bld
deleted file mode 100755
index 5237f94..0000000
--- a/bld
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env sh
-java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.IsgdShortenBuild "$@"
\ No newline at end of file
diff --git a/bld.bat b/bld.bat
deleted file mode 100644
index 7a1b7af..0000000
--- a/bld.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-@echo off
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.IsgdShortenBuild %*
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 0000000..5d82109
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,257 @@
+import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+import java.io.FileInputStream
+import java.util.Date
+import java.util.Properties
+
+plugins {
+ jacoco
+ `java-library`
+ `maven-publish`
+ id("com.github.ben-manes.versions") version "0.28.0"
+ id("com.jfrog.bintray") version "1.8.5"
+ id("io.gitlab.arturbosch.detekt") version "1.9.1"
+ id("net.thauvin.erik.gradle.semver") version "1.0.4"
+ id("org.jetbrains.dokka") version "0.10.1"
+ id("org.jetbrains.kotlin.jvm") version "1.3.72"
+ id("org.jetbrains.kotlin.kapt") version "1.3.72"
+ id("org.sonarqube") version "3.0"
+}
+
+group = "net.thauvin.erik"
+description = "is.gd Shortener 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"
+
+var semverProcessor = "net.thauvin.erik:semver:1.2.0"
+
+// Load local.properties
+File("local.properties").apply {
+ if (exists()) {
+ FileInputStream(this).use { fis ->
+ Properties().apply {
+ load(fis)
+ forEach { (k, v) ->
+ extra[k as String] = v
+ }
+ }
+ }
+ }
+}
+
+repositories {
+ jcenter()
+}
+
+dependencies {
+ // Align versions of all Kotlin components
+ implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
+
+ implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
+
+ testImplementation("org.jetbrains.kotlin:kotlin-test")
+ testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
+}
+
+kapt {
+ arguments {
+ arg("semver.project.dir", projectDir)
+ }
+}
+
+java {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+}
+
+detekt {
+ baseline = project.rootDir.resolve("detekt-baseline.xml")
+}
+
+jacoco {
+ toolVersion = "0.8.5"
+}
+
+sonarqube {
+ properties {
+ property("sonar.projectKey", "ethauvin_$name")
+ property("sonar.sourceEncoding", "UTF-8")
+ }
+}
+
+val sourcesJar by tasks.creating(Jar::class) {
+ archiveClassifier.set("sources")
+ from(sourceSets.getByName("main").allSource)
+}
+
+val javadocJar by tasks.creating(Jar::class) {
+ dependsOn(tasks.dokka)
+ from(tasks.dokka)
+ archiveClassifier.set("javadoc")
+ description = "Assembles a JAR of the generated Javadoc."
+ group = JavaBasePlugin.DOCUMENTATION_GROUP
+}
+
+tasks {
+ withType {
+ reports {
+ xml.isEnabled = true
+ html.isEnabled = true
+ }
+ }
+
+ withType().configureEach {
+ kotlinOptions.jvmTarget = "1.8"
+ }
+
+ withType {
+ destination = file("$projectDir/pom.xml")
+ }
+
+ assemble {
+ dependsOn(sourcesJar, javadocJar)
+ }
+
+ clean {
+ doLast {
+ project.delete(fileTree(deployDir))
+ }
+ }
+
+ val copyToDeploy by registering(Copy::class) {
+ from(configurations.runtimeClasspath) {
+ exclude("annotations-*.jar")
+ }
+ from(jar)
+ into(deployDir)
+ }
+
+ 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}")
+ }
+ }
+
+ val bintrayUpload by existing(BintrayUploadTask::class) {
+ dependsOn(publishToMavenLocal, gitTag)
+ doFirst {
+ versionName = "${project.version}"
+ versionDesc = "${project.name} ${project.version}"
+ versionVcsTag = "${project.version}"
+ versionReleased = Date().toString()
+ }
+ }
+
+ 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")
+ }
+
+ register("release") {
+ description = "Publishes version ${project.version} to Bintray."
+ group = PublishingPlugin.PUBLISH_TASK_GROUP
+ dependsOn("wrapper", bintrayUpload)
+ }
+
+ "sonarqube" {
+ dependsOn("jacocoTestReport")
+ }
+}
+
+fun findProperty(s: String) = project.findProperty(s) as String?
+bintray {
+ user = findProperty("bintray.user")
+ key = findProperty("bintray.apikey")
+ publish = isRelease
+ setPublications(publicationName)
+ pkg.apply {
+ repo = "maven"
+ name = project.name
+ desc = description
+ websiteUrl = mavenUrl
+ issueTrackerUrl = "$mavenUrl/issues"
+ githubRepo = gitHub
+ githubReleaseNotesFile = "README.md"
+ vcsUrl = "$mavenUrl.git"
+ setLabels(
+ "is.gd",
+ "v.gd",
+ "java",
+ "kotlin",
+ "shorten",
+ "shorten-urls",
+ "shortener",
+ "shortener-service",
+ "shortens-links",
+ "shorturl",
+ "url-shortener"
+ )
+ setLicenses("BSD 3-Clause")
+ publicDownloadNumbers = true
+ version.apply {
+ name = project.version as String
+ desc = description
+ vcsTag = project.version as String
+ gpg.apply {
+ sign = true
+ }
+ }
+ }
+}
+
+publishing {
+ publications {
+ create(publicationName) {
+ from(components["java"])
+ artifact(sourcesJar)
+ artifact(javadocJar)
+ pom.withXml {
+ asNode().apply {
+ appendNode("name", project.name)
+ appendNode("description", project.description)
+ appendNode("url", mavenUrl)
+
+ appendNode("licenses").appendNode("license").apply {
+ appendNode("name", "BSD 3-Clause")
+ appendNode("url", "https://opensource.org/licenses/BSD-3-Clause")
+ }
+
+ appendNode("developers").appendNode("developer").apply {
+ appendNode("id", "ethauvin")
+ appendNode("name", "Erik C. Thauvin")
+ appendNode("email", "erik@thauvin.net")
+ }
+
+ appendNode("scm").apply {
+ appendNode("connection", "scm:git:$mavenUrl.git")
+ appendNode("developerConnection", "scm:git:git@github.com:$gitHub.git")
+ appendNode("url", mavenUrl)
+ }
+
+ appendNode("issueManagement").apply {
+ appendNode("system", "GitHub")
+ appendNode("url", "$mavenUrl/issues")
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml
deleted file mode 100644
index 0eea41c..0000000
--- a/config/detekt/baseline.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
- LongParameterList:Isgd.kt$Isgd.Companion$( url: String, shorturl: String = "", callback: String = "", logstats: Boolean = false, format: Format = Format.SIMPLE, isVgd: Boolean = false )
- MagicNumber:Isgd.kt$Isgd.Companion$200
- MagicNumber:Isgd.kt$Isgd.Companion$399
- MaxLineLength:Isgd.kt$Isgd.Companion$*
- NestedBlockDepth:IsgdExample.kt$fun main(args: Array<String>)
- WildcardImport:IsgdTest.kt$import assertk.assertions.*
-
-
diff --git a/config/dokka/packages.md b/config/dokka/packages.md
deleted file mode 100644
index 69146fb..0000000
--- a/config/dokka/packages.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Module isgd-shorten
-
-Isgd Shortener for Kotlin, Java & Android
-
-A simple implementation of the `is.gd` URL shortening and lookup APIs.
diff --git a/detekt-baseline.xml b/detekt-baseline.xml
new file mode 100644
index 0000000..7a2ff7e
--- /dev/null
+++ b/detekt-baseline.xml
@@ -0,0 +1,7 @@
+
+
+
+
+ LongParameterList:Isgd.kt$Isgd.Companion$( url: String, shorturl: String = "", callback: String = "", logstats: Boolean = false, format: Format = Format.SIMPLE, isVgd: Boolean = false )
+
+
diff --git a/examples/gradle/.gitattributes b/examples/.gitattributes
similarity index 100%
rename from examples/gradle/.gitattributes
rename to examples/.gitattributes
diff --git a/examples/gradle/.gitignore b/examples/.gitignore
similarity index 100%
rename from examples/gradle/.gitignore
rename to examples/.gitignore
diff --git a/examples/bld/.gitignore b/examples/bld/.gitignore
deleted file mode 100644
index a2805aa..0000000
--- a/examples/bld/.gitignore
+++ /dev/null
@@ -1,55 +0,0 @@
-.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
deleted file mode 100644
index 26d3352..0000000
--- a/examples/bld/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/examples/bld/.idea/.name b/examples/bld/.idea/.name
deleted file mode 100644
index fdb4a4a..0000000
--- a/examples/bld/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-isgd-shorten-examples-bld
\ No newline at end of file
diff --git a/examples/bld/.idea/app.iml b/examples/bld/.idea/app.iml
deleted file mode 100644
index 2c1fe21..0000000
--- a/examples/bld/.idea/app.iml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/bld.iml b/examples/bld/.idea/bld.iml
deleted file mode 100644
index e63e11e..0000000
--- a/examples/bld/.idea/bld.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/inspectionProfiles/Project_Default.xml b/examples/bld/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 1e01b48..0000000
--- a/examples/bld/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/bld.xml b/examples/bld/.idea/libraries/bld.xml
deleted file mode 100644
index 153a060..0000000
--- a/examples/bld/.idea/libraries/bld.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/bld/.idea/libraries/compile.xml b/examples/bld/.idea/libraries/compile.xml
deleted file mode 100644
index 99cc0c0..0000000
--- a/examples/bld/.idea/libraries/compile.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/runtime.xml b/examples/bld/.idea/libraries/runtime.xml
deleted file mode 100644
index d4069f2..0000000
--- a/examples/bld/.idea/libraries/runtime.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/test.xml b/examples/bld/.idea/libraries/test.xml
deleted file mode 100644
index 57ed5ef..0000000
--- a/examples/bld/.idea/libraries/test.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/misc.xml b/examples/bld/.idea/misc.xml
deleted file mode 100644
index 301a237..0000000
--- a/examples/bld/.idea/misc.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/modules.xml b/examples/bld/.idea/modules.xml
deleted file mode 100644
index 55adcb9..0000000
--- a/examples/bld/.idea/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/runConfigurations/Run Tests.xml b/examples/bld/.idea/runConfigurations/Run Tests.xml
deleted file mode 100644
index 2b503e5..0000000
--- a/examples/bld/.idea/runConfigurations/Run Tests.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.idea/vcs.xml b/examples/bld/.idea/vcs.xml
deleted file mode 100644
index b2bdec2..0000000
--- a/examples/bld/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/bld/.vscode/launch.json b/examples/bld/.vscode/launch.json
deleted file mode 100644
index 30a8889..0000000
--- a/examples/bld/.vscode/launch.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- "type": "java",
- "name": "Run Tests",
- "request": "launch",
- "mainClass": "com.example.ExampleTest"
- }
- ]
-}
diff --git a/examples/bld/.vscode/settings.json b/examples/bld/.vscode/settings.json
deleted file mode 100644
index ba429d0..0000000
--- a/examples/bld/.vscode/settings.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "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
deleted file mode 100644
index 7b7a4a6..0000000
--- a/examples/bld/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-## Kotlin Example
-To compile & run the Kotlin example:
-
-```console
-./bld compile
-
-./bld run --args='https://www.example.com https://is.gd/Pt2sET'
-```
-
-## Java Example
-To compile & run the Java example:
-
-```console
-./bld compile
-
-./bld run-java --args='https://www.example.com https://is.gd/Pt2sET'
-
-```
diff --git a/examples/bld/bld b/examples/bld/bld
deleted file mode 100755
index 80d2986..0000000
--- a/examples/bld/bld
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env sh
-java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build com.example.ExampleBuild "$@"
\ No newline at end of file
diff --git a/examples/bld/bld.bat b/examples/bld/bld.bat
deleted file mode 100644
index 084bb72..0000000
--- a/examples/bld/bld.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-@echo off
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build com.example.ExampleBuild %*
\ No newline at end of file
diff --git a/examples/bld/lib/bld/bld-wrapper.jar b/examples/bld/lib/bld/bld-wrapper.jar
deleted file mode 100644
index ee1bfee..0000000
Binary files a/examples/bld/lib/bld/bld-wrapper.jar and /dev/null differ
diff --git a/examples/bld/lib/bld/bld-wrapper.properties b/examples/bld/lib/bld/bld-wrapper.properties
deleted file mode 100644
index 1156265..0000000
--- a/examples/bld/lib/bld/bld-wrapper.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-bld.downloadExtensionJavadoc=false
-bld.downloadExtensionSources=true
-bld.downloadLocation=
-bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10
-bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
-bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
-bld.sourceDirectories=
-bld.version=2.2.1
diff --git a/examples/bld/src/bld/java/com/example/ExampleBuild.java b/examples/bld/src/bld/java/com/example/ExampleBuild.java
deleted file mode 100644
index 172466e..0000000
--- a/examples/bld/src/bld/java/com/example/ExampleBuild.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.example;
-
-import rife.bld.BaseProject;
-import rife.bld.BuildCommand;
-import rife.bld.extension.CompileKotlinOperation;
-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 = "com.example";
- name = "Example";
- version = version(0, 1, 0);
-
- mainClass = "com.example.IsgdExampleKt";
-
- javaRelease = 11;
- downloadSources = true;
- autoDownloadPurge = true;
- repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
-
- scope(compile)
- .include(dependency("net.thauvin.erik:isgd-shorten:1.1.1-SNAPSHOT"));
- }
-
- public static void main(String[] args) {
- new ExampleBuild().start(args);
- }
-
- @Override
- public void compile() throws Exception {
- new CompileKotlinOperation()
- .fromProject(this)
- .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("com.example.IsgdSample")
- .execute();
- }
-}
diff --git a/examples/bld/src/main/java/com/example/IsgdSample.java b/examples/bld/src/main/java/com/example/IsgdSample.java
deleted file mode 100644
index ed0d774..0000000
--- a/examples/bld/src/main/java/com/example/IsgdSample.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.example;
-
-import net.thauvin.erik.isgd.Format;
-import net.thauvin.erik.isgd.Isgd;
-import net.thauvin.erik.isgd.IsgdException;
-import net.thauvin.erik.isgd.LookupConfig;
-
-public final class IsgdSample {
- public static void main(final String[] args) {
- if (args.length > 0) {
- for (final String arg : args) {
- try {
- if (arg.contains("is.gd")) {
- System.out.println(arg + " <-- " + Isgd.lookup(arg));
- System.out.print(Isgd.lookup(new LookupConfig.Builder(arg).format(Format.WEB).build()));
- } else {
- System.out.println(arg + " --> " + Isgd.shorten(arg));
- }
- } catch (IsgdException e) {
- System.out.println(e.getMessage());
- }
- }
- } else {
- System.err.println("Try specifying one or more URLs as arguments.");
- }
- System.exit(0);
- }
-}
diff --git a/examples/bld/src/main/kotlin/com/example/IsgdExample.kt b/examples/bld/src/main/kotlin/com/example/IsgdExample.kt
deleted file mode 100644
index fe721a0..0000000
--- a/examples/bld/src/main/kotlin/com/example/IsgdExample.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.example
-
-import net.thauvin.erik.isgd.Isgd
-import net.thauvin.erik.isgd.IsgdException
-import kotlin.system.exitProcess
-
-fun main(args: Array) {
- if (args.isNotEmpty()) {
- args.forEach {
- try {
- if (it.contains("is.gd"))
- println(it + " <-- " + Isgd.lookup(it))
- else
- println(it + " --> " + Isgd.shorten(it))
- } catch (e: IsgdException) {
- println(e.message)
- }
- }
- } else {
- println("Try specifying one or more URLs as arguments.")
- }
- exitProcess(0)
-}
diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts
new file mode 100644
index 0000000..8407c23
--- /dev/null
+++ b/examples/build.gradle.kts
@@ -0,0 +1,32 @@
+plugins {
+ id("org.jetbrains.kotlin.jvm") version "1.3.72"
+ id("com.github.ben-manes.versions") version "0.28.0"
+ application
+}
+
+// ./gradlew run --args='https://wwwcom.example. https://is.gd/Pt2sET'
+// ./gradlew runJava --args='https://www.example.com https://is.gd/Pt2sET'
+
+repositories {
+ mavenLocal()
+ jcenter()
+}
+
+dependencies {
+ implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
+ implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
+
+ implementation("net.thauvin.erik:isgd-shorten:0.9.0-beta")
+}
+
+application {
+ mainClassName = "com.example.IsgdExampleKt"
+}
+
+tasks {
+ register("runJava", JavaExec::class) {
+ group = "application"
+ main = "com.example.IsgdSample"
+ classpath = sourceSets["main"].runtimeClasspath
+ }
+}
diff --git a/examples/gradle/.idea/.gitignore b/examples/gradle/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/examples/gradle/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/examples/gradle/.idea/.name b/examples/gradle/.idea/.name
deleted file mode 100644
index a595e88..0000000
--- a/examples/gradle/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-isgd-shorten-examples-gradle
\ No newline at end of file
diff --git a/examples/gradle/.idea/gradle.xml b/examples/gradle/.idea/gradle.xml
deleted file mode 100644
index f2c1963..0000000
--- a/examples/gradle/.idea/gradle.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/inspectionProfiles/Project_Default.xml b/examples/gradle/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 1e01b48..0000000
--- a/examples/gradle/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/kotlinc.xml b/examples/gradle/.idea/kotlinc.xml
deleted file mode 100644
index 6d0ee1c..0000000
--- a/examples/gradle/.idea/kotlinc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/libraries/Gradle__net_thauvin_erik_isgd_shorten_1_0_2_SNAPSHOT.xml b/examples/gradle/.idea/libraries/Gradle__net_thauvin_erik_isgd_shorten_1_0_2_SNAPSHOT.xml
deleted file mode 100644
index 21fabac..0000000
--- a/examples/gradle/.idea/libraries/Gradle__net_thauvin_erik_isgd_shorten_1_0_2_SNAPSHOT.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/libraries/Gradle__net_thauvin_erik_urlencoder_urlencoder_lib_jvm_1_5_0.xml b/examples/gradle/.idea/libraries/Gradle__net_thauvin_erik_urlencoder_urlencoder_lib_jvm_1_5_0.xml
deleted file mode 100644
index a546fd2..0000000
--- a/examples/gradle/.idea/libraries/Gradle__net_thauvin_erik_urlencoder_urlencoder_lib_jvm_1_5_0.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml b/examples/gradle/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml
deleted file mode 100644
index e179fa0..0000000
--- a/examples/gradle/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_2_0_0.xml b/examples/gradle/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_2_0_0.xml
deleted file mode 100644
index 05bcccc..0000000
--- a/examples/gradle/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_2_0_0.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/misc.xml b/examples/gradle/.idea/misc.xml
deleted file mode 100644
index a4d3e28..0000000
--- a/examples/gradle/.idea/misc.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/modules.xml b/examples/gradle/.idea/modules.xml
deleted file mode 100644
index 2ec1f70..0000000
--- a/examples/gradle/.idea/modules.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/modules/isgd-shorten-examples-gradle.iml b/examples/gradle/.idea/modules/isgd-shorten-examples-gradle.iml
deleted file mode 100644
index 5fe3c00..0000000
--- a/examples/gradle/.idea/modules/isgd-shorten-examples-gradle.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/modules/isgd-shorten-examples-gradle.main.iml b/examples/gradle/.idea/modules/isgd-shorten-examples-gradle.main.iml
deleted file mode 100644
index dbd3931..0000000
--- a/examples/gradle/.idea/modules/isgd-shorten-examples-gradle.main.iml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-scripting-jvm/2.0.0/kotlin-scripting-jvm-2.0.0.jar
- $MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-scripting-common/2.0.0/kotlin-scripting-common-2.0.0.jar
- $MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.0.0/kotlin-stdlib-2.0.0.jar
- $MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar
- $MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-script-runtime/2.0.0/kotlin-script-runtime-2.0.0.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/modules/isgd-shorten-examples-gradle.test.iml b/examples/gradle/.idea/modules/isgd-shorten-examples-gradle.test.iml
deleted file mode 100644
index 6ade093..0000000
--- a/examples/gradle/.idea/modules/isgd-shorten-examples-gradle.test.iml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
- isgd-shorten-examples-gradle:main
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-scripting-jvm/2.0.0/kotlin-scripting-jvm-2.0.0.jar
- $MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-scripting-common/2.0.0/kotlin-scripting-common-2.0.0.jar
- $MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.0.0/kotlin-stdlib-2.0.0.jar
- $MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar
- $MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-script-runtime/2.0.0/kotlin-script-runtime-2.0.0.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/.idea/vcs.xml b/examples/gradle/.idea/vcs.xml
deleted file mode 100644
index b2bdec2..0000000
--- a/examples/gradle/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/gradle/README.md b/examples/gradle/README.md
deleted file mode 100644
index ba0bfd7..0000000
--- a/examples/gradle/README.md
+++ /dev/null
@@ -1,14 +0,0 @@
-## Kotlin Example
-To compile & run the Kotlin example:
-
-```console
-./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
-```
-
-## Java Example
-
-To compile & run the Java example:
-
-```console
-./gradlew runJava --args='https://www.example.com https://is.gd/Pt2sET'
-```
diff --git a/examples/gradle/build.gradle.kts b/examples/gradle/build.gradle.kts
deleted file mode 100644
index 989a94e..0000000
--- a/examples/gradle/build.gradle.kts
+++ /dev/null
@@ -1,38 +0,0 @@
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
-plugins {
- id("application")
- id("com.github.ben-manes.versions") version "0.51.0"
- kotlin("jvm") version "2.1.20"
-}
-
-repositories {
- mavenLocal()
- mavenCentral()
- maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } // only needed for SNAPSHOT
-}
-
-dependencies {
- implementation("net.thauvin.erik:isgd-shorten:1.1.1-SNAPSHOT")
-}
-
-java {
- sourceCompatibility = JavaVersion.VERSION_11
- targetCompatibility = JavaVersion.VERSION_11
-}
-
-application {
- mainClass.set("com.example.IsgdExampleKt")
-}
-
-kotlin {
- compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
-}
-
-tasks {
- register("runJava", JavaExec::class) {
- group = "application"
- mainClass.set("com.example.IsgdSample")
- classpath = sourceSets.main.get().runtimeClasspath
- }
-}
diff --git a/examples/gradle/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 1b33c55..0000000
Binary files a/examples/gradle/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/examples/gradle/gradlew b/examples/gradle/gradlew
deleted file mode 100755
index 23d15a9..0000000
--- a/examples/gradle/gradlew
+++ /dev/null
@@ -1,251 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright © 2015-2021 the original authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-#
-
-##############################################################################
-#
-# Gradle start up script for POSIX generated by Gradle.
-#
-# Important for running:
-#
-# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
-# noncompliant, but you have some other compliant shell such as ksh or
-# bash, then to run this script, type that shell name before the whole
-# command line, like:
-#
-# ksh Gradle
-#
-# Busybox and similar reduced shells will NOT work, because this script
-# requires all of these POSIX shell features:
-# * functions;
-# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
-# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
-# * compound commands having a testable exit status, especially «case»;
-# * various built-in commands including «command», «set», and «ulimit».
-#
-# Important for patching:
-#
-# (2) This script targets any POSIX shell, so it avoids extensions provided
-# by Bash, Ksh, etc; in particular arrays are avoided.
-#
-# The "traditional" practice of packing multiple parameters into a
-# space-separated string is a well documented source of bugs and security
-# problems, so this is (mostly) avoided, by progressively accumulating
-# options in "$@", and eventually passing that to Java.
-#
-# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
-# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
-# see the in-line comments for details.
-#
-# There are tweaks for specific operating systems such as AIX, CygWin,
-# Darwin, MinGW, and NonStop.
-#
-# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
-##############################################################################
-
-# Attempt to set APP_HOME
-
-# Resolve links: $0 may be a link
-app_path=$0
-
-# Need this for daisy-chained symlinks.
-while
- APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
- [ -h "$app_path" ]
-do
- ls=$( ls -ld "$app_path" )
- link=${ls#*' -> '}
- case $link in #(
- /*) app_path=$link ;; #(
- *) app_path=$APP_HOME$link ;;
- esac
-done
-
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD=maximum
-
-warn () {
- echo "$*"
-} >&2
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-} >&2
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "$( uname )" in #(
- CYGWIN* ) cygwin=true ;; #(
- Darwin* ) darwin=true ;; #(
- MSYS* | MINGW* ) msys=true ;; #(
- NONSTOP* ) nonstop=true ;;
-esac
-
-CLASSPATH="\\\"\\\""
-
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD=$JAVA_HOME/jre/sh/java
- else
- JAVACMD=$JAVA_HOME/bin/java
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD=java
- if ! command -v java >/dev/null 2>&1
- then
- die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-fi
-
-# Increase the maximum file descriptors if we can.
-if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
- case $MAX_FD in #(
- max*)
- # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC2039,SC3045
- MAX_FD=$( ulimit -H -n ) ||
- warn "Could not query maximum file descriptor limit"
- esac
- case $MAX_FD in #(
- '' | soft) :;; #(
- *)
- # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC2039,SC3045
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
-fi
-
-# Collect all arguments for the java command, stacking in reverse order:
-# * args from the command line
-# * the main class name
-# * -classpath
-# * -D...appname settings
-# * --module-path (only if needed)
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if "$cygwin" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
-
- JAVACMD=$( cygpath --unix "$JAVACMD" )
-
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- for arg do
- if
- case $arg in #(
- -*) false ;; # don't mess with options #(
- /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
- [ -e "$t" ] ;; #(
- *) false ;;
- esac
- then
- arg=$( cygpath --path --ignore --mixed "$arg" )
- fi
- # Roll the args list around exactly as many times as the number of
- # args, so each arg winds up back in the position where it started, but
- # possibly modified.
- #
- # NB: a `for` loop captures its iteration list before it begins, so
- # changing the positional parameters here affects neither the number of
- # iterations, nor the values presented in `arg`.
- shift # remove old arg
- set -- "$@" "$arg" # push replacement arg
- done
-fi
-
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Collect all arguments for the java command:
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
-# 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.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
- "$@"
-
-# Stop when "xargs" is not available.
-if ! command -v xargs >/dev/null 2>&1
-then
- die "xargs is not available"
-fi
-
-# Use "xargs" to parse quoted args.
-#
-# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
-#
-# In Bash we could simply go:
-#
-# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
-# set -- "${ARGS[@]}" "$@"
-#
-# but POSIX shell has neither arrays nor command substitution, so instead we
-# post-process each arg (as a line of input to sed) to backslash-escape any
-# character that might be a shell metacharacter, then use eval to reverse
-# that process (while maintaining the separation between arguments), and wrap
-# the whole thing up as a single "set" statement.
-#
-# This will of course break if any of these variables contains a newline or
-# an unmatched quote.
-#
-
-eval "set -- $(
- printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
- xargs -n1 |
- sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
- tr '\n' ' '
- )" '"$@"'
-
-exec "$JAVACMD" "$@"
diff --git a/examples/gradle/src/main/java/com/example/IsgdSample.java b/examples/gradle/src/main/java/com/example/IsgdSample.java
deleted file mode 100644
index ed0d774..0000000
--- a/examples/gradle/src/main/java/com/example/IsgdSample.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.example;
-
-import net.thauvin.erik.isgd.Format;
-import net.thauvin.erik.isgd.Isgd;
-import net.thauvin.erik.isgd.IsgdException;
-import net.thauvin.erik.isgd.LookupConfig;
-
-public final class IsgdSample {
- public static void main(final String[] args) {
- if (args.length > 0) {
- for (final String arg : args) {
- try {
- if (arg.contains("is.gd")) {
- System.out.println(arg + " <-- " + Isgd.lookup(arg));
- System.out.print(Isgd.lookup(new LookupConfig.Builder(arg).format(Format.WEB).build()));
- } else {
- System.out.println(arg + " --> " + Isgd.shorten(arg));
- }
- } catch (IsgdException e) {
- System.out.println(e.getMessage());
- }
- }
- } else {
- System.err.println("Try specifying one or more URLs as arguments.");
- }
- System.exit(0);
- }
-}
diff --git a/examples/gradle/src/main/kotlin/com/example/IsgdExample.kt b/examples/gradle/src/main/kotlin/com/example/IsgdExample.kt
deleted file mode 100644
index fe721a0..0000000
--- a/examples/gradle/src/main/kotlin/com/example/IsgdExample.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.example
-
-import net.thauvin.erik.isgd.Isgd
-import net.thauvin.erik.isgd.IsgdException
-import kotlin.system.exitProcess
-
-fun main(args: Array) {
- if (args.isNotEmpty()) {
- args.forEach {
- try {
- if (it.contains("is.gd"))
- println(it + " <-- " + Isgd.lookup(it))
- else
- println(it + " --> " + Isgd.shorten(it))
- } catch (e: IsgdException) {
- println(e.message)
- }
- }
- } else {
- println("Try specifying one or more URLs as arguments.")
- }
- exitProcess(0)
-}
diff --git a/examples/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..62d4c05
Binary files /dev/null and b/examples/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/gradle/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties
similarity index 74%
rename from examples/gradle/gradle/wrapper/gradle-wrapper.properties
rename to examples/gradle/wrapper/gradle-wrapper.properties
index ca025c8..622ab64 100644
--- a/examples/gradle/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/gradlew b/examples/gradlew
new file mode 100644
index 0000000..fbd7c51
--- /dev/null
+++ b/examples/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/examples/gradle/gradlew.bat b/examples/gradlew.bat
similarity index 72%
rename from examples/gradle/gradlew.bat
rename to examples/gradlew.bat
index db3a6ac..5093609 100644
--- a/examples/gradle/gradlew.bat
+++ b/examples/gradlew.bat
@@ -13,10 +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
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -27,8 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -43,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto init
-echo. 1>&2
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
@@ -57,36 +54,49 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto execute
+if exist "%JAVA_EXE%" goto init
-echo. 1>&2
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
:execute
@rem Setup the command line
-set CLASSPATH=
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-set EXIT_CODE=%ERRORLEVEL%
-if %EXIT_CODE% equ 0 set EXIT_CODE=1
-if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
-exit /b %EXIT_CODE%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/examples/gradle/settings.gradle.kts b/examples/settings.gradle.kts
similarity index 86%
rename from examples/gradle/settings.gradle.kts
rename to examples/settings.gradle.kts
index ed4a5c2..4ddea20 100644
--- a/examples/gradle/settings.gradle.kts
+++ b/examples/settings.gradle.kts
@@ -7,4 +7,4 @@
* in the user manual at https://docs.gradle.org/6.2/userguide/multi_project_builds.html
*/
-rootProject.name = "isgd-shorten-examples-gradle"
+rootProject.name = "isgd-examples"
diff --git a/examples/src/main/java/com/example/IsgdSample.java b/examples/src/main/java/com/example/IsgdSample.java
new file mode 100644
index 0000000..2328776
--- /dev/null
+++ b/examples/src/main/java/com/example/IsgdSample.java
@@ -0,0 +1,20 @@
+package com.example;
+
+import net.thauvin.erik.isgd.Isgd;
+
+public final class IsgdSample {
+ public static void main(final String[] args) {
+ if (args.length > 0) {
+ for (final String arg : args) {
+ if (arg.contains("is.gd")) {
+ System.out.println(arg + " <-- " + Isgd.lookup(arg));
+ } else {
+ System.out.println(arg + " --> " + Isgd.shorten(arg));
+ }
+ }
+ } else {
+ System.err.println("Try specifying one or more URLs as arguments.");
+ }
+ System.exit(0);
+ }
+}
diff --git a/examples/src/main/kotlin/com/example/IsgdExample.kt b/examples/src/main/kotlin/com/example/IsgdExample.kt
new file mode 100644
index 0000000..5acaad5
--- /dev/null
+++ b/examples/src/main/kotlin/com/example/IsgdExample.kt
@@ -0,0 +1,18 @@
+package com.example
+
+import net.thauvin.erik.isgd.Isgd
+import kotlin.system.exitProcess
+
+fun main(args: Array) {
+ if (args.isNotEmpty()) {
+ args.forEach {
+ if (it.contains("is.gd"))
+ println(it + " <-- " + Isgd.lookup(it))
+ else
+ println(it + " --> " + Isgd.shorten(it))
+ }
+ } else {
+ println("Try specifying one or more URLs as arguments.")
+ }
+ exitProcess(0)
+}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..62d4c05
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..622ab64
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..fbd7c51
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..5093609
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,104 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar
deleted file mode 100644
index a252a09..0000000
Binary files a/lib/bld/bld-wrapper.jar and /dev/null differ
diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties
deleted file mode 100644
index 751133d..0000000
--- a/lib/bld/bld-wrapper.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-bld.downloadExtensionJavadoc=false
-bld.downloadExtensionSources=true
-bld.downloadLocation=
-bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT
-bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.4-SNAPSHOT
-bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10
-bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
-bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
-bld.sourceDirectories=
-bld.version=2.2.1
diff --git a/pom.xml b/pom.xml
index 33a16b9..a56815b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,12 +1,35 @@
-
+
+
+
+
+
+
4.0.0
net.thauvin.erik
isgd-shorten
- 1.1.1-SNAPSHOT
+ 0.9.1
+
+
+
+ org.jetbrains.kotlin
+ kotlin-bom
+ 1.3.72
+ pom
+ import
+
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ 1.3.72
+ runtime
+
+
isgd-shorten
- A simple implementation of the is.gd URL shortening and lookup APIs
+ is.gd Shortener for Kotlin/Java
https://github.com/ethauvin/isgd-shorten
@@ -14,26 +37,11 @@
https://opensource.org/licenses/BSD-3-Clause
-
-
- org.jetbrains.kotlin
- kotlin-stdlib
- 2.1.20
- compile
-
-
- net.thauvin.erik.urlencoder
- urlencoder-lib-jvm
- 1.6.0
- compile
-
-
ethauvin
Erik C. Thauvin
erik@thauvin.net
- https://erik.thauvin.net/
@@ -41,4 +49,8 @@
scm:git:git@github.com:ethauvin/isgd-shorten.git
https://github.com/ethauvin/isgd-shorten
+
+ GitHub
+ https://github.com/ethauvin/isgd-shorten/issues
+
diff --git a/settings.gradle.kts b/settings.gradle.kts
new file mode 100644
index 0000000..4383f65
--- /dev/null
+++ b/settings.gradle.kts
@@ -0,0 +1 @@
+rootProject.name = "isgd-shorten"
diff --git a/sonar-project.properties b/sonar-project.properties
deleted file mode 100644
index 07235d2..0000000
--- a/sonar-project.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-sonar.organization=ethauvin-github
-sonar.projectKey=ethauvin_isgd-shorten
-sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml
-sonar.sources=src/main/kotlin/
-sonar.tests=src/test/kotlin/
-sonar.java.binaries=build/main,build/test
-sonar.java.libraries=lib/compile/*.jar
diff --git a/src/bld/java/net/thauvin/erik/IsgdShortenBuild.java b/src/bld/java/net/thauvin/erik/IsgdShortenBuild.java
deleted file mode 100644
index 49abd79..0000000
--- a/src/bld/java/net/thauvin/erik/IsgdShortenBuild.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * IsgdShortenBuild.java
- *
- * Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik;
-
-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.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;
-import rife.bld.publish.PublishLicense;
-import rife.bld.publish.PublishScm;
-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 IsgdShortenBuild extends Project {
- final File srcMainKotlin = new File(srcMainDirectory(), "kotlin");
-
- public IsgdShortenBuild() {
- pkg = "net.thauvin.erik";
- name = "isgd-shorten";
- version = version(1, 1, 1, "SNAPSHOT");
-
- javaRelease = 11;
- downloadSources = true;
- autoDownloadPurge = true;
-
- repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
-
- final var kotlin = version(2, 1, 20);
- scope(compile)
- .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin))
- .include(dependency("net.thauvin.erik.urlencoder", "urlencoder-lib-jvm", version(1, 6, 0)));
- scope(test)
- .include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
- .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
- .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)))
- .include(dependency("org.junit.platform", "junit-platform-launcher", version(1, 12, 2)))
- .include(dependency("com.willowtreeapps.assertk", "assertk-jvm", version(0, 28, 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 simple implementation of the is.gd URL shortening and lookup APIs")
- .url("https://github.com/ethauvin/" + name)
- .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")
- )
- .scm(new PublishScm()
- .connection("scm:git:https://github.com/ethauvin/" + name + ".git")
- .developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
- .url("https://github.com/ethauvin/" + name)
- )
- .signKey(property("sign.key"))
- .signPassphrase(property("sign.passphrase"));
-
- jarSourcesOperation().sourceDirectories(srcMainKotlin);
- }
-
- public static void main(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 IsgdShortenBuild().start(args);
- }
-
- @BuildCommand(summary = "Compiles the Kotlin project")
- @Override
- public void compile() throws Exception {
- new CompileKotlinOperation()
- .fromProject(this)
- .compileOptions(new CompileOptions().verbose(true))
- .execute();
- }
-
- @BuildCommand(summary = "Checks source with Detekt")
- public void detekt() throws ExitStatusException, IOException, InterruptedException {
- new DetektOperation()
- .fromProject(this)
- .baseline("config/detekt/baseline.xml")
- .execute();
- }
-
- @BuildCommand(value = "detekt-baseline", summary = "Creates the Detekt baseline")
- public void detektBaseline() throws ExitStatusException, IOException, InterruptedException {
- new DetektOperation()
- .fromProject(this)
- .baseline("config/detekt/baseline.xml")
- .createBaseline(true)
- .execute();
- }
-
- @BuildCommand(summary = "Generates JaCoCo Reports")
- public void jacoco() throws Exception {
- new JacocoReportOperation()
- .fromProject(this)
- .sourceFiles(srcMainKotlin)
- .execute();
- }
-
- @Override
- public void javadoc() throws ExitStatusException, IOException, InterruptedException {
- new DokkaOperation()
- .fromProject(this)
- .loggingLevel(LoggingLevel.INFO)
- .moduleName("is.gd Shorten")
- .moduleVersion(version.toString())
- .outputDir(new File(buildDirectory(), "javadoc"))
- .outputFormat(OutputFormat.JAVADOC)
- .execute();
- }
-
- @Override
- public void publish() throws Exception {
- super.publish();
- 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(),
- new File(workDirectory, "pom.xml"));
- }
-}
diff --git a/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt b/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt
index 9157567..c9a9afe 100644
--- a/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt
+++ b/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt
@@ -1,7 +1,8 @@
/*
* Isgd.kt
*
- * Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2020, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -31,91 +32,53 @@
package net.thauvin.erik.isgd
-import net.thauvin.erik.urlencoder.UrlEncoderUtil
import java.net.HttpURLConnection
-import java.net.URI
+import java.net.URL
+import java.net.URLEncoder
+import java.nio.charset.StandardCharsets
/**
- * See the [is.gd API](https://is.gd/apishorteningreference.php).
+ * See the [is.gd API](https://is.gd/apishorteningreference.php)
*/
enum class Format(val type: String) {
WEB("web"), SIMPLE("simple"), XML("xml"), JSON("json")
}
-fun String.encode(): String = UrlEncoderUtil.encode(this)
+fun String.encode(): String {
+ return URLEncoder.encode(this, StandardCharsets.UTF_8.name())
+}
-/**
- * Implements the [is.gd API](https://is.gd/developers.php).
- */
class Isgd private constructor() {
companion object {
private fun callApi(url: String): String {
- val connection = URI(url).toURL().openConnection() as HttpURLConnection
- try {
- connection.setRequestProperty(
- "User-Agent",
- "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0"
- )
- if (connection.responseCode in 200..399) {
- return connection.inputStream.bufferedReader().use { it.readText() }
- } else {
- throw IsgdException(
- connection.responseCode,
- connection.errorStream.bufferedReader().use { it.readText() })
- }
- } finally {
- connection.disconnect()
- }
+ val connection = URL(url).openConnection() as HttpURLConnection
+ connection.setRequestProperty(
+ "User-Agent",
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0"
+ )
+ return connection.inputStream.bufferedReader().readText()
}
- private fun getHost(isVgd: Boolean = false): String {
+ private fun host(isVgd: Boolean = false): String {
return if (isVgd) "v.gd" else "is.gd"
}
/**
- * Lookup a shortlink.
- *
* See the [is.gd API](https://is.gd/apilookupreference.php).
*/
@JvmStatic
- @Throws(IsgdException::class)
- fun lookup(config: LookupConfig): String {
- return lookup(
- config.shorturl,
- config.callback,
- config.format,
- config.isVgd
- )
- }
-
- /**
- * Lookup a shortlink.
- *
- * See the [is.gd API](https://is.gd/apilookupreference.php).
- *
- * @param shorturl The shorturl parameter is the shortened is.gd URL that you want to look up. You can either
- * submit the full address (e.g. `https://is.gd/example`) or only the unique part (e.g. `example`). The address
- * you submit should be properly formed; the API lookup function is not guaranteed to handle malformed URLs the
- * same way as when you visit them manually.
- * @param callback The callback parameter is used to specify a callback function to wrap the returned data in
- * when using JSON format. This can be useful when working with cross domain data. Even when using JSON format
- * this parameter is optional.
- * @param format The format parameter determines what format is.gd uses to send output back to you (e.g. to
- * tell you what your new shortened URL is or if an error has occurred).
- * @param isVgd Lookup using the `v.gd` domain.
- */
- @JvmStatic
@JvmOverloads
- @Throws(IsgdException::class)
fun lookup(
shorturl: String,
callback: String = "",
format: Format = Format.SIMPLE,
isVgd: Boolean = false
): String {
- require(shorturl.isNotEmpty()) { "Please specify a valid short URL to lookup." }
+ if (shorturl.isEmpty()) {
+ throw IllegalArgumentException("Please specify a valid short URL to lookup.")
+ }
- val sb = StringBuilder("https://${getHost(isVgd)}/forward.php?shorturl=${shorturl.encode()}")
+ val sb = StringBuilder("https://${host(isVgd)}/forward.php?shorturl=${shorturl.encode()}")
if (callback.isNotEmpty()) {
sb.append("&callback=${callback.encode()}")
@@ -127,51 +90,10 @@ class Isgd private constructor() {
}
/**
- * Shortens a link.
- *
* See the [is.gd API](https://is.gd/apishorteningreference.php).
*/
@JvmStatic
- @Throws(IsgdException::class)
- fun shorten(config: ShortenConfig): String {
- return shorten(
- config.url,
- config.shorturl,
- config.callback,
- config.logstats,
- config.format,
- config.isVgd
- )
- }
-
- /**
- * Shortens a link.
- *
- * See the [is.gd API](https://is.gd/apishorteningreference.php).
- *
- * @param url The url parameter is the address that you want to shorten.
- * @param shorturl You can specify the shorturl parameter if you'd like to pick a shortened URL instead of
- * having is.gd randomly generate one. These must be between 5 and 30 characters long and can only contain
- * alphanumeric characters and underscores. Shortened URLs are case sensitive. Bear in mind that a desired
- * short URL might already be taken (this is very often the case with common words) so if you're using this
- * option be prepared to respond to an error and get an alternative choice from your app's user.
- * @param callback The callback parameter is used to specify a callback function to wrap the returned data in
- * when using JSON format. This can be useful when working with cross domain data. Even when using JSON format
- * this parameter is optional.
- * @param logstats Turns on logging of detailed statistics when the shortened URL you create is accessed. This
- * allows you to see how many times the link was accessed on a given day, what pages referred people to the
- * link, what browser visitors were using etc. You can access these stats via the link preview page for your
- * shortened URL (add a hyphen/dash to the end of the shortened URL to get to it). Creating links with
- * statistics turned on has twice the "cost" towards our rate limit of other shortened links, so leave this
- * parameter out of your API call if you don't require statistics on usage. See the
- * [usage limits page](https://is.gd/usagelimits.php) for more information on this.
- * @param format The format parameter determines what format is.gd uses to send output back to you (e.g. to
- * tell you what your new shortened URL is or if an error has occurred).
- * @param isVgd Shorten using the `v.gd` domain.
- */
- @JvmStatic
@JvmOverloads
- @Throws(IsgdException::class)
fun shorten(
url: String,
shorturl: String = "",
@@ -180,9 +102,11 @@ class Isgd private constructor() {
format: Format = Format.SIMPLE,
isVgd: Boolean = false
): String {
- require(url.isNotEmpty()) { "Please enter a valid URL to shorten." }
+ if (url.isEmpty()) {
+ throw IllegalArgumentException("Please enter a valid URL to shorten.")
+ }
- val sb = StringBuilder("https://${getHost(isVgd)}/create.php?url=${url.encode()}")
+ val sb = StringBuilder("https://${host(isVgd)}/create.php?url=${url.encode()}")
if (shorturl.isNotEmpty()) {
sb.append("&shorturl=${shorturl.encode()}")
diff --git a/src/main/kotlin/net/thauvin/erik/isgd/IsgdException.kt b/src/main/kotlin/net/thauvin/erik/isgd/IsgdException.kt
deleted file mode 100644
index d44ea5a..0000000
--- a/src/main/kotlin/net/thauvin/erik/isgd/IsgdException.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * IsgdException.kt
- *
- * Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik.isgd
-
-/**
- * Thrown when an exceptional condition has occurred.
- *
- * @property statusCode The HTTP status code.
- * @property message The error message.
- */
-class IsgdException(val statusCode: Int, message: String) : Exception(message) {
- companion object {
- private const val serialVersionUID = 1L
- }
-}
diff --git a/src/main/kotlin/net/thauvin/erik/isgd/LookupConfig.kt b/src/main/kotlin/net/thauvin/erik/isgd/LookupConfig.kt
deleted file mode 100644
index 6975ff2..0000000
--- a/src/main/kotlin/net/thauvin/erik/isgd/LookupConfig.kt
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * LookupConfig.kt
- *
- * Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik.isgd
-
-/**
- * Provides a builder to lookup an is.gd shortlink.
- */
-class LookupConfig private constructor(builder: Builder) {
- val shorturl: String = builder.shorturl
- val callback: String = builder.callback
- val format: Format = builder.format
- val isVgd: Boolean = builder.isVgd
-
- /**
- * Configures the parameters to lookup an is.gd shortlink.
- *
- * See the [is.gd Lookup]() API.
- *
- * @param shorturl The shorturl parameter is the shortened is.gd URL that you want to look up. You can either submit
- * the full address (e.g. `https://is.gd/example`) or only the unique part (e.g. `example`). The address you submit
- * should be properly formed; the API lookup function is not guaranteed to handle malformed URLs the same way as
- * when you visit them manually.
- */
- data class Builder(var shorturl: String) {
- var callback: String = ""
- var format: Format = Format.SIMPLE
- var isVgd: Boolean = false
-
- /**
- * The shorturl parameter is the shortened is.gd URL that you want to look up. You can either submit the full
- * address (e.g. `https://is.gd/example`) or only the unique part (e.g. `example`). The address you submit
- * should be properly formed; the API lookup function is not guaranteed to handle malformed URLs the same way
- * as when you visit them manually.
- */
- fun shorturl(shorturl: String): Builder = apply { this.shorturl = shorturl }
-
- /**
- * The callback parameter is used to specify a callback function to wrap the returned data in
- * when using JSON format. This can be useful when working with cross domain data. Even when using JSON format
- * this parameter is optional.
- */
- fun callback(callback: String): Builder = apply { this.callback = callback }
-
- /**
- * The format parameter determines what format is.gd uses to send output back to you (e.g. to
- * tell you what your new shortened URL is or if an error has occurred).
- */
- fun format(format: Format): Builder = apply { this.format = format }
-
- /**
- * Shorten using the `v.gd` domain.
- */
- fun isVgd(isVgd: Boolean): Builder = apply { this.isVgd = isVgd }
-
- /**
- * Builds a new configuration.
- */
- fun build() = LookupConfig(this)
- }
-}
diff --git a/src/main/kotlin/net/thauvin/erik/isgd/ShortenConfig.kt b/src/main/kotlin/net/thauvin/erik/isgd/ShortenConfig.kt
deleted file mode 100644
index a11fc4e..0000000
--- a/src/main/kotlin/net/thauvin/erik/isgd/ShortenConfig.kt
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * ShortenConfig.kt
- *
- * Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik.isgd
-
-/**
- * Provides a builder to create an is.gd shortlink.
- */
-class ShortenConfig private constructor(builder: Builder) {
- val url: String = builder.url
- val shorturl: String = builder.shorturl
- val callback: String = builder.callback
- val logstats: Boolean = builder.logstats
- val format: Format = builder.format
- val isVgd: Boolean = builder.isVgd
-
- /**
- * Configures the parameters to create an is.gd shortlink.
- *
- * See the [is.gd Shortening](https://is.gd/apishorteningreference.php) API.
- *
- * @param url The url parameter is the address that you want to shorten.
- */
- data class Builder(var url: String) {
- var shorturl: String = ""
- var callback: String = ""
- var logstats: Boolean = false
- var format: Format = Format.SIMPLE
- var isVgd: Boolean = false
-
- /**
- * The url parameter is the address that you want to shorten.
- */
- fun url(url: String): Builder = apply { this.url = url }
-
- /**
- * You can specify the shorturl parameter if you'd like to pick a shortened URL instead of
- * having is.gd randomly generate one. These must be between 5 and 30 characters long and can only contain
- * alphanumeric characters and underscores. Shortened URLs are case-sensitive. Bear in mind that a desired
- * short URL might already be taken (this is very often the case with common words) so if you're using this
- * option be prepared to respond to an error and get an alternative choice from your app's user.
- */
- fun shorturl(shorturl: String): Builder = apply { this.shorturl = shorturl }
-
- /**
- * The callback parameter is used to specify a callback function to wrap the returned data in
- * when using JSON format. This can be useful when working with cross domain data. Even when using JSON format
- * this parameter is optional.
- */
- fun callback(callback: String): Builder = apply { this.callback = callback }
-
- /**
- * Turns on logging of detailed statistics when the shortened URL you create is accessed. This
- * allows you to see how many times the link was accessed on a given day, what pages referred people to the
- * link, what browser visitors were using etc. You can access these stats via the link preview page for your
- * shortened URL (add a hyphen/dash to the end of the shortened URL to get to it). Creating links with
- * statistics turned on has twice the "cost" towards our rate limit of other shortened links, so leave this
- * parameter out of your API call if you don't require statistics on usage. See the
- * [usage limits page](https://is.gd/usagelimits.php) for more information on this.
- */
- fun logstats(logstats: Boolean): Builder = apply { this.logstats = logstats }
-
- /**
- * The format parameter determines what format is.gd uses to send output back to you (e.g. to
- * tell you what your new shortened URL is or if an error has occurred).
- */
- fun format(format: Format): Builder = apply { this.format = format }
-
- /**
- * Shorten using the `v.gd` domain.
- */
- fun isVgd(isVgd: Boolean): Builder = apply { this.isVgd = isVgd }
-
- /**
- * Builds a new configuration.
- */
- fun build() = ShortenConfig(this)
- }
-}
diff --git a/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt b/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
index 8048362..399030b 100644
--- a/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
@@ -1,7 +1,8 @@
/*
* IsgdTest.kt
*
- * Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2020, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -31,101 +32,28 @@
package net.thauvin.erik.isgd
-import assertk.all
-import assertk.assertThat
-import assertk.assertions.*
import kotlin.test.Test
import kotlin.test.assertEquals
-import kotlin.test.assertFailsWith
+import kotlin.test.assertTrue
class IsgdTest {
private val url = "https://www.example.com"
private val shortUrl = "https://is.gd/Pt2sET"
private val shortVgdUrl = "https://v.gd/2z2ncj"
- @Test
- fun testException() {
- assertFailsWith(
- message = "shorten(duplicate)",
- exceptionClass = IsgdException::class,
- block = { Isgd.shorten(shortUrl) }
- )
-
- try {
- Isgd.shorten(shortUrl)
- } catch (e: IsgdException) {
- assertThat(e, "shorten(duplicate)").all {
- prop(IsgdException::statusCode).isEqualTo(400)
- prop(IsgdException::message).isNotNull().startsWith("Error: ")
- }
- }
- }
-
- @Test
- fun testExceptionConfig() {
- assertFailsWith(
- message = "shorten(config:duplicate)",
- exceptionClass = IsgdException::class,
- block = { Isgd.shorten(ShortenConfig.Builder(shortUrl).build()) }
- )
- }
-
- @Test
- fun testLookup() {
- assertFailsWith(
- message = "lookup(empty)",
- exceptionClass = IllegalArgumentException::class,
- block = { Isgd.lookup("") }
- )
- }
-
- @Test
- fun testLookupConfig() {
- assertFailsWith(
- message = "lookup(config:empty)",
- exceptionClass = IllegalArgumentException::class,
- block = { Isgd.lookup(LookupConfig.Builder("").build()) }
- )
- }
-
@Test
fun testLookupDefault() {
assertEquals(url, Isgd.lookup(shortUrl))
- assertEquals(url, Isgd.lookup(shortVgdUrl, isVgd = true), "lookup(isVgd)")
- }
-
- @Test
- fun testLookupDefaultConfig() {
- assertEquals(url, Isgd.lookup(LookupConfig.Builder(shortUrl).build()), "lookup(config)")
- assertEquals(
- url, Isgd.lookup(
- LookupConfig.Builder(shortVgdUrl).isVgd(true).build()
- ), "lookup(config:isVgd)"
- )
+ assertEquals(url, Isgd.lookup(shortVgdUrl, isVgd = true), "v.gd")
}
@Test
fun testLookupJson() {
assertEquals("{ \"url\": \"$url\" }", Isgd.lookup(shortUrl, format = Format.JSON))
-
assertEquals(
"test({ \"url\": \"$url\" });",
Isgd.lookup(shortUrl, callback = "test", format = Format.JSON),
- "lookup(callback)"
- )
- }
-
- @Test
- fun testLookupJsonConfig() {
- assertEquals(
- "{ \"url\": \"$url\" }",
- Isgd.lookup(LookupConfig.Builder(shortUrl).format(Format.JSON).build()), "lookup(config)"
- )
-
- assertEquals(
- "test({ \"url\": \"$url\" });",
- Isgd.lookup(LookupConfig.Builder(shortUrl).callback("test").format(Format.JSON).build()),
- "lookup(config:callback)"
+ "with callback"
)
}
@@ -137,62 +65,10 @@ class IsgdTest {
)
}
- @Test
- fun testLookupXmlConfig() {
- assertEquals(
- "$url ",
- Isgd.lookup(LookupConfig.Builder(shortUrl).format(Format.XML).build()),
- "lookup(config:xml)"
- )
- }
-
- @Test
- fun testShorten() {
- assertFailsWith(
- message = "shorten(empty)",
- exceptionClass = IllegalArgumentException::class,
- block = { Isgd.shorten("") }
- )
-
- assertFailsWith(
- message = "shorten(shorturl)",
- exceptionClass = IsgdException::class,
- block = { Isgd.shorten(url, shorturl = "test") }
- )
- }
-
- @Test
- fun testShortenConfig() {
- assertFailsWith(
- message = "shorten(config:empty)",
- exceptionClass = IllegalArgumentException::class,
- block = { Isgd.shorten(ShortenConfig.Builder("").build()) }
- )
-
- assertFailsWith(
- message = "shorten(config:shorturl)",
- exceptionClass = IsgdException::class,
- block = { Isgd.shorten(ShortenConfig.Builder(url).shorturl("test").build()) }
- )
- }
-
@Test
fun testShortenDefault() {
- assertEquals(shortUrl, Isgd.shorten(url), "shorten(url)")
- assertEquals(shortVgdUrl, Isgd.shorten(url, isVgd = true), "shorten(isVgd)")
- assertThat(Isgd.shorten(url, logstats = true), "shorten(callback)").matches("https://is.gd/\\w{6}".toRegex())
- }
-
- @Test
- fun testShortenDefaultConfig() {
- assertEquals(shortUrl, Isgd.shorten(ShortenConfig.Builder(url).build()), "shorten(config:url)")
- assertEquals(
- shortVgdUrl,
- Isgd.shorten(ShortenConfig.Builder(url).isVgd(true).build()),
- "shorten(config:isVgd)"
- )
- assertThat(Isgd.shorten(ShortenConfig.Builder(url).logstats(true).build()), "shorten(config:callback)")
- .matches("https://is.gd/\\w{6}".toRegex())
+ assertEquals(shortUrl, Isgd.shorten(url))
+ assertEquals(shortVgdUrl, Isgd.shorten(url, isVgd = true), "v.gd")
}
@Test
@@ -201,50 +77,20 @@ class IsgdTest {
assertEquals(
"test({ \"shorturl\": \"$shortUrl\" });",
Isgd.shorten(url, callback = "test", format = Format.JSON),
- "shorten(callback,json)"
- )
- }
-
- @Test
- fun testShortenJsonConfig() {
- assertEquals(
- "{ \"shorturl\": \"$shortUrl\" }",
- Isgd.shorten(ShortenConfig.Builder(url).format(Format.JSON).build()), "shorten(config:json)"
- )
- assertEquals(
- "test({ \"shorturl\": \"$shortUrl\" });",
- Isgd.shorten(ShortenConfig.Builder(url).callback("test").format(Format.JSON).build()),
- "shorten(config:callback,json)"
+ "with callback"
)
}
@Test
fun testShortenXml() {
assertEquals(
- "" +
- "$shortUrl ",
+ "$shortUrl ",
Isgd.shorten(url, format = Format.XML)
)
}
- @Test
- fun testShortenXmlConfig() {
- assertEquals(
- "" +
- "$shortUrl ",
- Isgd.shorten(ShortenConfig.Builder(url).format(Format.XML).build()),
- "shorten(config:xml)"
- )
- }
-
@Test
fun testShortenWeb() {
- assertThat(Isgd.shorten(url, format = Format.WEB)).contains(shortUrl)
- }
-
- @Test
- fun testShortenWebConfig() {
- assertThat(Isgd.shorten(ShortenConfig.Builder(url).format(Format.WEB).build()), "shorten(config:web)")
- .contains(shortUrl)
+ assertTrue(Isgd.shorten(url, format = Format.WEB).contains(shortUrl))
}
}
diff --git a/version.properties b/version.properties
new file mode 100644
index 0000000..7d7030f
--- /dev/null
+++ b/version.properties
@@ -0,0 +1,8 @@
+#Generated by the Semver Plugin for Gradle
+#Sat Mar 21 16:36:23 PDT 2020
+version.buildmeta=
+version.major=0
+version.minor=9
+version.patch=1
+version.prerelease=
+version.semver=0.9.1