-
-
+
\ No newline at end of file
diff --git a/.idea/isgd-shorten.iml b/.idea/isgd-shorten.iml
deleted file mode 100644
index 78b2cc5..0000000
--- a/.idea/isgd-shorten.iml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..9d6ea82
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml
new file mode 100644
index 0000000..153a060
--- /dev/null
+++ b/.idea/libraries/bld.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/libraries/compile.xml b/.idea/libraries/compile.xml
new file mode 100644
index 0000000..99cc0c0
--- /dev/null
+++ b/.idea/libraries/compile.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/runtime.xml b/.idea/libraries/runtime.xml
new file mode 100644
index 0000000..d4069f2
--- /dev/null
+++ b/.idea/libraries/runtime.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/test.xml b/.idea/libraries/test.xml
new file mode 100644
index 0000000..57ed5ef
--- /dev/null
+++ b/.idea/libraries/test.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index f126aa3..3131f62 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,13 +1,26 @@
-
-
-
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..55adcb9
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Run Tests.xml b/.idea/runConfigurations/Run Tests.xml
new file mode 100644
index 0000000..3217d0c
--- /dev/null
+++ b/.idea/runConfigurations/Run Tests.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 48c5805..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-language: java
-dist: trusty
-
-env:
- global:
- - CI=true
-
-#install:
-# - git fetch --unshallow --tags
-
-addons:
- sonarcloud:
- organization: "ethauvin-github"
-
-jdk:
- - oraclejdk8
- - openjdk14
-
-before_install:
- - chmod +x gradlew
-
-after_success:
- - |
- if [ "${TRAVIS_TEST_RESULT}" == 0 ] && [ "$TRAVIS_JDK_VERSION" == "openjdk14" ]; then
- ./gradlew sonarqube
- fi
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..48ea182
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,19 @@
+# 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 2fadd27..75e61da 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,5 +1,4 @@
-Copyright (c) 2020, Erik C. Thauvin (erik@thauvin.net)
-All rights reserved.
+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:
diff --git a/README.md b/README.md
index a345094..7bff2fb 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,34 @@
-[](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)
+[](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/)
-# [is.gd](https://is.gd/developers.php) Shortener for Kotlin/Java
-A simple implementation of the [is.gd API](https://is.gd/developers.php).
+[](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).
## 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 [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.
+- 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.
-
-### 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.
@@ -34,36 +42,117 @@ 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:
-```json
+```js
test({ "shorturl": "https://is.gd/foobar" });
```
-### Gradle
-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:
+## 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:
```gradle
repositories {
- jcenter()
+ mavenCentral()
+ maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } // only needed for SNAPSHOT
}
dependencies {
- implementation("net.thauvin.erik:isgd-shorten:0.9.1")
+ implementation("net.thauvin.erik:isgd-shorten:1.1.0")
}
```
-### v.gd
+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
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
new file mode 100644
index 0000000..ace99d2
--- /dev/null
+++ b/bitbucket-pipelines.yml
@@ -0,0 +1,20 @@
+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
new file mode 100755
index 0000000..5237f94
--- /dev/null
+++ b/bld
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.IsgdShortenBuild "$@"
\ No newline at end of file
diff --git a/bld.bat b/bld.bat
new file mode 100644
index 0000000..7a1b7af
--- /dev/null
+++ b/bld.bat
@@ -0,0 +1,4 @@
+@echo off
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.IsgdShortenBuild %*
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
deleted file mode 100644
index 5d82109..0000000
--- a/build.gradle.kts
+++ /dev/null
@@ -1,257 +0,0 @@
-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
new file mode 100644
index 0000000..0eea41c
--- /dev/null
+++ b/config/detekt/baseline.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ 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
new file mode 100644
index 0000000..69146fb
--- /dev/null
+++ b/config/dokka/packages.md
@@ -0,0 +1,5 @@
+# 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
deleted file mode 100644
index 7a2ff7e..0000000
--- a/detekt-baseline.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
- 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/bld/.gitignore b/examples/bld/.gitignore
new file mode 100644
index 0000000..a2805aa
--- /dev/null
+++ b/examples/bld/.gitignore
@@ -0,0 +1,55 @@
+.gradle
+.DS_Store
+build
+lib/bld/**
+!lib/bld/bld-wrapper.jar
+!lib/bld/bld-wrapper.properties
+lib/compile/
+lib/runtime/
+lib/standalone/
+lib/test/
+
+# IDEA ignores
+
+# User-specific
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# SonarLint plugin
+.idea/sonarlint/
+
+# Editor-based Rest Client
+.idea/httpRequests
\ No newline at end of file
diff --git a/examples/bld/.idea/.gitignore b/examples/bld/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/examples/bld/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/examples/bld/.idea/.name b/examples/bld/.idea/.name
new file mode 100644
index 0000000..fdb4a4a
--- /dev/null
+++ b/examples/bld/.idea/.name
@@ -0,0 +1 @@
+isgd-shorten-examples-bld
\ No newline at end of file
diff --git a/examples/bld/.idea/app.iml b/examples/bld/.idea/app.iml
new file mode 100644
index 0000000..2c1fe21
--- /dev/null
+++ b/examples/bld/.idea/app.iml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/bld.iml b/examples/bld/.idea/bld.iml
new file mode 100644
index 0000000..e63e11e
--- /dev/null
+++ b/examples/bld/.idea/bld.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/inspectionProfiles/Project_Default.xml b/examples/bld/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..1e01b48
--- /dev/null
+++ b/examples/bld/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/bld.xml b/examples/bld/.idea/libraries/bld.xml
new file mode 100644
index 0000000..153a060
--- /dev/null
+++ b/examples/bld/.idea/libraries/bld.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/bld/.idea/libraries/compile.xml b/examples/bld/.idea/libraries/compile.xml
new file mode 100644
index 0000000..99cc0c0
--- /dev/null
+++ b/examples/bld/.idea/libraries/compile.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/runtime.xml b/examples/bld/.idea/libraries/runtime.xml
new file mode 100644
index 0000000..d4069f2
--- /dev/null
+++ b/examples/bld/.idea/libraries/runtime.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/test.xml b/examples/bld/.idea/libraries/test.xml
new file mode 100644
index 0000000..57ed5ef
--- /dev/null
+++ b/examples/bld/.idea/libraries/test.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/misc.xml b/examples/bld/.idea/misc.xml
new file mode 100644
index 0000000..301a237
--- /dev/null
+++ b/examples/bld/.idea/misc.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/modules.xml b/examples/bld/.idea/modules.xml
new file mode 100644
index 0000000..55adcb9
--- /dev/null
+++ b/examples/bld/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/runConfigurations/Run Tests.xml b/examples/bld/.idea/runConfigurations/Run Tests.xml
new file mode 100644
index 0000000..2b503e5
--- /dev/null
+++ b/examples/bld/.idea/runConfigurations/Run Tests.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/vcs.xml b/examples/bld/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/examples/bld/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.vscode/launch.json b/examples/bld/.vscode/launch.json
new file mode 100644
index 0000000..30a8889
--- /dev/null
+++ b/examples/bld/.vscode/launch.json
@@ -0,0 +1,11 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "java",
+ "name": "Run Tests",
+ "request": "launch",
+ "mainClass": "com.example.ExampleTest"
+ }
+ ]
+}
diff --git a/examples/bld/.vscode/settings.json b/examples/bld/.vscode/settings.json
new file mode 100644
index 0000000..ba429d0
--- /dev/null
+++ b/examples/bld/.vscode/settings.json
@@ -0,0 +1,15 @@
+{
+ "java.project.sourcePaths": [
+ "src/main/java",
+ "src/main/resources",
+ "src/test/java",
+ "src/test/resources",
+ "src/bld/java",
+ "src/bld/resources"
+ ],
+ "java.configuration.updateBuildConfiguration": "automatic",
+ "java.project.referencedLibraries": [
+ "${HOME}/.bld/dist/bld-2.2.1.jar",
+ "lib/**/*.jar"
+ ]
+}
diff --git a/examples/bld/README.md b/examples/bld/README.md
new file mode 100644
index 0000000..7b7a4a6
--- /dev/null
+++ b/examples/bld/README.md
@@ -0,0 +1,18 @@
+## 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
new file mode 100755
index 0000000..80d2986
--- /dev/null
+++ b/examples/bld/bld
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build com.example.ExampleBuild "$@"
\ No newline at end of file
diff --git a/examples/bld/bld.bat b/examples/bld/bld.bat
new file mode 100644
index 0000000..084bb72
--- /dev/null
+++ b/examples/bld/bld.bat
@@ -0,0 +1,4 @@
+@echo off
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build 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
new file mode 100644
index 0000000..ee1bfee
Binary files /dev/null and b/examples/bld/lib/bld/bld-wrapper.jar differ
diff --git a/examples/bld/lib/bld/bld-wrapper.properties b/examples/bld/lib/bld/bld-wrapper.properties
new file mode 100644
index 0000000..1156265
--- /dev/null
+++ b/examples/bld/lib/bld/bld-wrapper.properties
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000..172466e
--- /dev/null
+++ b/examples/bld/src/bld/java/com/example/ExampleBuild.java
@@ -0,0 +1,51 @@
+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
new file mode 100644
index 0000000..ed0d774
--- /dev/null
+++ b/examples/bld/src/main/java/com/example/IsgdSample.java
@@ -0,0 +1,28 @@
+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
new file mode 100644
index 0000000..fe721a0
--- /dev/null
+++ b/examples/bld/src/main/kotlin/com/example/IsgdExample.kt
@@ -0,0 +1,23 @@
+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
deleted file mode 100644
index 8407c23..0000000
--- a/examples/build.gradle.kts
+++ /dev/null
@@ -1,32 +0,0 @@
-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/.gitattributes b/examples/gradle/.gitattributes
similarity index 100%
rename from examples/.gitattributes
rename to examples/gradle/.gitattributes
diff --git a/examples/.gitignore b/examples/gradle/.gitignore
similarity index 100%
rename from examples/.gitignore
rename to examples/gradle/.gitignore
diff --git a/examples/gradle/.idea/.gitignore b/examples/gradle/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/examples/gradle/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/examples/gradle/.idea/.name b/examples/gradle/.idea/.name
new file mode 100644
index 0000000..a595e88
--- /dev/null
+++ b/examples/gradle/.idea/.name
@@ -0,0 +1 @@
+isgd-shorten-examples-gradle
\ No newline at end of file
diff --git a/.idea/compiler.xml b/examples/gradle/.idea/compiler.xml
similarity index 75%
rename from .idea/compiler.xml
rename to examples/gradle/.idea/compiler.xml
index 61a9130..fb7f4a8 100644
--- a/.idea/compiler.xml
+++ b/examples/gradle/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/examples/gradle/.idea/gradle.xml b/examples/gradle/.idea/gradle.xml
new file mode 100644
index 0000000..f2c1963
--- /dev/null
+++ b/examples/gradle/.idea/gradle.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/gradle/.idea/inspectionProfiles/Project_Default.xml b/examples/gradle/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..1e01b48
--- /dev/null
+++ b/examples/gradle/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/examples/gradle/.idea/jarRepositories.xml
similarity index 73%
rename from .idea/jarRepositories.xml
rename to examples/gradle/.idea/jarRepositories.xml
index ac476f9..4e9cedf 100644
--- a/.idea/jarRepositories.xml
+++ b/examples/gradle/.idea/jarRepositories.xml
@@ -11,20 +11,20 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/gradle/.idea/kotlinc.xml b/examples/gradle/.idea/kotlinc.xml
new file mode 100644
index 0000000..6d0ee1c
--- /dev/null
+++ b/examples/gradle/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ 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
new file mode 100644
index 0000000..21fabac
--- /dev/null
+++ b/examples/gradle/.idea/libraries/Gradle__net_thauvin_erik_isgd_shorten_1_0_2_SNAPSHOT.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ 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
new file mode 100644
index 0000000..a546fd2
--- /dev/null
+++ b/examples/gradle/.idea/libraries/Gradle__net_thauvin_erik_urlencoder_urlencoder_lib_jvm_1_5_0.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ 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
new file mode 100644
index 0000000..e179fa0
--- /dev/null
+++ b/examples/gradle/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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
new file mode 100644
index 0000000..05bcccc
--- /dev/null
+++ b/examples/gradle/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_2_0_0.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/gradle/.idea/misc.xml b/examples/gradle/.idea/misc.xml
new file mode 100644
index 0000000..a4d3e28
--- /dev/null
+++ b/examples/gradle/.idea/misc.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+