Merge branch '0.9.2-dev'
This commit is contained in:
commit
d2389088ac
31 changed files with 769 additions and 521 deletions
|
@ -30,19 +30,19 @@ defaults_gradle: &defaults_gradle
|
|||
path: build/reports/
|
||||
|
||||
jobs:
|
||||
build_gradle_jdk14:
|
||||
build_gradle_jdk18:
|
||||
<<: *defaults
|
||||
|
||||
docker:
|
||||
- image: openjdk:14-jdk
|
||||
- image: cimg/openjdk:18.0
|
||||
|
||||
<<: *defaults_gradle
|
||||
|
||||
build_gradle_jdk8:
|
||||
build_gradle_jdk11:
|
||||
<<: *defaults
|
||||
|
||||
docker:
|
||||
- image: circleci/openjdk:8-jdk
|
||||
- image: cimg/openjdk:11.0
|
||||
|
||||
<<: *defaults_gradle
|
||||
|
||||
|
@ -50,5 +50,5 @@ workflows:
|
|||
version: 2
|
||||
gradle:
|
||||
jobs:
|
||||
- build_gradle_jdk8
|
||||
- build_gradle_jdk14
|
||||
- build_gradle_jdk11
|
||||
- build_gradle_jdk18
|
||||
|
|
64
.github/workflows/gradle.yml
vendored
64
.github/workflows/gradle.yml
vendored
|
@ -1,19 +1,61 @@
|
|||
name: Java CI with Gradle
|
||||
name: gradle-ci
|
||||
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-XX:MaxMetaspaceSize=512m"
|
||||
SONAR_JDK: "11"
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
java-version: [ 11, 18 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Test with Gradle
|
||||
run: ./gradlew check
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK ${{ matrix.java-version }}
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java-version }}
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Cache SonarCloud packages
|
||||
if: matrix.java-version == env.SONAR_JDK
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.sonar/cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
restore-keys: ${{ runner.os }}-sonar
|
||||
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ matrix.java-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-${{ matrix.java-version }}-
|
||||
|
||||
- name: Test with Gradle
|
||||
run: ./gradlew build check --stacktrace
|
||||
|
||||
- name: SonarCloud
|
||||
if: success() && matrix.java-version == env.SONAR_JDK
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
run: ./gradlew sonarqube
|
||||
|
||||
- name: Cleanup Gradle Cache
|
||||
run: |
|
||||
rm -f ~/.gradle/caches/modules-2/modules-2.lock
|
||||
rm -f ~/.gradle/caches/modules-2/gc.properties
|
||||
|
|
39
.gitignore
vendored
39
.gitignore
vendored
|
@ -1,22 +1,7 @@
|
|||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
|
||||
__pycache__
|
||||
.classpath
|
||||
.DS_Store
|
||||
.gradle
|
||||
.history
|
||||
.kobalt
|
||||
.mtj.tmp/
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.nb-gradle
|
||||
.project
|
||||
.scannerwork
|
||||
.settings
|
||||
*.class
|
||||
*.code-workspace
|
||||
*.ctxt
|
||||
|
@ -27,7 +12,21 @@ __pycache__
|
|||
*.sublime-*
|
||||
*.tar.gz
|
||||
*.zip
|
||||
/**/.idea_modules/
|
||||
.DS_Store
|
||||
.classpath
|
||||
.gradle
|
||||
.history
|
||||
.kobalt
|
||||
.mtj.tmp/
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.nb-gradle
|
||||
.project
|
||||
.scannerwork
|
||||
.settings
|
||||
.vscode/*
|
||||
/**/.idea/$CACHE_FILE$
|
||||
/**/.idea/$PRODUCT_WORKSPACE_FILE$
|
||||
/**/.idea/**/caches/build_file_checksums.ser
|
||||
/**/.idea/**/contentModel.xml
|
||||
/**/.idea/**/dataSources.ids
|
||||
|
@ -48,8 +47,10 @@ __pycache__
|
|||
/**/.idea/**/uiDesigner.xml
|
||||
/**/.idea/**/usage.statistics.xml
|
||||
/**/.idea/**/workspace.xml
|
||||
/**/.idea/$CACHE_FILE$
|
||||
/**/.idea/$PRODUCT_WORKSPACE_FILE$
|
||||
/**/.idea/sonarlint*
|
||||
/**/.idea_modules/
|
||||
Thumbs.db
|
||||
__pycache__
|
||||
atlassian-ide-plugin.xml
|
||||
bin/
|
||||
build/
|
||||
|
@ -71,6 +72,7 @@ lib/kotlin*
|
|||
libs/
|
||||
local.properties
|
||||
out/
|
||||
pom.xml.asc
|
||||
pom.xml.next
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.tag
|
||||
|
@ -80,5 +82,4 @@ project.properties
|
|||
release.properties
|
||||
target/
|
||||
test-output
|
||||
Thumbs.db
|
||||
venv
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
image: gradle:alpine
|
||||
image: gradle:7-jdk11
|
||||
|
||||
variables:
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
|
@ -12,7 +12,7 @@ stages:
|
|||
|
||||
build:
|
||||
stage: build
|
||||
script: ./gradlew --build-cache assemble
|
||||
script: gradle --build-cache assemble
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_NAME"
|
||||
policy: push
|
||||
|
@ -22,7 +22,7 @@ build:
|
|||
|
||||
test:
|
||||
stage: test
|
||||
script: ./gradlew check
|
||||
script: gradle check
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_NAME"
|
||||
policy: pull
|
||||
|
|
2
.idea/compiler.xml
generated
2
.idea/compiler.xml
generated
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="1.8" />
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
2
.idea/copyright/Erik_s_Copyright_Notice.xml
generated
2
.idea/copyright/Erik_s_Copyright_Notice.xml
generated
|
@ -1,6 +1,6 @@
|
|||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="&#36;file.fileName Copyright (c) &#36;today.year, 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: 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." />
|
||||
<option name="notice" value="&#36;file.fileName Copyright &#36;today.year 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." />
|
||||
<option name="myName" value="Erik's Copyright Notice" />
|
||||
</copyright>
|
||||
</component>
|
2
.idea/isgd-shorten.iml
generated
2
.idea/isgd-shorten.iml
generated
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
15
.idea/jarRepositories.xml
generated
15
.idea/jarRepositories.xml
generated
|
@ -26,5 +26,20 @@
|
|||
<option name="name" value="MavenLocal" />
|
||||
<option name="url" value="file:$MAVEN_REPOSITORY$/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://packages.jetbrains.team/maven/p/ij/intellij-dependencies" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
6
.idea/kotlinc.xml
generated
Normal file
6
.idea/kotlinc.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.8.0" />
|
||||
</component>
|
||||
</project>
|
5
.idea/misc.xml
generated
5
.idea/misc.xml
generated
|
@ -4,7 +4,10 @@
|
|||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="PDMPlugin">
|
||||
<option name="skipTestSources" value="false" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="18" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
26
.travis.yml
26
.travis.yml
|
@ -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
|
|
@ -1,5 +1,4 @@
|
|||
Copyright (c) 2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
All rights reserved.
|
||||
Copyright 2020-2023 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:
|
||||
|
|
41
README.md
41
README.md
|
@ -1,10 +1,16 @@
|
|||
[](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://opensource.org/licenses/BSD-3-Clause)
|
||||
[](https://kotlinlang.org/)
|
||||
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/isgd-shorten/)
|
||||
[](https://github.com/ethauvin/isgd-shorten/releases/latest)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten)
|
||||
|
||||
[](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://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten)
|
||||
[](https://github.com/ethauvin/isgd-shorten/actions/workflows/gradle.yml)
|
||||
[](https://circleci.com/gh/ethauvin/isgd-shorten/tree/master)
|
||||
|
||||
# [is.gd](https://is.gd/developers.php) Shortener for Kotlin/Java/Android
|
||||
# [is.gd](https://is.gd/developers.php) Shortener for Kotlin, Java & Android
|
||||
|
||||
A simple implementation of the [is.gd API](https://is.gd/developers.php).
|
||||
A simple implementation of the [is.gd](https://is.gd/) URL shortening and lookup [APIs](https://is.gd/developers.php).
|
||||
|
||||
## Examples (TL;DR)
|
||||
|
||||
|
@ -44,7 +50,7 @@ Isgd.shorten(url = url, shorturl="foobar", callback = "test", logstats = true, f
|
|||
```
|
||||
returns:
|
||||
|
||||
```json
|
||||
```js
|
||||
test({ "shorturl": "https://is.gd/foobar" });
|
||||
```
|
||||
### Gradle
|
||||
|
@ -53,14 +59,33 @@ To use with [Gradle](https://gradle.org/), include the following dependency in y
|
|||
|
||||
```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:0.9.2")
|
||||
}
|
||||
```
|
||||
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/artifact/net.thauvin.erik/isgd-shorten/0.9.1/jar).
|
||||
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten).
|
||||
|
||||
### 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})
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
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
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
image: openjdk:8
|
||||
image: maven:3-openjdk-18
|
||||
|
||||
pipelines:
|
||||
default:
|
||||
|
|
221
build.gradle.kts
221
build.gradle.kts
|
@ -1,24 +1,24 @@
|
|||
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import java.io.FileInputStream
|
||||
import java.util.*
|
||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
|
||||
plugins {
|
||||
jacoco
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("com.github.ben-manes.versions") version "0.29.0"
|
||||
id("com.jfrog.bintray") version "1.8.5"
|
||||
id("io.gitlab.arturbosch.detekt") version "1.11.0"
|
||||
id("com.github.ben-manes.versions") version "0.44.0"
|
||||
id("io.gitlab.arturbosch.detekt") version "1.22.0"
|
||||
id("java")
|
||||
id("java-library")
|
||||
id("maven-publish")
|
||||
id("net.thauvin.erik.gradle.semver") version "1.0.4"
|
||||
id("org.jetbrains.dokka") version "1.4.0-rc"
|
||||
id("org.jetbrains.kotlin.jvm") version "1.4.0"
|
||||
id("org.jetbrains.kotlin.kapt") version "1.4.0"
|
||||
id("org.sonarqube") version "3.0"
|
||||
id("org.jetbrains.dokka") version "1.7.20"
|
||||
id("org.jetbrains.kotlinx.kover") version "0.6.1"
|
||||
id("org.sonarqube") version "3.5.0.2730"
|
||||
id("signing")
|
||||
kotlin("jvm") version "1.8.0"
|
||||
kotlin("kapt") version "1.8.0"
|
||||
}
|
||||
|
||||
group = "net.thauvin.erik"
|
||||
description = "is.gd Shortener for Kotlin/Java"
|
||||
description = "A simple implementation of the is.gd URL shortening and lookup APIs"
|
||||
|
||||
val gitHub = "ethauvin/$name"
|
||||
val mavenUrl = "https://github.com/$gitHub"
|
||||
|
@ -27,62 +27,41 @@ 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()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
||||
}
|
||||
implementation(platform(kotlin("bom")))
|
||||
implementation("net.thauvin.erik:urlencoder:1.3.0")
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
arg("semver.project.dir", projectDir)
|
||||
}
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation(kotlin("test-junit"))
|
||||
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.25")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
detekt {
|
||||
//toolVersion = "main-SNAPSHOT"
|
||||
baseline = project.rootDir.resolve("config/detekt/baseline.xml")
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "0.8.5"
|
||||
}
|
||||
|
||||
sonarqube {
|
||||
properties {
|
||||
property("sonar.projectKey", "ethauvin_$name")
|
||||
property("sonar.organization", "ethauvin-github")
|
||||
property("sonar.host.url", "https://sonarcloud.io")
|
||||
property("sonar.sourceEncoding", "UTF-8")
|
||||
property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/xml/report.xml")
|
||||
}
|
||||
}
|
||||
|
||||
val sourcesJar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
from(sourceSets.getByName("main").allSource)
|
||||
}
|
||||
|
||||
val javadocJar by tasks.creating(Jar::class) {
|
||||
dependsOn(tasks.dokkaJavadoc)
|
||||
from(tasks.dokkaJavadoc)
|
||||
|
@ -92,15 +71,15 @@ val javadocJar by tasks.creating(Jar::class) {
|
|||
}
|
||||
|
||||
tasks {
|
||||
withType<JacocoReport> {
|
||||
reports {
|
||||
xml.isEnabled = true
|
||||
html.isEnabled = true
|
||||
}
|
||||
withType<KotlinCompile>().configureEach {
|
||||
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
|
||||
}
|
||||
|
||||
withType<KotlinCompile>().configureEach {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
withType<Test> {
|
||||
testLogging {
|
||||
exceptionFormat = TestExceptionFormat.FULL
|
||||
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||
}
|
||||
}
|
||||
|
||||
withType<GenerateMavenPom> {
|
||||
|
@ -108,7 +87,7 @@ tasks {
|
|||
}
|
||||
|
||||
assemble {
|
||||
dependsOn(sourcesJar, javadocJar)
|
||||
dependsOn(javadocJar)
|
||||
}
|
||||
|
||||
clean {
|
||||
|
@ -140,75 +119,23 @@ tasks {
|
|||
}
|
||||
}
|
||||
|
||||
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")
|
||||
dependsOn(clean, wrapper, build, jar)
|
||||
outputs.dir(deployDir)
|
||||
inputs.files(copyToDeploy)
|
||||
mustRunAfter("clean")
|
||||
mustRunAfter(clean)
|
||||
}
|
||||
|
||||
register("release") {
|
||||
description = "Publishes version ${project.version} to Bintray."
|
||||
description = "Publishes version ${project.version} to local repository."
|
||||
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||
dependsOn("wrapper", bintrayUpload)
|
||||
dependsOn(wrapper, "deploy", gitTag, publishToMavenLocal)
|
||||
}
|
||||
|
||||
"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(
|
||||
"android",
|
||||
"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
|
||||
}
|
||||
}
|
||||
dependsOn(koverReport)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,37 +143,51 @@ publishing {
|
|||
publications {
|
||||
create<MavenPublication>(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")
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
url.set(mavenUrl)
|
||||
licenses {
|
||||
license {
|
||||
name.set("BSD 3-Clause")
|
||||
url.set("https://opensource.org/licenses/BSD-3-Clause")
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id.set("ethauvin")
|
||||
name.set("Erik C. Thauvin")
|
||||
email.set("erik@thauvin.net")
|
||||
url.set("https://erik.thauvin.net/")
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection.set("scm:git://github.com/$gitHub.git")
|
||||
developerConnection.set("scm:git@github.com:$gitHub.git")
|
||||
url.set(mavenUrl)
|
||||
}
|
||||
issueManagement {
|
||||
system.set("GitHub")
|
||||
url.set("$mavenUrl/issues")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "ossrh"
|
||||
project.afterEvaluate {
|
||||
url = if (project.version.toString().contains("SNAPSHOT"))
|
||||
uri("https://oss.sonatype.org/content/repositories/snapshots/") else
|
||||
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||
}
|
||||
credentials(PasswordCredentials::class)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign(publishing.publications[publicationName])
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?xml version="1.0" ?>
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<SmellBaseline>
|
||||
<Blacklist></Blacklist>
|
||||
<Whitelist>
|
||||
<ManuallySuppressedIssues/>
|
||||
<CurrentIssues>
|
||||
<ID>LongParameterList:Isgd.kt$Isgd.Companion$( url: String, shorturl: String = "", callback: String = "", logstats: Boolean = false, format: Format = Format.SIMPLE, isVgd: Boolean = false )</ID>
|
||||
</Whitelist>
|
||||
<ID>MagicNumber:Isgd.kt$Isgd.Companion$200</ID>
|
||||
<ID>MagicNumber:Isgd.kt$Isgd.Companion$399</ID>
|
||||
</CurrentIssues>
|
||||
</SmellBaseline>
|
||||
|
|
|
@ -1,29 +1,41 @@
|
|||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.jvm") version "1.4.0"
|
||||
id("com.github.ben-manes.versions") version "0.29.0"
|
||||
application
|
||||
id("application")
|
||||
id("com.github.ben-manes.versions") version "0.44.0"
|
||||
kotlin("jvm") version "1.8.0"
|
||||
}
|
||||
|
||||
// ./gradlew run --args='https://wwwcom.example. https://is.gd/Pt2sET'
|
||||
// ./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
|
||||
// ./gradlew runJava --args='https://www.example.com https://is.gd/Pt2sET'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
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:0.9.2-SNAPSHOT")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = "com.example.IsgdExampleKt"
|
||||
mainClass.set("com.example.IsgdExampleKt")
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<KotlinCompile>().configureEach {
|
||||
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
|
||||
}
|
||||
|
||||
register("runJava", JavaExec::class) {
|
||||
group = "application"
|
||||
main = "com.example.IsgdSample"
|
||||
classpath = sourceSets["main"].runtimeClasspath
|
||||
mainClass.set("com.example.IsgdSample")
|
||||
classpath = sourceSets.main.get().runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
|
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
269
examples/gradlew
vendored
Normal file → Executable file
269
examples/gradlew
vendored
Normal file → Executable file
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# 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.
|
||||
|
@ -17,67 +17,101 @@
|
|||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# 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/master/subprojects/plugins/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
|
||||
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
|
||||
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
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
APP_BASE_NAME=${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"
|
||||
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
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||
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"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
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
|
||||
|
@ -106,80 +140,95 @@ 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" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
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, 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.
|
||||
|
||||
# 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"
|
||||
# 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
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# 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" "$@"
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package com.example;
|
||||
|
||||
import net.thauvin.erik.isgd.Isgd;
|
||||
import net.thauvin.erik.isgd.IsgdException;
|
||||
|
||||
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));
|
||||
try {
|
||||
if (arg.contains("is.gd")) {
|
||||
System.out.println(arg + " <-- " + Isgd.lookup(arg));
|
||||
} else {
|
||||
System.out.println(arg + " --> " + Isgd.shorten(arg));
|
||||
}
|
||||
} catch (IsgdException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package com.example
|
||||
|
||||
import net.thauvin.erik.isgd.Isgd
|
||||
import net.thauvin.erik.isgd.IsgdException
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (args.isNotEmpty()) {
|
||||
args.forEach {
|
||||
if (it.contains("is.gd"))
|
||||
println(it + " <-- " + Isgd.lookup(it))
|
||||
else
|
||||
println(it + " --> " + Isgd.shorten(it))
|
||||
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.")
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
269
gradlew
vendored
269
gradlew
vendored
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# 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.
|
||||
|
@ -17,67 +17,101 @@
|
|||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# 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/master/subprojects/plugins/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
|
||||
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
|
||||
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
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
APP_BASE_NAME=${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"
|
||||
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
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||
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"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
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
|
||||
|
@ -106,80 +140,95 @@ 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" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
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, 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.
|
||||
|
||||
# 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"
|
||||
# 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
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# 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" "$@"
|
||||
|
|
55
pom.xml
55
pom.xml
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<!-- This module was also published with a richer model, Gradle metadata, -->
|
||||
<!-- which should be used instead. Do not delete the following line which -->
|
||||
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
|
||||
|
@ -8,28 +8,9 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.thauvin.erik</groupId>
|
||||
<artifactId>isgd-shorten</artifactId>
|
||||
<version>0.9.1</version>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-bom</artifactId>
|
||||
<version>1.3.72</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>1.3.72</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<version>0.9.2-SNAPSHOT</version>
|
||||
<name>isgd-shorten</name>
|
||||
<description>is.gd Shortener for Kotlin/Java</description>
|
||||
<description>A simple implementation of the is.gd URL shortening and lookup APIs</description>
|
||||
<url>https://github.com/ethauvin/isgd-shorten</url>
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -42,15 +23,41 @@
|
|||
<id>ethauvin</id>
|
||||
<name>Erik C. Thauvin</name>
|
||||
<email>erik@thauvin.net</email>
|
||||
<url>https://erik.thauvin.net/</url>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:https://github.com/ethauvin/isgd-shorten.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:ethauvin/isgd-shorten.git</developerConnection>
|
||||
<connection>scm:git://github.com/ethauvin/isgd-shorten.git</connection>
|
||||
<developerConnection>scm:git@github.com:ethauvin/isgd-shorten.git</developerConnection>
|
||||
<url>https://github.com/ethauvin/isgd-shorten</url>
|
||||
</scm>
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/ethauvin/isgd-shorten/issues</url>
|
||||
</issueManagement>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-bom</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.thauvin.erik</groupId>
|
||||
<artifactId>urlencoder</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1 +1,18 @@
|
|||
plugins {
|
||||
id("com.gradle.enterprise").version("3.6.3")
|
||||
}
|
||||
|
||||
gradleEnterprise {
|
||||
buildScan {
|
||||
link("GitHub", "https://github.com/ethauvin/isgd-shorten/tree/master")
|
||||
if (!System.getenv("CI").isNullOrEmpty()) {
|
||||
isUploadInBackground = false
|
||||
publishOnFailure()
|
||||
tag("CI")
|
||||
}
|
||||
termsOfServiceUrl = "https://gradle.com/terms-of-service"
|
||||
termsOfServiceAgree = "yes"
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "isgd-shorten"
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
/*
|
||||
* Isgd.kt
|
||||
*
|
||||
* Copyright (c) 2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
* Copyright 2023 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:
|
||||
|
@ -32,34 +31,38 @@
|
|||
|
||||
package net.thauvin.erik.isgd
|
||||
|
||||
import net.thauvin.erik.urlencoder.UrlEncoder
|
||||
import java.net.HttpURLConnection
|
||||
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 {
|
||||
return URLEncoder.encode(this, StandardCharsets.UTF_8.name())
|
||||
}
|
||||
fun String.encode(): String = UrlEncoder.encode(this)
|
||||
|
||||
/**
|
||||
* Implements the [is.gd API](https://is.gd/developers.php).
|
||||
*/
|
||||
class Isgd private constructor() {
|
||||
companion object {
|
||||
private fun callApi(url: String): String {
|
||||
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"
|
||||
"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0"
|
||||
)
|
||||
return connection.inputStream.bufferedReader().readText()
|
||||
if (connection.responseCode in 200..399) {
|
||||
return connection.inputStream.bufferedReader().readText()
|
||||
} else {
|
||||
throw IsgdException(connection.responseCode, connection.errorStream.bufferedReader().readText())
|
||||
}
|
||||
}
|
||||
|
||||
private fun host(isVgd: Boolean = false): String {
|
||||
private fun getHost(isVgd: Boolean = false): String {
|
||||
return if (isVgd) "v.gd" else "is.gd"
|
||||
}
|
||||
|
||||
|
@ -68,17 +71,16 @@ class Isgd private constructor() {
|
|||
*/
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
@Throws(IsgdException::class)
|
||||
fun lookup(
|
||||
shorturl: String,
|
||||
callback: String = "",
|
||||
format: Format = Format.SIMPLE,
|
||||
isVgd: Boolean = false
|
||||
): String {
|
||||
if (shorturl.isEmpty()) {
|
||||
throw IllegalArgumentException("Please specify a valid short URL to lookup.")
|
||||
}
|
||||
require(shorturl.isNotEmpty()) { "Please specify a valid short URL to lookup." }
|
||||
|
||||
val sb = StringBuilder("https://${host(isVgd)}/forward.php?shorturl=${shorturl.encode()}")
|
||||
val sb = StringBuilder("https://${getHost(isVgd)}/forward.php?shorturl=${shorturl.encode()}")
|
||||
|
||||
if (callback.isNotEmpty()) {
|
||||
sb.append("&callback=${callback.encode()}")
|
||||
|
@ -94,6 +96,7 @@ class Isgd private constructor() {
|
|||
*/
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
@Throws(IsgdException::class)
|
||||
fun shorten(
|
||||
url: String,
|
||||
shorturl: String = "",
|
||||
|
@ -102,11 +105,9 @@ class Isgd private constructor() {
|
|||
format: Format = Format.SIMPLE,
|
||||
isVgd: Boolean = false
|
||||
): String {
|
||||
if (url.isEmpty()) {
|
||||
throw IllegalArgumentException("Please enter a valid URL to shorten.")
|
||||
}
|
||||
require(url.isNotEmpty()) { "Please enter a valid URL to shorten." }
|
||||
|
||||
val sb = StringBuilder("https://${host(isVgd)}/create.php?url=${url.encode()}")
|
||||
val sb = StringBuilder("https://${getHost(isVgd)}/create.php?url=${url.encode()}")
|
||||
|
||||
if (shorturl.isNotEmpty()) {
|
||||
sb.append("&shorturl=${shorturl.encode()}")
|
||||
|
|
44
src/main/kotlin/net/thauvin/erik/isgd/IsgdException.kt
Normal file
44
src/main/kotlin/net/thauvin/erik/isgd/IsgdException.kt
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* IsgdException.kt
|
||||
*
|
||||
* Copyright 2023 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
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
/*
|
||||
* IsgdTest.kt
|
||||
*
|
||||
* Copyright (c) 2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
* Copyright 2023 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:
|
||||
|
@ -32,19 +31,54 @@
|
|||
|
||||
package net.thauvin.erik.isgd
|
||||
|
||||
import assertk.all
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.contains
|
||||
import assertk.assertions.isEqualTo
|
||||
import assertk.assertions.isNotNull
|
||||
import assertk.assertions.matches
|
||||
import assertk.assertions.prop
|
||||
import assertk.assertions.startsWith
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
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 testLookup() {
|
||||
assertFailsWith(
|
||||
message = "lookup(empty)",
|
||||
exceptionClass = IllegalArgumentException::class,
|
||||
block = { Isgd.lookup("") }
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLookupDefault() {
|
||||
assertEquals(url, Isgd.lookup(shortUrl))
|
||||
assertEquals(url, Isgd.lookup(shortVgdUrl, isVgd = true), "v.gd")
|
||||
assertEquals(url, Isgd.lookup(shortVgdUrl, isVgd = true), "lookup(isVgd)")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,7 +87,7 @@ class IsgdTest {
|
|||
assertEquals(
|
||||
"test({ \"url\": \"$url\" });",
|
||||
Isgd.lookup(shortUrl, callback = "test", format = Format.JSON),
|
||||
"with callback"
|
||||
"lookup(callback)"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -65,10 +99,28 @@ class IsgdTest {
|
|||
)
|
||||
}
|
||||
|
||||
@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 testShortenDefault() {
|
||||
assertEquals(shortUrl, Isgd.shorten(url))
|
||||
assertEquals(shortVgdUrl, Isgd.shorten(url, isVgd = true), "v.gd")
|
||||
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
|
||||
|
@ -77,20 +129,21 @@ class IsgdTest {
|
|||
assertEquals(
|
||||
"test({ \"shorturl\": \"$shortUrl\" });",
|
||||
Isgd.shorten(url, callback = "test", format = Format.JSON),
|
||||
"with callback"
|
||||
"shorten(callback,json)"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShortenXml() {
|
||||
assertEquals(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><output><shorturl>$shortUrl</shorturl></output>",
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
|
||||
"<output><shorturl>$shortUrl</shorturl></output>",
|
||||
Isgd.shorten(url, format = Format.XML)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShortenWeb() {
|
||||
assertTrue(Isgd.shorten(url, format = Format.WEB).contains(shortUrl))
|
||||
assertThat(Isgd.shorten(url, format = Format.WEB)).contains(shortUrl)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#Generated by the Semver Plugin for Gradle
|
||||
#Sat Mar 21 16:36:23 PDT 2020
|
||||
#Sun May 02 21:57:08 PDT 2021
|
||||
version.buildmeta=
|
||||
version.major=0
|
||||
version.minor=9
|
||||
version.patch=1
|
||||
version.prerelease=
|
||||
version.semver=0.9.1
|
||||
version.patch=2
|
||||
version.prerelease=SNAPSHOT
|
||||
version.semver=0.9.2-SNAPSHOT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue