Compare commits
No commits in common. "master" and "1.0.0" have entirely different histories.
100 changed files with 1062 additions and 1565 deletions
|
@ -1,62 +1,54 @@
|
||||||
version: 2.1
|
version: 2
|
||||||
|
|
||||||
orbs:
|
|
||||||
sdkman: joshdholtz/sdkman@0.2.0
|
|
||||||
|
|
||||||
defaults: &defaults
|
defaults: &defaults
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
environment:
|
environment:
|
||||||
JVM_OPTS: -Xmx3200m
|
JVM_OPTS: -Xmx3200m
|
||||||
TERM: dumb
|
TERM: dumb
|
||||||
CI_NAME: "CircleCI"
|
CI: true
|
||||||
|
|
||||||
commands:
|
defaults_gradle: &defaults_gradle
|
||||||
build_and_test:
|
steps:
|
||||||
parameters:
|
- checkout
|
||||||
reports-dir:
|
- restore_cache:
|
||||||
type: string
|
keys:
|
||||||
default: "build/reports/test_results"
|
- gradle-dependencies-{{ checksum "build.gradle.kts" }}
|
||||||
steps:
|
# fallback to using the latest cache if no exact match is found
|
||||||
- checkout
|
- gradle-dependencies-
|
||||||
- sdkman/setup-sdkman
|
- run:
|
||||||
- sdkman/sdkman-install:
|
name: Gradle Dependencies
|
||||||
candidate: kotlin
|
command: ./gradlew dependencies
|
||||||
version: 2.1.10
|
- save_cache:
|
||||||
- run:
|
paths: ~/.m2
|
||||||
name: Download dependencies
|
key: gradle-dependencies-{{ checksum "build.gradle.kts" }}
|
||||||
command: ./bld download
|
- run:
|
||||||
- run:
|
name: Run All Checks
|
||||||
name: Compile source
|
command: ./gradlew check
|
||||||
command: ./bld compile
|
- store_artifacts:
|
||||||
- run:
|
path: build/reports/
|
||||||
name: Run tests
|
destination: reports
|
||||||
command: ./bld jacoco -reports-dir=<< parameters.reports-dir >>
|
- store_test_results:
|
||||||
- store_test_results:
|
path: build/reports/
|
||||||
path: << parameters.reports-dir >>
|
|
||||||
- store_artifacts:
|
|
||||||
path: build/reports/jacoco/test/html
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
bld_jdk17:
|
build_gradle_jdk18:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/openjdk:17.0
|
- image: cimg/openjdk:18.0
|
||||||
|
|
||||||
steps:
|
<<: *defaults_gradle
|
||||||
- build_and_test
|
|
||||||
|
|
||||||
bld_jdk21:
|
build_gradle_jdk11:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/openjdk:21.0
|
- image: cimg/openjdk:11.0
|
||||||
|
|
||||||
steps:
|
<<: *defaults_gradle
|
||||||
- build_and_test
|
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
bld:
|
version: 2
|
||||||
jobs:
|
gradle:
|
||||||
- bld_jdk17
|
jobs:
|
||||||
- bld_jdk21
|
- build_gradle_jdk11
|
||||||
|
- build_gradle_jdk18
|
||||||
|
|
68
.github/workflows/bld.yml
vendored
68
.github/workflows/bld.yml
vendored
|
@ -1,68 +0,0 @@
|
||||||
name: bld-ci
|
|
||||||
|
|
||||||
on: [push, pull_request, workflow_dispatch]
|
|
||||||
|
|
||||||
env:
|
|
||||||
COVERAGE_JDK: "21"
|
|
||||||
COVERAGE_KOTLIN: "2.0.21"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-bld-project:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
java-version: [17, 21, 24]
|
|
||||||
kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ]
|
|
||||||
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout source repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up JDK ${{ matrix.java-version }} with Kotlin ${{ matrix.kotlin-version }}
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: "zulu"
|
|
||||||
java-version: ${{ matrix.java-version }}
|
|
||||||
|
|
||||||
- name: Download dependencies [bld example]
|
|
||||||
working-directory: examples/bld
|
|
||||||
run: ./bld download
|
|
||||||
|
|
||||||
- name: Compile and run examples [bld example]
|
|
||||||
working-directory: examples/bld
|
|
||||||
run: |
|
|
||||||
./bld compile
|
|
||||||
./bld run --args='https://www.example.com https://is.gd/Pt2sET'
|
|
||||||
./bld run-java --args='https://www.example.com https://is.gd/Pt2sET'
|
|
||||||
|
|
||||||
- name: Run examples [gradle example]
|
|
||||||
working-directory: examples/gradle
|
|
||||||
run: |
|
|
||||||
./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
|
|
||||||
./gradlew runJava --args='https://www.example.com https://is.gd/Pt2sET'
|
|
||||||
|
|
||||||
- name: Download dependencies
|
|
||||||
run: ./bld download
|
|
||||||
|
|
||||||
- name: Compile source
|
|
||||||
run: ./bld compile
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: ./bld jacoco
|
|
||||||
|
|
||||||
- name: Remove pom.xml
|
|
||||||
if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN
|
|
||||||
&& matrix.os == 'ubuntu-latest'
|
|
||||||
run: rm -rf pom.xml
|
|
||||||
|
|
||||||
- name: SonarCloud Scan
|
|
||||||
uses: sonarsource/sonarcloud-github-action@master
|
|
||||||
if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN
|
|
||||||
&& matrix.os == 'ubuntu-latest'
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
49
.github/workflows/gradle.yml
vendored
Normal file
49
.github/workflows/gradle.yml
vendored
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
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: "17"
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
java-version: [ 11, 17, 20 ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up JDK ${{ matrix.java-version }}
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'zulu'
|
||||||
|
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@v3
|
||||||
|
with:
|
||||||
|
path: ~/.sonar/cache
|
||||||
|
key: ${{ runner.os }}-sonar
|
||||||
|
restore-keys: ${{ runner.os }}-sonar
|
||||||
|
|
||||||
|
- name: Test with Gradle
|
||||||
|
uses: gradle/gradle-build-action@v2
|
||||||
|
with:
|
||||||
|
arguments: build check --stacktrace --scan
|
||||||
|
|
||||||
|
- name: SonarCloud
|
||||||
|
if: success() && matrix.java-version == env.SONAR_JDK
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
run: ./gradlew sonar --info
|
139
.gitignore
vendored
139
.gitignore
vendored
|
@ -1,61 +1,84 @@
|
||||||
.gradle
|
!.vscode/extensions.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
*.class
|
||||||
|
*.code-workspace
|
||||||
|
*.ctxt
|
||||||
|
*.iws
|
||||||
|
*.log
|
||||||
|
*.nar
|
||||||
|
*.rar
|
||||||
|
*.sublime-*
|
||||||
|
*.tar.gz
|
||||||
|
*.zip
|
||||||
.DS_Store
|
.DS_Store
|
||||||
build
|
.classpath
|
||||||
lib/bld/**
|
.gradle
|
||||||
!lib/bld/bld-wrapper.jar
|
.history
|
||||||
!lib/bld/bld-wrapper.properties
|
.kobalt
|
||||||
lib/compile/
|
.mtj.tmp/
|
||||||
lib/runtime/
|
.mvn/timing.properties
|
||||||
lib/standalone/
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
lib/test/
|
.nb-gradle
|
||||||
|
.project
|
||||||
# IDEA ignores
|
.scannerwork
|
||||||
|
.settings
|
||||||
# User-specific
|
.vscode/*
|
||||||
.idea/**/workspace.xml
|
/**/.idea/$CACHE_FILE$
|
||||||
.idea/**/tasks.xml
|
/**/.idea/$PRODUCT_WORKSPACE_FILE$
|
||||||
.idea/**/usage.statistics.xml
|
/**/.idea/**/caches/build_file_checksums.ser
|
||||||
.idea/**/dictionaries
|
/**/.idea/**/contentModel.xml
|
||||||
.idea/**/shelf
|
/**/.idea/**/dataSources.ids
|
||||||
|
/**/.idea/**/dataSources.local.xml
|
||||||
# AWS User-specific
|
/**/.idea/**/dataSources/
|
||||||
.idea/**/aws.xml
|
/**/.idea/**/dbnavigator.xml
|
||||||
|
/**/.idea/**/dictionaries
|
||||||
# Generated files
|
/**/.idea/**/dynamic.xml
|
||||||
.idea/**/contentModel.xml
|
/**/.idea/**/gradle.xml
|
||||||
|
/**/.idea/**/httpRequests
|
||||||
# Sensitive or high-churn files
|
/**/.idea/**/libraries
|
||||||
.idea/**/dataSources/
|
/**/.idea/**/mongoSettings.xml
|
||||||
.idea/**/dataSources.ids
|
/**/.idea/**/replstate.xml
|
||||||
.idea/**/dataSources.local.xml
|
/**/.idea/**/shelf
|
||||||
.idea/**/sqlDataSources.xml
|
/**/.idea/**/shelf/
|
||||||
.idea/**/dynamic.xml
|
/**/.idea/**/sqlDataSources.xml
|
||||||
.idea/**/uiDesigner.xml
|
/**/.idea/**/tasks.xml
|
||||||
.idea/**/dbnavigator.xml
|
/**/.idea/**/uiDesigner.xml
|
||||||
|
/**/.idea/**/usage.statistics.xml
|
||||||
# Gradle
|
/**/.idea/**/workspace.xml
|
||||||
.idea/**/gradle.xml
|
/**/.idea/sonarlint*
|
||||||
|
/**/.idea_modules/
|
||||||
# Mongo Explorer plugin
|
Thumbs.db
|
||||||
.idea/**/mongoSettings.xml
|
__pycache__
|
||||||
|
|
||||||
# mpeltonen/sbt-idea plugin
|
|
||||||
.idea_modules/
|
|
||||||
|
|
||||||
# JIRA plugin
|
|
||||||
atlassian-ide-plugin.xml
|
atlassian-ide-plugin.xml
|
||||||
|
bin/
|
||||||
# Cursive Clojure plugin
|
build/
|
||||||
.idea/replstate.xml
|
cmake-build-*/
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
# SonarLint plugin
|
crashlytics-build.properties
|
||||||
.idea/sonarlint/
|
crashlytics.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
# Editor-based Rest Client
|
deploy/
|
||||||
.idea/httpRequests
|
dist/
|
||||||
|
ehthumbs.db
|
||||||
bin
|
fabric.properties
|
||||||
deploy
|
gen/
|
||||||
target
|
hs_err_pid*
|
||||||
|
kobaltBuild
|
||||||
|
kobaltw*-test
|
||||||
|
lib/kotlin*
|
||||||
|
libs/
|
||||||
local.properties
|
local.properties
|
||||||
|
out/
|
||||||
|
pom.xml.asc
|
||||||
|
pom.xml.next
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
proguard-project.txt
|
||||||
|
project.properties
|
||||||
|
release.properties
|
||||||
|
target/
|
||||||
|
test-output
|
||||||
|
venv
|
||||||
|
|
|
@ -1,24 +1,31 @@
|
||||||
image: fedora:latest
|
image: gradle:8-jdk11
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
CI_NAME: "GitLab CI"
|
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||||
|
|
||||||
stages:
|
|
||||||
- test
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- dnf -qy update && dnf -y install zip
|
- export GRADLE_USER_HOME=`pwd`/.gradle
|
||||||
- curl -s "https://get.sdkman.io" | bash
|
|
||||||
- echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config
|
stages:
|
||||||
- echo sdkman_auto_selfupdate=true >> $HOME/.sdkman/etc/config
|
- build
|
||||||
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
- test
|
||||||
- sdk install java
|
|
||||||
- sdk install kotlin
|
build:
|
||||||
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
stage: build
|
||||||
|
script: gradle --build-cache assemble
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_NAME"
|
||||||
|
policy: push
|
||||||
|
paths:
|
||||||
|
- build
|
||||||
|
- .gradle
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script: gradle check
|
||||||
- ./bld download
|
cache:
|
||||||
- ./bld compile
|
key: "$CI_COMMIT_REF_NAME"
|
||||||
- ./bld test
|
policy: pull
|
||||||
|
paths:
|
||||||
|
- build
|
||||||
|
- .gradle
|
||||||
|
|
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
30
.idea/app.iml
generated
30
.idea/app.iml
generated
|
@ -1,30 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<output url="file://$MODULE_DIR$/build/main" />
|
|
||||||
<output-test url="file://$MODULE_DIR$/build/test" />
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" relativeOutputPath="resources" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="module-library" scope="RUNTIME">
|
|
||||||
<library>
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$MODULE_DIR$/src/main/resources/templates" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</orderEntry>
|
|
||||||
<orderEntry type="library" name="compile" level="project" />
|
|
||||||
<orderEntry type="library" scope="RUNTIME" name="runtime" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="test" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
14
.idea/bld.iml
generated
14
.idea/bld.iml
generated
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<output url="file://$MODULE_DIR$/build/bld" />
|
|
||||||
<output-test url="file://$MODULE_DIR$/build/bld" />
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$/src/bld">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/bld/java" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="library" name="bld" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
6
.idea/bld.xml
generated
6
.idea/bld.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="BldConfiguration">
|
|
||||||
<events />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
6
.idea/copyright/BSD_3.xml
generated
6
.idea/copyright/BSD_3.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<component name="CopyrightManager">
|
|
||||||
<copyright>
|
|
||||||
<option name="notice" value="&#36;file.fileName Copyright 2020-&#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="BSD-3" />
|
|
||||||
</copyright>
|
|
||||||
</component>
|
|
6
.idea/copyright/Erik_s_Copyright_Notice.xml
generated
Normal file
6
.idea/copyright/Erik_s_Copyright_Notice.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="CopyrightManager">
|
||||||
|
<copyright>
|
||||||
|
<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/copyright/profiles_settings.xml
generated
2
.idea/copyright/profiles_settings.xml
generated
|
@ -1,3 +1,3 @@
|
||||||
<component name="CopyrightManager">
|
<component name="CopyrightManager">
|
||||||
<settings default="BSD-3" />
|
<settings default="Erik's Copyright Notice" />
|
||||||
</component>
|
</component>
|
47
.idea/inspectionProfiles/Project_Default.xml
generated
47
.idea/inspectionProfiles/Project_Default.xml
generated
|
@ -1,9 +1,50 @@
|
||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="AndroidLintNewerVersionAvailable" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<option name="ADDITIONAL_TAGS" value="created" />
|
<inspection_tool class="GroovyVariableCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="INNER_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="METHOD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="FIELD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="IGNORE_DEPRECATED" value="false" />
|
||||||
|
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
|
||||||
|
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
|
||||||
|
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||||
|
<option name="myAdditionalJavadocTags" value="created" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
<inspection_tool class="UsePropertyAccessSyntax" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
<inspection_tool class="LiteralAsArgToStringEquals" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="LocalCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="REPORT_VARIABLES" value="true" />
|
||||||
|
<option name="REPORT_PARAMETERS" value="true" />
|
||||||
|
<option name="REPORT_CATCH_PARAMETERS" value="false" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="NonFinalUtilityClass" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="SerializableHasSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoreAnonymousInnerClasses" value="false" />
|
||||||
|
<option name="superClassString" value="java.awt.Component" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="UnnecessarySemicolon" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
|
@ -11,6 +11,16 @@
|
||||||
<option name="name" value="JBoss Community repository" />
|
<option name="name" value="JBoss Community repository" />
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenLocal" />
|
||||||
|
<option name="name" value="MavenLocal" />
|
||||||
|
<option name="url" value="file:/$MAVEN_REPOSITORY$/" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="MavenLocal" />
|
<option name="id" value="MavenLocal" />
|
||||||
<option name="name" value="MavenLocal" />
|
<option name="name" value="MavenLocal" />
|
||||||
|
@ -26,5 +36,10 @@
|
||||||
<option name="name" value="maven" />
|
<option name="name" value="maven" />
|
||||||
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
|
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
|
||||||
</remote-repository>
|
</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>
|
</component>
|
||||||
</project>
|
</project>
|
11
.idea/kotlinc.xml
generated
11
.idea/kotlinc.xml
generated
|
@ -1,13 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Kotlin2JsCompilerArguments">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="moduleKind" value="plain" />
|
<option name="version" value="1.9.10" />
|
||||||
</component>
|
|
||||||
<component name="Kotlin2JvmCompilerArguments">
|
|
||||||
<option name="jvmTarget" value="1.8" />
|
|
||||||
</component>
|
|
||||||
<component name="KotlinCommonCompilerArguments">
|
|
||||||
<option name="apiVersion" value="2.0" />
|
|
||||||
<option name="languageVersion" value="2.0" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
18
.idea/libraries/bld.xml
generated
18
.idea/libraries/bld.xml
generated
|
@ -1,18 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="bld">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
<excluded>
|
|
||||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
|
||||||
</excluded>
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" />
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" type="SOURCES" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
13
.idea/libraries/compile.xml
generated
13
.idea/libraries/compile.xml
generated
|
@ -1,13 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="compile">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
|
||||||
</SOURCES>
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
14
.idea/libraries/runtime.xml
generated
14
.idea/libraries/runtime.xml
generated
|
@ -1,14 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="runtime">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
|
||||||
<root url="file://$PROJECT_DIR$/src/main/resources" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
|
||||||
</SOURCES>
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
14
.idea/libraries/test.xml
generated
14
.idea/libraries/test.xml
generated
|
@ -1,14 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="test">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
|
||||||
<root url="file://$PROJECT_DIR$/src/test/resources" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
|
||||||
</SOURCES>
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
27
.idea/misc.xml
generated
27
.idea/misc.xml
generated
|
@ -1,26 +1,15 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="EntryPointsManager">
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<pattern value="net.thauvin.erik.IsgdShortenBuild" method="detekt" />
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<pattern value="net.thauvin.erik.IsgdShortenBuild" method="detektBaseline" />
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
<pattern value="net.thauvin.erik.IsgdShortenBuild" />
|
|
||||||
<pattern value="net.thauvin.erik.IsgdShortenBuild" method="jacoco" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="PDMPlugin">
|
<component name="PDMPlugin">
|
||||||
<option name="customRuleSets">
|
|
||||||
<list>
|
|
||||||
<option value="K:\java\semver\config\pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../java/bld-pitest/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../java/bld-jacoco-report/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../java/bld-checkstyle/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../java/bld-exec/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../java/bld-testng/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../java/bld-generated-version/config/pmd.xml" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
<option name="skipTestSources" value="false" />
|
<option name="skipTestSources" value="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="18" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
9
.idea/modules.xml
generated
9
.idea/modules.xml
generated
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
9
.idea/runConfigurations/Run Tests.xml
generated
9
.idea/runConfigurations/Run Tests.xml
generated
|
@ -1,9 +0,0 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Run Tests" type="Application" factoryName="Application" nameIsGenerated="true">
|
|
||||||
<option name="MAIN_CLASS_NAME" value="net.thauvin.erik.IsgdShortenTest" />
|
|
||||||
<module name="app" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
|
Copyright 2020-2023 Erik C. Thauvin (erik@thauvin.net)
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
68
README.md
68
README.md
|
@ -1,13 +1,11 @@
|
||||||
[](https://opensource.org/licenses/BSD-3-Clause)
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
||||||
[](https://kotlinlang.org/)
|
[](https://kotlinlang.org/)
|
||||||
[](https://rife2.com/bld)
|
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/isgd-shorten/)
|
||||||
[](https://github.com/ethauvin/isgd-shorten/releases/latest)
|
[](https://github.com/ethauvin/isgd-shorten/releases/latest)
|
||||||
[](https://central.sonatype.com/artifact/net.thauvin.erik/isgd-shorten)
|
[](https://central.sonatype.com/artifact/net.thauvin.erik/isgd-shorten)
|
||||||
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/isgd-shorten/)
|
|
||||||
|
|
||||||
|
|
||||||
[](https://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten)
|
[](https://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten)
|
||||||
[](https://github.com/ethauvin/isgd-shorten/actions/workflows/bld.yml)
|
[](https://github.com/ethauvin/isgd-shorten/actions/workflows/gradle.yml)
|
||||||
[](https://circleci.com/gh/ethauvin/isgd-shorten/tree/master)
|
[](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
|
||||||
|
@ -19,16 +17,16 @@ A simple implementation of the [is.gd](https://is.gd/) URL shortening and lookup
|
||||||
```kotlin
|
```kotlin
|
||||||
import net.thauvin.erik.isgd.Isgd
|
import net.thauvin.erik.isgd.Isgd
|
||||||
|
|
||||||
// ...
|
...
|
||||||
|
|
||||||
Isgd.shorten("https://www.example.com/") // returns https://is.gd/Pt2sET
|
Isgd.shorten("https://www.example.com/") // returns https://is.gd/Pt2sET
|
||||||
Isgd.lookup("https://is.gd/Pt2sET") // returns https://www.example.com
|
Isgd.lookup("https://is.gd/Pt2sET") // returns https://www.example.com
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- View [bld](https://github.com/ethauvin/isgd-shorten/blob/master/examples/bld) or [Gradle](https://github.com/ethauvin/isgd-shorten/blob/master/examples/gradle) Examples.
|
- View [Kotlin](https://github.com/ethauvin/isgd-shorten/blob/master/examples/src/main/kotlin/com/example/IsgdExample.kt) or [Java](https://github.com/ethauvin/isgd-shorten/blob/master/examples/src/main/java/com/example/IsgdSample.java) Examples.
|
||||||
|
|
||||||
## JSON or XML
|
### JSON or XML
|
||||||
|
|
||||||
The [is.gd API](https://is.gd/developers.php) can return data in plain text (default), JSON or XML.
|
The [is.gd API](https://is.gd/developers.php) can return data in plain text (default), JSON or XML.
|
||||||
|
|
||||||
|
@ -42,7 +40,7 @@ returns:
|
||||||
{ "shorturl": "https://is.gd/Pt2sET" }
|
{ "shorturl": "https://is.gd/Pt2sET" }
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
### Parameters
|
||||||
|
|
||||||
All of the [is.gd API](https://is.gd/developers.php) parameters are supported:
|
All of the [is.gd API](https://is.gd/developers.php) parameters are supported:
|
||||||
|
|
||||||
|
@ -61,20 +59,9 @@ returns:
|
||||||
test({ "shorturl": "https://is.gd/foobar" });
|
test({ "shorturl": "https://is.gd/foobar" });
|
||||||
```
|
```
|
||||||
|
|
||||||
## bld
|
### Gradle
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
```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
|
```gradle
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -83,7 +70,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.thauvin.erik:isgd-shorten:1.1.0")
|
implementation("net.thauvin.erik:isgd-shorten:1.0.0")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -94,10 +81,11 @@ Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](htt
|
||||||
To make it easier to use the library with Java, configuration builders are available:
|
To make it easier to use the library with Java, configuration builders are available:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
var config = new ShortenConfig.Builder("https://www.example.com/")
|
var config = new Config.Builder()
|
||||||
.shorturl("foobar")
|
.url("https://www.example.com/")
|
||||||
|
.shortUrl("foobar")
|
||||||
.callback("test")
|
.callback("test")
|
||||||
.logstats(true)
|
.logStats(true)
|
||||||
.format(Format.JSON)
|
.format(Format.JSON)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -105,15 +93,15 @@ Isgd.shorten(config);
|
||||||
```
|
```
|
||||||
|
|
||||||
```java
|
```java
|
||||||
var config = new LookupConfig.Builder("https://is.gd/Pt2sET")
|
var config = new Config.Builder()
|
||||||
.callback("test")
|
.shortUrl("https://is.gd/Pt2sET")
|
||||||
.format(Format.XML)
|
.format(Format.XML)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Isgd.lookup(config);
|
Isgd.lookup(config);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Errors
|
### 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:
|
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:
|
||||||
|
|
||||||
|
@ -126,33 +114,15 @@ try {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```console
|
```
|
||||||
Status Code: 400
|
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.
|
Error: Sorry, the URL you entered is on our internal blacklist. It may have been used abusively in the past, or it may link to another URL redirection service.
|
||||||
```
|
```
|
||||||
|
|
||||||
## v.gd
|
### v.gd
|
||||||
|
|
||||||
Additionally, link can be shortened using [v.gd](https://v.gd/) by setting the `isVgd` flag:
|
Additionally, link can be shortened using [v.gd](https://v.gd/) by setting the `isVgd` flag:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
Isgd.shorten("https://www.example.com/", isVgd = true) // returns https://v.gd/2z2ncj
|
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.
|
|
||||||
|
|
|
@ -1,20 +1,9 @@
|
||||||
image: ubuntu:latest
|
image: maven:3-openjdk-18
|
||||||
|
|
||||||
pipelines:
|
pipelines:
|
||||||
default:
|
default:
|
||||||
- step:
|
- step:
|
||||||
name: Test with bld
|
caches:
|
||||||
|
- gradle
|
||||||
script:
|
script:
|
||||||
# Install latest Java & Kotlin via SDKMAN!
|
- bash ./gradlew check
|
||||||
- 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
|
|
||||||
|
|
2
bld
2
bld
|
@ -1,2 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.IsgdShortenBuild "$@"
|
|
4
bld.bat
4
bld.bat
|
@ -1,4 +0,0 @@
|
||||||
@echo off
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
|
||||||
java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.IsgdShortenBuild %*
|
|
209
build.gradle.kts
Normal file
209
build.gradle.kts
Normal file
|
@ -0,0 +1,209 @@
|
||||||
|
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||||
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("com.github.ben-manes.versions") version "0.48.0"
|
||||||
|
id("io.gitlab.arturbosch.detekt") version "1.23.1"
|
||||||
|
id("java")
|
||||||
|
id("java-library")
|
||||||
|
id("maven-publish")
|
||||||
|
id("net.thauvin.erik.gradle.semver") version "1.0.4"
|
||||||
|
id("org.jetbrains.dokka") version "1.9.0"
|
||||||
|
id("org.jetbrains.kotlinx.kover") version "0.7.3"
|
||||||
|
id("org.sonarqube") version "4.3.1.3277"
|
||||||
|
id("signing")
|
||||||
|
kotlin("jvm") version "1.9.10"
|
||||||
|
kotlin("kapt") version "1.9.10"
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "net.thauvin.erik"
|
||||||
|
description = "A simple implementation of the is.gd URL shortening and lookup APIs"
|
||||||
|
|
||||||
|
val gitHub = "ethauvin/$name"
|
||||||
|
val mavenUrl = "https://github.com/$gitHub"
|
||||||
|
val deployDir = "deploy"
|
||||||
|
var isRelease = "release" in gradle.startParameter.taskNames
|
||||||
|
|
||||||
|
val publicationName = "mavenJava"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(platform(kotlin("bom")))
|
||||||
|
implementation("net.thauvin.erik.urlencoder:urlencoder-lib:1.4.0")
|
||||||
|
|
||||||
|
testImplementation(kotlin("test"))
|
||||||
|
testImplementation(kotlin("test-junit"))
|
||||||
|
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.27.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
koverReport {
|
||||||
|
defaults {
|
||||||
|
xml {
|
||||||
|
onCheck = true
|
||||||
|
}
|
||||||
|
html {
|
||||||
|
onCheck = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
detekt {
|
||||||
|
//toolVersion = "main-SNAPSHOT"
|
||||||
|
baseline = project.rootDir.resolve("config/detekt/baseline.xml")
|
||||||
|
}
|
||||||
|
|
||||||
|
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", "${layout.buildDirectory.get()}/reports/kover/report.xml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val javadocJar by tasks.creating(Jar::class) {
|
||||||
|
dependsOn(tasks.dokkaJavadoc)
|
||||||
|
from(tasks.dokkaJavadoc)
|
||||||
|
archiveClassifier.set("javadoc")
|
||||||
|
description = "Assembles a JAR of the generated Javadoc."
|
||||||
|
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
withType<KotlinCompile>().configureEach {
|
||||||
|
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<Test> {
|
||||||
|
testLogging {
|
||||||
|
exceptionFormat = TestExceptionFormat.FULL
|
||||||
|
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<GenerateMavenPom> {
|
||||||
|
destination = file("$projectDir/pom.xml")
|
||||||
|
}
|
||||||
|
|
||||||
|
assemble {
|
||||||
|
dependsOn(javadocJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
clean {
|
||||||
|
doLast {
|
||||||
|
project.delete(fileTree(deployDir))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dokkaJavadoc {
|
||||||
|
dokkaSourceSets {
|
||||||
|
configureEach {
|
||||||
|
includes.from("config/dokka/packages.md")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mustRunAfter("kaptKotlin")
|
||||||
|
}
|
||||||
|
|
||||||
|
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}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
register("deploy") {
|
||||||
|
description = "Copies all needed files to the $deployDir directory."
|
||||||
|
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||||
|
dependsOn(clean, build, jar)
|
||||||
|
outputs.dir(deployDir)
|
||||||
|
inputs.files(copyToDeploy)
|
||||||
|
mustRunAfter(clean)
|
||||||
|
}
|
||||||
|
|
||||||
|
register("release") {
|
||||||
|
description = "Publishes version ${project.version} to local repository."
|
||||||
|
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||||
|
dependsOn("deploy", gitTag, publishToMavenLocal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>(publicationName) {
|
||||||
|
from(components["java"])
|
||||||
|
artifact(javadocJar)
|
||||||
|
pom {
|
||||||
|
name.set(project.name)
|
||||||
|
description.set(project.description)
|
||||||
|
url.set(mavenUrl)
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name.set("BSD 3-Clause")
|
||||||
|
url.set("https://opensource.org/licenses/BSD-3-Clause")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id.set("ethauvin")
|
||||||
|
name.set("Erik C. Thauvin")
|
||||||
|
email.set("erik@thauvin.net")
|
||||||
|
url.set("https://erik.thauvin.net/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
connection.set("scm:git:https://github.com/$gitHub.git")
|
||||||
|
developerConnection.set("scm:git:git@github.com:$gitHub.git")
|
||||||
|
url.set(mavenUrl)
|
||||||
|
}
|
||||||
|
issueManagement {
|
||||||
|
system.set("GitHub")
|
||||||
|
url.set("$mavenUrl/issues")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "ossrh"
|
||||||
|
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,12 +1,10 @@
|
||||||
<?xml version="1.0" ?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<SmellBaseline>
|
<SmellBaseline>
|
||||||
<ManuallySuppressedIssues></ManuallySuppressedIssues>
|
<ManuallySuppressedIssues/>
|
||||||
<CurrentIssues>
|
<CurrentIssues>
|
||||||
<ID>LongParameterList:Isgd.kt$Isgd.Companion$( url: String, shorturl: String = "", callback: String = "", logstats: Boolean = false, format: Format = Format.SIMPLE, isVgd: Boolean = false )</ID>
|
<ID>LongParameterList:Isgd.kt$Isgd.Companion$( url: String, shorturl: String = "", callback: String = "", logstats: Boolean = false, format: Format = Format.SIMPLE, isVgd: Boolean = false )</ID>
|
||||||
<ID>MagicNumber:Isgd.kt$Isgd.Companion$200</ID>
|
<ID>MagicNumber:Isgd.kt$Isgd.Companion$200</ID>
|
||||||
<ID>MagicNumber:Isgd.kt$Isgd.Companion$399</ID>
|
<ID>MagicNumber:Isgd.kt$Isgd.Companion$399</ID>
|
||||||
<ID>MaxLineLength:Isgd.kt$Isgd.Companion$*</ID>
|
|
||||||
<ID>NestedBlockDepth:IsgdExample.kt$fun main(args: Array<String>)</ID>
|
|
||||||
<ID>WildcardImport:IsgdTest.kt$import assertk.assertions.*</ID>
|
<ID>WildcardImport:IsgdTest.kt$import assertk.assertions.*</ID>
|
||||||
</CurrentIssues>
|
</CurrentIssues>
|
||||||
</SmellBaseline>
|
</SmellBaseline>
|
||||||
|
|
55
examples/bld/.gitignore
vendored
55
examples/bld/.gitignore
vendored
|
@ -1,55 +0,0 @@
|
||||||
.gradle
|
|
||||||
.DS_Store
|
|
||||||
build
|
|
||||||
lib/bld/**
|
|
||||||
!lib/bld/bld-wrapper.jar
|
|
||||||
!lib/bld/bld-wrapper.properties
|
|
||||||
lib/compile/
|
|
||||||
lib/runtime/
|
|
||||||
lib/standalone/
|
|
||||||
lib/test/
|
|
||||||
|
|
||||||
# IDEA ignores
|
|
||||||
|
|
||||||
# User-specific
|
|
||||||
.idea/**/workspace.xml
|
|
||||||
.idea/**/tasks.xml
|
|
||||||
.idea/**/usage.statistics.xml
|
|
||||||
.idea/**/dictionaries
|
|
||||||
.idea/**/shelf
|
|
||||||
|
|
||||||
# AWS User-specific
|
|
||||||
.idea/**/aws.xml
|
|
||||||
|
|
||||||
# Generated files
|
|
||||||
.idea/**/contentModel.xml
|
|
||||||
|
|
||||||
# Sensitive or high-churn files
|
|
||||||
.idea/**/dataSources/
|
|
||||||
.idea/**/dataSources.ids
|
|
||||||
.idea/**/dataSources.local.xml
|
|
||||||
.idea/**/sqlDataSources.xml
|
|
||||||
.idea/**/dynamic.xml
|
|
||||||
.idea/**/uiDesigner.xml
|
|
||||||
.idea/**/dbnavigator.xml
|
|
||||||
|
|
||||||
# Gradle
|
|
||||||
.idea/**/gradle.xml
|
|
||||||
|
|
||||||
# Mongo Explorer plugin
|
|
||||||
.idea/**/mongoSettings.xml
|
|
||||||
|
|
||||||
# mpeltonen/sbt-idea plugin
|
|
||||||
.idea_modules/
|
|
||||||
|
|
||||||
# JIRA plugin
|
|
||||||
atlassian-ide-plugin.xml
|
|
||||||
|
|
||||||
# Cursive Clojure plugin
|
|
||||||
.idea/replstate.xml
|
|
||||||
|
|
||||||
# SonarLint plugin
|
|
||||||
.idea/sonarlint/
|
|
||||||
|
|
||||||
# Editor-based Rest Client
|
|
||||||
.idea/httpRequests
|
|
3
examples/bld/.idea/.gitignore
generated
vendored
3
examples/bld/.idea/.gitignore
generated
vendored
|
@ -1,3 +0,0 @@
|
||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
1
examples/bld/.idea/.name
generated
1
examples/bld/.idea/.name
generated
|
@ -1 +0,0 @@
|
||||||
isgd-shorten-examples-bld
|
|
30
examples/bld/.idea/app.iml
generated
30
examples/bld/.idea/app.iml
generated
|
@ -1,30 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<output url="file://$MODULE_DIR$/build/main" />
|
|
||||||
<output-test url="file://$MODULE_DIR$/build/test" />
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" relativeOutputPath="resources" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="module-library" scope="RUNTIME">
|
|
||||||
<library>
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$MODULE_DIR$/src/main/resources/templates" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</orderEntry>
|
|
||||||
<orderEntry type="library" name="compile" level="project" />
|
|
||||||
<orderEntry type="library" scope="RUNTIME" name="runtime" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="test" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
14
examples/bld/.idea/bld.iml
generated
14
examples/bld/.idea/bld.iml
generated
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<output url="file://$MODULE_DIR$/build/bld" />
|
|
||||||
<output-test url="file://$MODULE_DIR$/build/bld" />
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$/src/bld">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/bld/java" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="library" name="bld" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<profile version="1.0">
|
|
||||||
<option name="myName" value="Project Default" />
|
|
||||||
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
|
||||||
<option name="ADDITIONAL_TAGS" value="created" />
|
|
||||||
</inspection_tool>
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
18
examples/bld/.idea/libraries/bld.xml
generated
18
examples/bld/.idea/libraries/bld.xml
generated
|
@ -1,18 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="bld">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
<excluded>
|
|
||||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
|
||||||
</excluded>
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" />
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" type="SOURCES" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
13
examples/bld/.idea/libraries/compile.xml
generated
13
examples/bld/.idea/libraries/compile.xml
generated
|
@ -1,13 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="compile">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
|
||||||
</SOURCES>
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
14
examples/bld/.idea/libraries/runtime.xml
generated
14
examples/bld/.idea/libraries/runtime.xml
generated
|
@ -1,14 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="runtime">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
|
||||||
<root url="file://$PROJECT_DIR$/src/main/resources" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
|
||||||
</SOURCES>
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
14
examples/bld/.idea/libraries/test.xml
generated
14
examples/bld/.idea/libraries/test.xml
generated
|
@ -1,14 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="test">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
|
||||||
<root url="file://$PROJECT_DIR$/src/test/resources" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
|
||||||
</SOURCES>
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
20
examples/bld/.idea/misc.xml
generated
20
examples/bld/.idea/misc.xml
generated
|
@ -1,20 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="PDMPlugin">
|
|
||||||
<option name="customRuleSets">
|
|
||||||
<list>
|
|
||||||
<option value="K:\java\semver\config\pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-generated-version/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-pitest/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-jacoco-report/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-checkstyle/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-exec/config/pmd.xml" />
|
|
||||||
<option value="$PROJECT_DIR$/../../../../java/bld-testng/config/pmd.xml" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
<option name="skipTestSources" value="false" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
9
examples/bld/.idea/modules.xml
generated
9
examples/bld/.idea/modules.xml
generated
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,9 +0,0 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Run Tests" type="Application" factoryName="Application" nameIsGenerated="true">
|
|
||||||
<option name="MAIN_CLASS_NAME" value="com.example.ExampleTest" />
|
|
||||||
<module name="app" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
6
examples/bld/.idea/vcs.xml
generated
6
examples/bld/.idea/vcs.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
11
examples/bld/.vscode/launch.json
vendored
11
examples/bld/.vscode/launch.json
vendored
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "Run Tests",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "com.example.ExampleTest"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
15
examples/bld/.vscode/settings.json
vendored
15
examples/bld/.vscode/settings.json
vendored
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"java.project.sourcePaths": [
|
|
||||||
"src/main/java",
|
|
||||||
"src/main/resources",
|
|
||||||
"src/test/java",
|
|
||||||
"src/test/resources",
|
|
||||||
"src/bld/java",
|
|
||||||
"src/bld/resources"
|
|
||||||
],
|
|
||||||
"java.configuration.updateBuildConfiguration": "automatic",
|
|
||||||
"java.project.referencedLibraries": [
|
|
||||||
"${HOME}/.bld/dist/bld-2.2.1.jar",
|
|
||||||
"lib/**/*.jar"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
## Kotlin Example
|
|
||||||
To compile & run the Kotlin example:
|
|
||||||
|
|
||||||
```console
|
|
||||||
./bld compile
|
|
||||||
|
|
||||||
./bld run --args='https://www.example.com https://is.gd/Pt2sET'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Java Example
|
|
||||||
To compile & run the Java example:
|
|
||||||
|
|
||||||
```console
|
|
||||||
./bld compile
|
|
||||||
|
|
||||||
./bld run-java --args='https://www.example.com https://is.gd/Pt2sET'
|
|
||||||
|
|
||||||
```
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build com.example.ExampleBuild "$@"
|
|
|
@ -1,4 +0,0 @@
|
||||||
@echo off
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
|
||||||
java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build com.example.ExampleBuild %*
|
|
Binary file not shown.
|
@ -1,8 +0,0 @@
|
||||||
bld.downloadExtensionJavadoc=false
|
|
||||||
bld.downloadExtensionSources=true
|
|
||||||
bld.downloadLocation=
|
|
||||||
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10
|
|
||||||
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
|
|
||||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
|
||||||
bld.sourceDirectories=
|
|
||||||
bld.version=2.2.1
|
|
|
@ -1,51 +0,0 @@
|
||||||
package com.example;
|
|
||||||
|
|
||||||
import rife.bld.BaseProject;
|
|
||||||
import rife.bld.BuildCommand;
|
|
||||||
import rife.bld.extension.CompileKotlinOperation;
|
|
||||||
import rife.bld.operations.RunOperation;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static rife.bld.dependencies.Repository.*;
|
|
||||||
import static rife.bld.dependencies.Scope.compile;
|
|
||||||
|
|
||||||
public class ExampleBuild extends BaseProject {
|
|
||||||
public ExampleBuild() {
|
|
||||||
pkg = "com.example";
|
|
||||||
name = "Example";
|
|
||||||
version = version(0, 1, 0);
|
|
||||||
|
|
||||||
mainClass = "com.example.IsgdExampleKt";
|
|
||||||
|
|
||||||
javaRelease = 11;
|
|
||||||
downloadSources = true;
|
|
||||||
autoDownloadPurge = true;
|
|
||||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
|
|
||||||
|
|
||||||
scope(compile)
|
|
||||||
.include(dependency("net.thauvin.erik:isgd-shorten:1.1.1-SNAPSHOT"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new ExampleBuild().start(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void compile() throws Exception {
|
|
||||||
new CompileKotlinOperation()
|
|
||||||
.fromProject(this)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
// Also compile the Java source code
|
|
||||||
super.compile();
|
|
||||||
}
|
|
||||||
|
|
||||||
@BuildCommand(value = "run-java", summary = "Runs the Java example")
|
|
||||||
public void runJava() throws Exception {
|
|
||||||
new RunOperation()
|
|
||||||
.fromProject(this)
|
|
||||||
.mainClass("com.example.IsgdSample")
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,10 +2,13 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("application")
|
id("application")
|
||||||
id("com.github.ben-manes.versions") version "0.51.0"
|
id("com.github.ben-manes.versions") version "0.48.0"
|
||||||
kotlin("jvm") version "2.1.20"
|
kotlin("jvm") version "1.9.10"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
|
||||||
|
// ./gradlew runJava --args='https://www.example.com https://is.gd/Pt2sET'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -13,7 +16,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.thauvin.erik:isgd-shorten:1.1.1-SNAPSHOT")
|
implementation("net.thauvin.erik:isgd-shorten:1.0.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -25,11 +28,11 @@ application {
|
||||||
mainClass.set("com.example.IsgdExampleKt")
|
mainClass.set("com.example.IsgdExampleKt")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
|
||||||
compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
withType<KotlinCompile>().configureEach {
|
||||||
|
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
|
||||||
|
}
|
||||||
|
|
||||||
register("runJava", JavaExec::class) {
|
register("runJava", JavaExec::class) {
|
||||||
group = "application"
|
group = "application"
|
||||||
mainClass.set("com.example.IsgdSample")
|
mainClass.set("com.example.IsgdSample")
|
3
examples/gradle/.idea/.gitignore
generated
vendored
3
examples/gradle/.idea/.gitignore
generated
vendored
|
@ -1,3 +0,0 @@
|
||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
1
examples/gradle/.idea/.name
generated
1
examples/gradle/.idea/.name
generated
|
@ -1 +0,0 @@
|
||||||
isgd-shorten-examples-gradle
|
|
17
examples/gradle/.idea/gradle.xml
generated
17
examples/gradle/.idea/gradle.xml
generated
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
|
||||||
<component name="GradleSettings">
|
|
||||||
<option name="linkedExternalProjectsSettings">
|
|
||||||
<GradleProjectSettings>
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
||||||
<option name="gradleJvm" value="17" />
|
|
||||||
<option name="modules">
|
|
||||||
<set>
|
|
||||||
<option value="$PROJECT_DIR$" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</GradleProjectSettings>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<profile version="1.0">
|
|
||||||
<option name="myName" value="Project Default" />
|
|
||||||
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
|
||||||
<option name="ADDITIONAL_TAGS" value="created" />
|
|
||||||
</inspection_tool>
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
6
examples/gradle/.idea/kotlinc.xml
generated
6
examples/gradle/.idea/kotlinc.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="KotlinJpsPluginSettings">
|
|
||||||
<option name="version" value="2.0.0" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,10 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Gradle: net.thauvin.erik:isgd-shorten:1.0.2-SNAPSHOT" type="java-imported" external-system-id="GRADLE">
|
|
||||||
<properties groupId="net.thauvin.erik" artifactId="isgd-shorten" version="1.0.2-SNAPSHOT" />
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/thauvin/erik/isgd-shorten/1.0.2-SNAPSHOT/isgd-shorten-1.0.2-SNAPSHOT.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -1,10 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Gradle: net.thauvin.erik.urlencoder:urlencoder-lib-jvm:1.5.0" type="java-imported" external-system-id="GRADLE">
|
|
||||||
<properties groupId="net.thauvin.erik.urlencoder" artifactId="urlencoder-lib-jvm" version="1.5.0" />
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/thauvin/erik/urlencoder/urlencoder-lib-jvm/1.5.0/urlencoder-lib-jvm-1.5.0.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -1,14 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Gradle: org.jetbrains:annotations:13.0" type="java-imported" external-system-id="GRADLE">
|
|
||||||
<properties groupId="org.jetbrains" artifactId="annotations" version="13.0" />
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/73368c3b0887f3adc2c2730dd1b95d7c3781aaf3/annotations-13.0-javadoc.jar!/" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/5991ca87ef1fb5544943d9abc5a9a37583fabe03/annotations-13.0-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -1,14 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:2.0.0" type="java-imported" external-system-id="GRADLE">
|
|
||||||
<properties groupId="org.jetbrains.kotlin" artifactId="kotlin-stdlib" version="2.0.0" />
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.0.0/kotlin-stdlib-2.0.0.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.0.0/2ad14aed781c4a73ed4dbb421966d408a0a06686/kotlin-stdlib-2.0.0-javadoc.jar!/" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.0.0/84cdfeb1d3e1b3f72cc4e0a3803c85c4727312f1/kotlin-stdlib-2.0.0-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
10
examples/gradle/.idea/misc.xml
generated
10
examples/gradle/.idea/misc.xml
generated
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
|
||||||
<file type="web" url="file://$PROJECT_DIR$" />
|
|
||||||
</component>
|
|
||||||
<component name="PDMPlugin">
|
|
||||||
<option name="skipTestSources" value="false" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
|
||||||
</project>
|
|
10
examples/gradle/.idea/modules.xml
generated
10
examples/gradle/.idea/modules.xml
generated
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/isgd-shorten-examples-gradle.iml" filepath="$PROJECT_DIR$/.idea/modules/isgd-shorten-examples-gradle.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/isgd-shorten-examples-gradle.main.iml" filepath="$PROJECT_DIR$/.idea/modules/isgd-shorten-examples-gradle.main.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/isgd-shorten-examples-gradle.test.iml" filepath="$PROJECT_DIR$/.idea/modules/isgd-shorten-examples-gradle.test.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module external.linked.project.id="isgd-shorten-examples-gradle" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$/../..">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../.gradle" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module external.linked.project.id="isgd-shorten-examples-gradle:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet external-system-id="GRADLE" type="kotlin-language" name="Kotlin">
|
|
||||||
<configuration version="5" platform="JVM 11" allPlatforms="JVM [11]" useProjectSettings="false">
|
|
||||||
<compilerArguments>
|
|
||||||
<flagArguments>
|
|
||||||
<flagArg name="allowNoSourceFiles" arg="true" />
|
|
||||||
<flagArg name="noReflect" arg="true" />
|
|
||||||
<flagArg name="noStdlib" arg="true" />
|
|
||||||
</flagArguments>
|
|
||||||
<stringArguments>
|
|
||||||
<stringArg name="destination" arg="$MODULE_DIR$/../../build/classes/kotlin/main" />
|
|
||||||
<stringArg name="jvmTarget" arg="11" />
|
|
||||||
<stringArg name="moduleName" arg="isgd-shorten-examples-gradle" />
|
|
||||||
<stringArg name="apiVersion" arg="2.0" />
|
|
||||||
<stringArg name="languageVersion" arg="2.0" />
|
|
||||||
</stringArguments>
|
|
||||||
<arrayArguments>
|
|
||||||
<arrayArg name="pluginClasspaths">
|
|
||||||
<args>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-scripting-jvm/2.0.0/kotlin-scripting-jvm-2.0.0.jar</arg>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-scripting-common/2.0.0/kotlin-scripting-common-2.0.0.jar</arg>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.0.0/kotlin-stdlib-2.0.0.jar</arg>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar</arg>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-script-runtime/2.0.0/kotlin-script-runtime-2.0.0.jar</arg>
|
|
||||||
</args>
|
|
||||||
</arrayArg>
|
|
||||||
<arrayArg name="pluginOptions" />
|
|
||||||
</arrayArguments>
|
|
||||||
</compilerArguments>
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<output url="file://$MODULE_DIR$/../../build/classes/java/main" />
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$/../../src/main">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../src/main/kotlin" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.thauvin.erik:isgd-shorten:1.0.2-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:2.0.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.thauvin.erik.urlencoder:urlencoder-lib-jvm:1.5.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module external.linked.project.id="isgd-shorten-examples-gradle:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet external-system-id="GRADLE" type="kotlin-language" name="Kotlin">
|
|
||||||
<configuration version="5" platform="JVM 11" allPlatforms="JVM [11]" useProjectSettings="false">
|
|
||||||
<additionalVisibleModuleNames>isgd-shorten-examples-gradle:main</additionalVisibleModuleNames>
|
|
||||||
<compilerArguments>
|
|
||||||
<flagArguments>
|
|
||||||
<flagArg name="allowNoSourceFiles" arg="true" />
|
|
||||||
<flagArg name="noReflect" arg="true" />
|
|
||||||
<flagArg name="noStdlib" arg="true" />
|
|
||||||
</flagArguments>
|
|
||||||
<stringArguments>
|
|
||||||
<stringArg name="destination" arg="$MODULE_DIR$/../../build/classes/kotlin/test" />
|
|
||||||
<stringArg name="jvmTarget" arg="11" />
|
|
||||||
<stringArg name="moduleName" arg="isgd-shorten-examples-gradle_test" />
|
|
||||||
<stringArg name="apiVersion" arg="2.0" />
|
|
||||||
<stringArg name="languageVersion" arg="2.0" />
|
|
||||||
</stringArguments>
|
|
||||||
<arrayArguments>
|
|
||||||
<arrayArg name="pluginClasspaths">
|
|
||||||
<args>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-scripting-jvm/2.0.0/kotlin-scripting-jvm-2.0.0.jar</arg>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-scripting-common/2.0.0/kotlin-scripting-common-2.0.0.jar</arg>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.0.0/kotlin-stdlib-2.0.0.jar</arg>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar</arg>
|
|
||||||
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-script-runtime/2.0.0/kotlin-script-runtime-2.0.0.jar</arg>
|
|
||||||
</args>
|
|
||||||
</arrayArg>
|
|
||||||
<arrayArg name="pluginOptions" />
|
|
||||||
</arrayArguments>
|
|
||||||
</compilerArguments>
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<output-test url="file://$MODULE_DIR$/../../build/classes/java/test" />
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$/../../src/test" />
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="module" module-name="isgd-shorten-examples-gradle.main" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.thauvin.erik:isgd-shorten:1.0.2-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:2.0.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.thauvin.erik.urlencoder:urlencoder-lib-jvm:1.5.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0" level="project" />
|
|
||||||
</component>
|
|
||||||
<component name="TestModuleProperties" production-module="isgd-shorten-examples-gradle.main" />
|
|
||||||
</module>
|
|
6
examples/gradle/.idea/vcs.xml
generated
6
examples/gradle/.idea/vcs.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,14 +0,0 @@
|
||||||
## Kotlin Example
|
|
||||||
To compile & run the Kotlin example:
|
|
||||||
|
|
||||||
```console
|
|
||||||
./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Java Example
|
|
||||||
|
|
||||||
To compile & run the Java example:
|
|
||||||
|
|
||||||
```console
|
|
||||||
./gradlew runJava --args='https://www.example.com https://is.gd/Pt2sET'
|
|
||||||
```
|
|
BIN
examples/gradle/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
examples/gradle/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,28 +0,0 @@
|
||||||
package com.example;
|
|
||||||
|
|
||||||
import net.thauvin.erik.isgd.Format;
|
|
||||||
import net.thauvin.erik.isgd.Isgd;
|
|
||||||
import net.thauvin.erik.isgd.IsgdException;
|
|
||||||
import net.thauvin.erik.isgd.LookupConfig;
|
|
||||||
|
|
||||||
public final class IsgdSample {
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
if (args.length > 0) {
|
|
||||||
for (final String arg : args) {
|
|
||||||
try {
|
|
||||||
if (arg.contains("is.gd")) {
|
|
||||||
System.out.println(arg + " <-- " + Isgd.lookup(arg));
|
|
||||||
System.out.print(Isgd.lookup(new LookupConfig.Builder(arg).format(Format.WEB).build()));
|
|
||||||
} else {
|
|
||||||
System.out.println(arg + " --> " + Isgd.shorten(arg));
|
|
||||||
}
|
|
||||||
} catch (IsgdException e) {
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
System.err.println("Try specifying one or more URLs as arguments.");
|
|
||||||
}
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.example
|
|
||||||
|
|
||||||
import net.thauvin.erik.isgd.Isgd
|
|
||||||
import net.thauvin.erik.isgd.IsgdException
|
|
||||||
import kotlin.system.exitProcess
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
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)
|
|
||||||
}
|
|
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
examples/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
examples/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
248
examples/gradlew
vendored
Executable file
248
examples/gradlew
vendored
Executable file
|
@ -0,0 +1,248 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/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
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $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 \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
|
@ -13,8 +13,6 @@
|
||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -59,22 +57,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
|
@ -7,4 +7,4 @@
|
||||||
* in the user manual at https://docs.gradle.org/6.2/userguide/multi_project_builds.html
|
* in the user manual at https://docs.gradle.org/6.2/userguide/multi_project_builds.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rootProject.name = "isgd-shorten-examples-gradle"
|
rootProject.name = "isgd-examples"
|
|
@ -1,9 +1,9 @@
|
||||||
package com.example;
|
package com.example;
|
||||||
|
|
||||||
|
import net.thauvin.erik.isgd.Config;
|
||||||
import net.thauvin.erik.isgd.Format;
|
import net.thauvin.erik.isgd.Format;
|
||||||
import net.thauvin.erik.isgd.Isgd;
|
import net.thauvin.erik.isgd.Isgd;
|
||||||
import net.thauvin.erik.isgd.IsgdException;
|
import net.thauvin.erik.isgd.IsgdException;
|
||||||
import net.thauvin.erik.isgd.LookupConfig;
|
|
||||||
|
|
||||||
public final class IsgdSample {
|
public final class IsgdSample {
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
|
@ -12,7 +12,7 @@ public final class IsgdSample {
|
||||||
try {
|
try {
|
||||||
if (arg.contains("is.gd")) {
|
if (arg.contains("is.gd")) {
|
||||||
System.out.println(arg + " <-- " + Isgd.lookup(arg));
|
System.out.println(arg + " <-- " + Isgd.lookup(arg));
|
||||||
System.out.print(Isgd.lookup(new LookupConfig.Builder(arg).format(Format.WEB).build()));
|
System.out.print(Isgd.lookup(new Config.Builder().shortUrl(arg).format(Format.WEB).build()));
|
||||||
} else {
|
} else {
|
||||||
System.out.println(arg + " --> " + Isgd.shorten(arg));
|
System.out.println(arg + " --> " + Isgd.shorten(arg));
|
||||||
}
|
}
|
0
gradle.properties
Normal file
0
gradle.properties
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
24
examples/gradle/gradlew → gradlew
vendored
24
examples/gradle/gradlew → gradlew
vendored
|
@ -15,8 +15,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
|
@ -57,7 +55,7 @@
|
||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
@ -86,7 +84,7 @@ done
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
@ -114,7 +112,7 @@ case "$( uname )" in #(
|
||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH="\\\"\\\""
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
|
@ -147,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC2039,SC3045
|
# shellcheck disable=SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
|
@ -155,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC2039,SC3045
|
# shellcheck disable=SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
|
@ -204,16 +202,16 @@ fi
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# 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"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command;
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
# and any embedded shellness will be escaped.
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# double quotes to make sure that they get re-expanded; and
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-classpath "$CLASSPATH" \
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# Stop when "xargs" is not available.
|
92
gradlew.bat
vendored
Normal file
92
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
Binary file not shown.
|
@ -1,10 +0,0 @@
|
||||||
bld.downloadExtensionJavadoc=false
|
|
||||||
bld.downloadExtensionSources=true
|
|
||||||
bld.downloadLocation=
|
|
||||||
bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT
|
|
||||||
bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.4-SNAPSHOT
|
|
||||||
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10
|
|
||||||
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
|
|
||||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
|
||||||
bld.sourceDirectories=
|
|
||||||
bld.version=2.2.1
|
|
53
pom.xml
53
pom.xml
|
@ -1,10 +1,14 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
<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">
|
||||||
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 -->
|
||||||
|
<!-- that they should prefer consuming it instead. -->
|
||||||
|
<!-- do_not_remove: published-with-gradle-metadata -->
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.thauvin.erik</groupId>
|
<groupId>net.thauvin.erik</groupId>
|
||||||
<artifactId>isgd-shorten</artifactId>
|
<artifactId>isgd-shorten</artifactId>
|
||||||
<version>1.1.1-SNAPSHOT</version>
|
<version>1.0.0</version>
|
||||||
<name>isgd-shorten</name>
|
<name>isgd-shorten</name>
|
||||||
<description>A simple implementation of the is.gd URL shortening and lookup APIs</description>
|
<description>A simple implementation of the is.gd URL shortening and lookup APIs</description>
|
||||||
<url>https://github.com/ethauvin/isgd-shorten</url>
|
<url>https://github.com/ethauvin/isgd-shorten</url>
|
||||||
|
@ -14,20 +18,6 @@
|
||||||
<url>https://opensource.org/licenses/BSD-3-Clause</url>
|
<url>https://opensource.org/licenses/BSD-3-Clause</url>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-stdlib</artifactId>
|
|
||||||
<version>2.1.20</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.thauvin.erik.urlencoder</groupId>
|
|
||||||
<artifactId>urlencoder-lib-jvm</artifactId>
|
|
||||||
<version>1.6.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>ethauvin</id>
|
<id>ethauvin</id>
|
||||||
|
@ -41,4 +31,33 @@
|
||||||
<developerConnection>scm:git:git@github.com:ethauvin/isgd-shorten.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:ethauvin/isgd-shorten.git</developerConnection>
|
||||||
<url>https://github.com/ethauvin/isgd-shorten</url>
|
<url>https://github.com/ethauvin/isgd-shorten</url>
|
||||||
</scm>
|
</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.9.10</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>1.9.10</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.thauvin.erik.urlencoder</groupId>
|
||||||
|
<artifactId>urlencoder-lib-jvm</artifactId>
|
||||||
|
<version>1.4.0</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
18
settings.gradle.kts
Normal file
18
settings.gradle.kts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
plugins {
|
||||||
|
id("com.gradle.enterprise").version("3.15")
|
||||||
|
}
|
||||||
|
|
||||||
|
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,7 +0,0 @@
|
||||||
sonar.organization=ethauvin-github
|
|
||||||
sonar.projectKey=ethauvin_isgd-shorten
|
|
||||||
sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml
|
|
||||||
sonar.sources=src/main/kotlin/
|
|
||||||
sonar.tests=src/test/kotlin/
|
|
||||||
sonar.java.binaries=build/main,build/test
|
|
||||||
sonar.java.libraries=lib/compile/*.jar
|
|
|
@ -1,195 +0,0 @@
|
||||||
/*
|
|
||||||
* IsgdShortenBuild.java
|
|
||||||
*
|
|
||||||
* Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name of this project nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software without
|
|
||||||
* specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.thauvin.erik;
|
|
||||||
|
|
||||||
import rife.bld.BuildCommand;
|
|
||||||
import rife.bld.Project;
|
|
||||||
import rife.bld.extension.CompileKotlinOperation;
|
|
||||||
import rife.bld.extension.DetektOperation;
|
|
||||||
import rife.bld.extension.DokkaOperation;
|
|
||||||
import rife.bld.extension.JacocoReportOperation;
|
|
||||||
import rife.bld.extension.dokka.LoggingLevel;
|
|
||||||
import rife.bld.extension.dokka.OutputFormat;
|
|
||||||
import rife.bld.extension.kotlin.CompileOptions;
|
|
||||||
import rife.bld.operations.exceptions.ExitStatusException;
|
|
||||||
import rife.bld.publish.PomBuilder;
|
|
||||||
import rife.bld.publish.PublishDeveloper;
|
|
||||||
import rife.bld.publish.PublishLicense;
|
|
||||||
import rife.bld.publish.PublishScm;
|
|
||||||
import rife.tools.exceptions.FileUtilsErrorException;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.ConsoleHandler;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static rife.bld.dependencies.Repository.*;
|
|
||||||
import static rife.bld.dependencies.Scope.compile;
|
|
||||||
import static rife.bld.dependencies.Scope.test;
|
|
||||||
|
|
||||||
public class IsgdShortenBuild extends Project {
|
|
||||||
final File srcMainKotlin = new File(srcMainDirectory(), "kotlin");
|
|
||||||
|
|
||||||
public IsgdShortenBuild() {
|
|
||||||
pkg = "net.thauvin.erik";
|
|
||||||
name = "isgd-shorten";
|
|
||||||
version = version(1, 1, 1, "SNAPSHOT");
|
|
||||||
|
|
||||||
javaRelease = 11;
|
|
||||||
downloadSources = true;
|
|
||||||
autoDownloadPurge = true;
|
|
||||||
|
|
||||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
|
|
||||||
|
|
||||||
final var kotlin = version(2, 1, 20);
|
|
||||||
scope(compile)
|
|
||||||
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin))
|
|
||||||
.include(dependency("net.thauvin.erik.urlencoder", "urlencoder-lib-jvm", version(1, 6, 0)));
|
|
||||||
scope(test)
|
|
||||||
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
|
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
|
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)))
|
|
||||||
.include(dependency("org.junit.platform", "junit-platform-launcher", version(1, 12, 2)))
|
|
||||||
.include(dependency("com.willowtreeapps.assertk", "assertk-jvm", version(0, 28, 1)));
|
|
||||||
|
|
||||||
publishOperation()
|
|
||||||
.repository(version.isSnapshot() ? repository(SONATYPE_SNAPSHOTS_LEGACY.location())
|
|
||||||
.withCredentials(property("sonatype.user"), property("sonatype.password"))
|
|
||||||
: repository(SONATYPE_RELEASES_LEGACY.location())
|
|
||||||
.withCredentials(property("sonatype.user"), property("sonatype.password")))
|
|
||||||
.repository(repository("github"))
|
|
||||||
.info()
|
|
||||||
.groupId(pkg)
|
|
||||||
.artifactId(name)
|
|
||||||
.description("A simple implementation of the is.gd URL shortening and lookup APIs")
|
|
||||||
.url("https://github.com/ethauvin/" + name)
|
|
||||||
.developer(new PublishDeveloper()
|
|
||||||
.id("ethauvin")
|
|
||||||
.name("Erik C. Thauvin")
|
|
||||||
.email("erik@thauvin.net")
|
|
||||||
.url("https://erik.thauvin.net/")
|
|
||||||
)
|
|
||||||
.license(new PublishLicense()
|
|
||||||
.name("BSD 3-Clause")
|
|
||||||
.url("https://opensource.org/licenses/BSD-3-Clause")
|
|
||||||
)
|
|
||||||
.scm(new PublishScm()
|
|
||||||
.connection("scm:git:https://github.com/ethauvin/" + name + ".git")
|
|
||||||
.developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
|
|
||||||
.url("https://github.com/ethauvin/" + name)
|
|
||||||
)
|
|
||||||
.signKey(property("sign.key"))
|
|
||||||
.signPassphrase(property("sign.passphrase"));
|
|
||||||
|
|
||||||
jarSourcesOperation().sourceDirectories(srcMainKotlin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// Enable detailed logging for the extensions
|
|
||||||
var level = Level.ALL;
|
|
||||||
var logger = Logger.getLogger("rife.bld.extension");
|
|
||||||
var consoleHandler = new ConsoleHandler();
|
|
||||||
|
|
||||||
consoleHandler.setLevel(level);
|
|
||||||
logger.addHandler(consoleHandler);
|
|
||||||
logger.setLevel(level);
|
|
||||||
logger.setUseParentHandlers(false);
|
|
||||||
|
|
||||||
new IsgdShortenBuild().start(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
|
||||||
@Override
|
|
||||||
public void compile() throws Exception {
|
|
||||||
new CompileKotlinOperation()
|
|
||||||
.fromProject(this)
|
|
||||||
.compileOptions(new CompileOptions().verbose(true))
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
@BuildCommand(summary = "Checks source with Detekt")
|
|
||||||
public void detekt() throws ExitStatusException, IOException, InterruptedException {
|
|
||||||
new DetektOperation()
|
|
||||||
.fromProject(this)
|
|
||||||
.baseline("config/detekt/baseline.xml")
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
@BuildCommand(value = "detekt-baseline", summary = "Creates the Detekt baseline")
|
|
||||||
public void detektBaseline() throws ExitStatusException, IOException, InterruptedException {
|
|
||||||
new DetektOperation()
|
|
||||||
.fromProject(this)
|
|
||||||
.baseline("config/detekt/baseline.xml")
|
|
||||||
.createBaseline(true)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
@BuildCommand(summary = "Generates JaCoCo Reports")
|
|
||||||
public void jacoco() throws Exception {
|
|
||||||
new JacocoReportOperation()
|
|
||||||
.fromProject(this)
|
|
||||||
.sourceFiles(srcMainKotlin)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void javadoc() throws ExitStatusException, IOException, InterruptedException {
|
|
||||||
new DokkaOperation()
|
|
||||||
.fromProject(this)
|
|
||||||
.loggingLevel(LoggingLevel.INFO)
|
|
||||||
.moduleName("is.gd Shorten")
|
|
||||||
.moduleVersion(version.toString())
|
|
||||||
.outputDir(new File(buildDirectory(), "javadoc"))
|
|
||||||
.outputFormat(OutputFormat.JAVADOC)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void publish() throws Exception {
|
|
||||||
super.publish();
|
|
||||||
pomRoot();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void publishLocal() throws Exception {
|
|
||||||
super.publishLocal();
|
|
||||||
pomRoot();
|
|
||||||
}
|
|
||||||
|
|
||||||
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
|
|
||||||
public void pomRoot() throws FileUtilsErrorException {
|
|
||||||
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
|
|
||||||
new File(workDirectory, "pom.xml"));
|
|
||||||
}
|
|
||||||
}
|
|
74
src/main/kotlin/net/thauvin/erik/isgd/Config.kt
Normal file
74
src/main/kotlin/net/thauvin/erik/isgd/Config.kt
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Config.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
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a builder to create/lookup an is.gd shortlink.
|
||||||
|
*/
|
||||||
|
class Config private constructor(
|
||||||
|
val url: String,
|
||||||
|
val shorturl: String,
|
||||||
|
val callback: String,
|
||||||
|
val logstats: Boolean,
|
||||||
|
val format: Format,
|
||||||
|
val isVgd: Boolean
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* Configures the parameters to create/lookup an is.gd shortlink.
|
||||||
|
*
|
||||||
|
* See the [is.gd API](https://is.gd/apishorteningreference.php).
|
||||||
|
*/
|
||||||
|
data class Builder(
|
||||||
|
private var url: String = "",
|
||||||
|
private var shorturl: String = "",
|
||||||
|
private var callback: String = "",
|
||||||
|
private var logstats: Boolean = false,
|
||||||
|
private var format: Format = Format.SIMPLE,
|
||||||
|
private var isVgd: Boolean = false
|
||||||
|
) {
|
||||||
|
fun url(url: String) = apply { this.url = url }
|
||||||
|
fun shortUrl(shortUrl: String) = apply { this.shorturl = shortUrl }
|
||||||
|
fun callback(callback: String) = apply { this.callback = callback }
|
||||||
|
fun logStats(logStats: Boolean) = apply { this.logstats = logStats }
|
||||||
|
fun format(format: Format) = apply { this.format = format }
|
||||||
|
fun isVgd(isVgd: Boolean) = apply { this.isVgd = isVgd }
|
||||||
|
|
||||||
|
fun build() = Config(
|
||||||
|
url,
|
||||||
|
shorturl,
|
||||||
|
callback,
|
||||||
|
logstats,
|
||||||
|
format,
|
||||||
|
isVgd
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Isgd.kt
|
* Isgd.kt
|
||||||
*
|
*
|
||||||
* Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
|
* Copyright 2023 Erik C. Thauvin (erik@thauvin.net)
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -33,7 +33,7 @@ package net.thauvin.erik.isgd
|
||||||
|
|
||||||
import net.thauvin.erik.urlencoder.UrlEncoderUtil
|
import net.thauvin.erik.urlencoder.UrlEncoderUtil
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import java.net.URI
|
import java.net.URL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See the [is.gd API](https://is.gd/apishorteningreference.php).
|
* See the [is.gd API](https://is.gd/apishorteningreference.php).
|
||||||
|
@ -50,21 +50,17 @@ fun String.encode(): String = UrlEncoderUtil.encode(this)
|
||||||
class Isgd private constructor() {
|
class Isgd private constructor() {
|
||||||
companion object {
|
companion object {
|
||||||
private fun callApi(url: String): String {
|
private fun callApi(url: String): String {
|
||||||
val connection = URI(url).toURL().openConnection() as HttpURLConnection
|
val connection = URL(url).openConnection() as HttpURLConnection
|
||||||
try {
|
connection.setRequestProperty(
|
||||||
connection.setRequestProperty(
|
"User-Agent",
|
||||||
"User-Agent",
|
"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0"
|
||||||
"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0"
|
)
|
||||||
)
|
if (connection.responseCode in 200..399) {
|
||||||
if (connection.responseCode in 200..399) {
|
return connection.inputStream.bufferedReader().use { it.readText() }
|
||||||
return connection.inputStream.bufferedReader().use { it.readText() }
|
} else {
|
||||||
} else {
|
throw IsgdException(
|
||||||
throw IsgdException(
|
connection.responseCode,
|
||||||
connection.responseCode,
|
connection.errorStream.bufferedReader().use { it.readText() })
|
||||||
connection.errorStream.bufferedReader().use { it.readText() })
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
connection.disconnect()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +75,7 @@ class Isgd private constructor() {
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Throws(IsgdException::class)
|
@Throws(IsgdException::class)
|
||||||
fun lookup(config: LookupConfig): String {
|
fun lookup(config: Config): String {
|
||||||
return lookup(
|
return lookup(
|
||||||
config.shorturl,
|
config.shorturl,
|
||||||
config.callback,
|
config.callback,
|
||||||
|
@ -92,17 +88,6 @@ class Isgd private constructor() {
|
||||||
* Lookup a shortlink.
|
* Lookup a shortlink.
|
||||||
*
|
*
|
||||||
* See the [is.gd API](https://is.gd/apilookupreference.php).
|
* See the [is.gd API](https://is.gd/apilookupreference.php).
|
||||||
*
|
|
||||||
* @param shorturl The shorturl parameter is the shortened is.gd URL that you want to look up. You can either
|
|
||||||
* submit the full address (e.g. `https://is.gd/example`) or only the unique part (e.g. `example`). The address
|
|
||||||
* you submit should be properly formed; the API lookup function is not guaranteed to handle malformed URLs the
|
|
||||||
* same way as when you visit them manually.
|
|
||||||
* @param callback The callback parameter is used to specify a callback function to wrap the returned data in
|
|
||||||
* when using JSON format. This can be useful when working with cross domain data. Even when using JSON format
|
|
||||||
* this parameter is optional.
|
|
||||||
* @param format The format parameter determines what format is.gd uses to send output back to you (e.g. to
|
|
||||||
* tell you what your new shortened URL is or if an error has occurred).
|
|
||||||
* @param isVgd Lookup using the `v.gd` domain.
|
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
|
@ -133,7 +118,7 @@ class Isgd private constructor() {
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Throws(IsgdException::class)
|
@Throws(IsgdException::class)
|
||||||
fun shorten(config: ShortenConfig): String {
|
fun shorten(config: Config): String {
|
||||||
return shorten(
|
return shorten(
|
||||||
config.url,
|
config.url,
|
||||||
config.shorturl,
|
config.shorturl,
|
||||||
|
@ -148,26 +133,6 @@ class Isgd private constructor() {
|
||||||
* Shortens a link.
|
* Shortens a link.
|
||||||
*
|
*
|
||||||
* See the [is.gd API](https://is.gd/apishorteningreference.php).
|
* See the [is.gd API](https://is.gd/apishorteningreference.php).
|
||||||
*
|
|
||||||
* @param url The url parameter is the address that you want to shorten.
|
|
||||||
* @param shorturl You can specify the shorturl parameter if you'd like to pick a shortened URL instead of
|
|
||||||
* having is.gd randomly generate one. These must be between 5 and 30 characters long and can only contain
|
|
||||||
* alphanumeric characters and underscores. Shortened URLs are case sensitive. Bear in mind that a desired
|
|
||||||
* short URL might already be taken (this is very often the case with common words) so if you're using this
|
|
||||||
* option be prepared to respond to an error and get an alternative choice from your app's user.
|
|
||||||
* @param callback The callback parameter is used to specify a callback function to wrap the returned data in
|
|
||||||
* when using JSON format. This can be useful when working with cross domain data. Even when using JSON format
|
|
||||||
* this parameter is optional.
|
|
||||||
* @param logstats Turns on logging of detailed statistics when the shortened URL you create is accessed. This
|
|
||||||
* allows you to see how many times the link was accessed on a given day, what pages referred people to the
|
|
||||||
* link, what browser visitors were using etc. You can access these stats via the link preview page for your
|
|
||||||
* shortened URL (add a hyphen/dash to the end of the shortened URL to get to it). Creating links with
|
|
||||||
* statistics turned on has twice the "cost" towards our rate limit of other shortened links, so leave this
|
|
||||||
* parameter out of your API call if you don't require statistics on usage. See the
|
|
||||||
* [usage limits page](https://is.gd/usagelimits.php) for more information on this.
|
|
||||||
* @param format The format parameter determines what format is.gd uses to send output back to you (e.g. to
|
|
||||||
* tell you what your new shortened URL is or if an error has occurred).
|
|
||||||
* @param isVgd Shorten using the `v.gd` domain.
|
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* IsgdException.kt
|
* IsgdException.kt
|
||||||
*
|
*
|
||||||
* Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
|
* Copyright 2023 Erik C. Thauvin (erik@thauvin.net)
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
/*
|
|
||||||
* LookupConfig.kt
|
|
||||||
*
|
|
||||||
* Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name of this project nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software without
|
|
||||||
* specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.thauvin.erik.isgd
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides a builder to lookup an is.gd shortlink.
|
|
||||||
*/
|
|
||||||
class LookupConfig private constructor(builder: Builder) {
|
|
||||||
val shorturl: String = builder.shorturl
|
|
||||||
val callback: String = builder.callback
|
|
||||||
val format: Format = builder.format
|
|
||||||
val isVgd: Boolean = builder.isVgd
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configures the parameters to lookup an is.gd shortlink.
|
|
||||||
*
|
|
||||||
* See the [is.gd Lookup]() API.
|
|
||||||
*
|
|
||||||
* @param shorturl The shorturl parameter is the shortened is.gd URL that you want to look up. You can either submit
|
|
||||||
* the full address (e.g. `https://is.gd/example`) or only the unique part (e.g. `example`). The address you submit
|
|
||||||
* should be properly formed; the API lookup function is not guaranteed to handle malformed URLs the same way as
|
|
||||||
* when you visit them manually.
|
|
||||||
*/
|
|
||||||
data class Builder(var shorturl: String) {
|
|
||||||
var callback: String = ""
|
|
||||||
var format: Format = Format.SIMPLE
|
|
||||||
var isVgd: Boolean = false
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The shorturl parameter is the shortened is.gd URL that you want to look up. You can either submit the full
|
|
||||||
* address (e.g. `https://is.gd/example`) or only the unique part (e.g. `example`). The address you submit
|
|
||||||
* should be properly formed; the API lookup function is not guaranteed to handle malformed URLs the same way
|
|
||||||
* as when you visit them manually.
|
|
||||||
*/
|
|
||||||
fun shorturl(shorturl: String): Builder = apply { this.shorturl = shorturl }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The callback parameter is used to specify a callback function to wrap the returned data in
|
|
||||||
* when using JSON format. This can be useful when working with cross domain data. Even when using JSON format
|
|
||||||
* this parameter is optional.
|
|
||||||
*/
|
|
||||||
fun callback(callback: String): Builder = apply { this.callback = callback }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The format parameter determines what format is.gd uses to send output back to you (e.g. to
|
|
||||||
* tell you what your new shortened URL is or if an error has occurred).
|
|
||||||
*/
|
|
||||||
fun format(format: Format): Builder = apply { this.format = format }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shorten using the `v.gd` domain.
|
|
||||||
*/
|
|
||||||
fun isVgd(isVgd: Boolean): Builder = apply { this.isVgd = isVgd }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a new configuration.
|
|
||||||
*/
|
|
||||||
fun build() = LookupConfig(this)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,107 +0,0 @@
|
||||||
/*
|
|
||||||
* ShortenConfig.kt
|
|
||||||
*
|
|
||||||
* Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name of this project nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software without
|
|
||||||
* specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.thauvin.erik.isgd
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides a builder to create an is.gd shortlink.
|
|
||||||
*/
|
|
||||||
class ShortenConfig private constructor(builder: Builder) {
|
|
||||||
val url: String = builder.url
|
|
||||||
val shorturl: String = builder.shorturl
|
|
||||||
val callback: String = builder.callback
|
|
||||||
val logstats: Boolean = builder.logstats
|
|
||||||
val format: Format = builder.format
|
|
||||||
val isVgd: Boolean = builder.isVgd
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configures the parameters to create an is.gd shortlink.
|
|
||||||
*
|
|
||||||
* See the [is.gd Shortening](https://is.gd/apishorteningreference.php) API.
|
|
||||||
*
|
|
||||||
* @param url The url parameter is the address that you want to shorten.
|
|
||||||
*/
|
|
||||||
data class Builder(var url: String) {
|
|
||||||
var shorturl: String = ""
|
|
||||||
var callback: String = ""
|
|
||||||
var logstats: Boolean = false
|
|
||||||
var format: Format = Format.SIMPLE
|
|
||||||
var isVgd: Boolean = false
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The url parameter is the address that you want to shorten.
|
|
||||||
*/
|
|
||||||
fun url(url: String): Builder = apply { this.url = url }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* You can specify the shorturl parameter if you'd like to pick a shortened URL instead of
|
|
||||||
* having is.gd randomly generate one. These must be between 5 and 30 characters long and can only contain
|
|
||||||
* alphanumeric characters and underscores. Shortened URLs are case-sensitive. Bear in mind that a desired
|
|
||||||
* short URL might already be taken (this is very often the case with common words) so if you're using this
|
|
||||||
* option be prepared to respond to an error and get an alternative choice from your app's user.
|
|
||||||
*/
|
|
||||||
fun shorturl(shorturl: String): Builder = apply { this.shorturl = shorturl }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The callback parameter is used to specify a callback function to wrap the returned data in
|
|
||||||
* when using JSON format. This can be useful when working with cross domain data. Even when using JSON format
|
|
||||||
* this parameter is optional.
|
|
||||||
*/
|
|
||||||
fun callback(callback: String): Builder = apply { this.callback = callback }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns on logging of detailed statistics when the shortened URL you create is accessed. This
|
|
||||||
* allows you to see how many times the link was accessed on a given day, what pages referred people to the
|
|
||||||
* link, what browser visitors were using etc. You can access these stats via the link preview page for your
|
|
||||||
* shortened URL (add a hyphen/dash to the end of the shortened URL to get to it). Creating links with
|
|
||||||
* statistics turned on has twice the "cost" towards our rate limit of other shortened links, so leave this
|
|
||||||
* parameter out of your API call if you don't require statistics on usage. See the
|
|
||||||
* [usage limits page](https://is.gd/usagelimits.php) for more information on this.
|
|
||||||
*/
|
|
||||||
fun logstats(logstats: Boolean): Builder = apply { this.logstats = logstats }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The format parameter determines what format is.gd uses to send output back to you (e.g. to
|
|
||||||
* tell you what your new shortened URL is or if an error has occurred).
|
|
||||||
*/
|
|
||||||
fun format(format: Format): Builder = apply { this.format = format }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shorten using the `v.gd` domain.
|
|
||||||
*/
|
|
||||||
fun isVgd(isVgd: Boolean): Builder = apply { this.isVgd = isVgd }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a new configuration.
|
|
||||||
*/
|
|
||||||
fun build() = ShortenConfig(this)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* IsgdTest.kt
|
* IsgdTest.kt
|
||||||
*
|
*
|
||||||
* Copyright 2020-2025 Erik C. Thauvin (erik@thauvin.net)
|
* Copyright 2023 Erik C. Thauvin (erik@thauvin.net)
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -66,7 +66,7 @@ class IsgdTest {
|
||||||
assertFailsWith(
|
assertFailsWith(
|
||||||
message = "shorten(config:duplicate)",
|
message = "shorten(config:duplicate)",
|
||||||
exceptionClass = IsgdException::class,
|
exceptionClass = IsgdException::class,
|
||||||
block = { Isgd.shorten(ShortenConfig.Builder(shortUrl).build()) }
|
block = { Isgd.shorten(Config.Builder().url(shortUrl).build()) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class IsgdTest {
|
||||||
assertFailsWith(
|
assertFailsWith(
|
||||||
message = "lookup(config:empty)",
|
message = "lookup(config:empty)",
|
||||||
exceptionClass = IllegalArgumentException::class,
|
exceptionClass = IllegalArgumentException::class,
|
||||||
block = { Isgd.lookup(LookupConfig.Builder("").build()) }
|
block = { Isgd.lookup(Config.Builder().shortUrl("").build()) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,10 +96,10 @@ class IsgdTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testLookupDefaultConfig() {
|
fun testLookupDefaultConfig() {
|
||||||
assertEquals(url, Isgd.lookup(LookupConfig.Builder(shortUrl).build()), "lookup(config)")
|
assertEquals(url, Isgd.lookup(Config.Builder().shortUrl(shortUrl).build()), "lookup(config)")
|
||||||
assertEquals(
|
assertEquals(
|
||||||
url, Isgd.lookup(
|
url, Isgd.lookup(
|
||||||
LookupConfig.Builder(shortVgdUrl).isVgd(true).build()
|
Config.Builder().shortUrl(shortVgdUrl).isVgd(true).build()
|
||||||
), "lookup(config:isVgd)"
|
), "lookup(config:isVgd)"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -119,12 +119,12 @@ class IsgdTest {
|
||||||
fun testLookupJsonConfig() {
|
fun testLookupJsonConfig() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"{ \"url\": \"$url\" }",
|
"{ \"url\": \"$url\" }",
|
||||||
Isgd.lookup(LookupConfig.Builder(shortUrl).format(Format.JSON).build()), "lookup(config)"
|
Isgd.lookup(Config.Builder().shortUrl(shortUrl).format(Format.JSON).build()), "lookup(config)"
|
||||||
)
|
)
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"test({ \"url\": \"$url\" });",
|
"test({ \"url\": \"$url\" });",
|
||||||
Isgd.lookup(LookupConfig.Builder(shortUrl).callback("test").format(Format.JSON).build()),
|
Isgd.lookup(Config.Builder().shortUrl(shortUrl).callback("test").format(Format.JSON).build()),
|
||||||
"lookup(config:callback)"
|
"lookup(config:callback)"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ class IsgdTest {
|
||||||
fun testLookupXmlConfig() {
|
fun testLookupXmlConfig() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><output><url>$url</url></output>",
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><output><url>$url</url></output>",
|
||||||
Isgd.lookup(LookupConfig.Builder(shortUrl).format(Format.XML).build()),
|
Isgd.lookup(Config.Builder().shortUrl(shortUrl).format(Format.XML).build()),
|
||||||
"lookup(config:xml)"
|
"lookup(config:xml)"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -166,13 +166,13 @@ class IsgdTest {
|
||||||
assertFailsWith(
|
assertFailsWith(
|
||||||
message = "shorten(config:empty)",
|
message = "shorten(config:empty)",
|
||||||
exceptionClass = IllegalArgumentException::class,
|
exceptionClass = IllegalArgumentException::class,
|
||||||
block = { Isgd.shorten(ShortenConfig.Builder("").build()) }
|
block = { Isgd.shorten(Config.Builder().url("").build()) }
|
||||||
)
|
)
|
||||||
|
|
||||||
assertFailsWith(
|
assertFailsWith(
|
||||||
message = "shorten(config:shorturl)",
|
message = "shorten(config:shorturl)",
|
||||||
exceptionClass = IsgdException::class,
|
exceptionClass = IsgdException::class,
|
||||||
block = { Isgd.shorten(ShortenConfig.Builder(url).shorturl("test").build()) }
|
block = { Isgd.shorten(Config.Builder(url).shortUrl("test").build()) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,13 +185,13 @@ class IsgdTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testShortenDefaultConfig() {
|
fun testShortenDefaultConfig() {
|
||||||
assertEquals(shortUrl, Isgd.shorten(ShortenConfig.Builder(url).build()), "shorten(config:url)")
|
assertEquals(shortUrl, Isgd.shorten(Config.Builder().url(url).build()), "shorten(config:url)")
|
||||||
assertEquals(
|
assertEquals(
|
||||||
shortVgdUrl,
|
shortVgdUrl,
|
||||||
Isgd.shorten(ShortenConfig.Builder(url).isVgd(true).build()),
|
Isgd.shorten(Config.Builder().url(url).isVgd(true).build()),
|
||||||
"shorten(config:isVgd)"
|
"shorten(config:isVgd)"
|
||||||
)
|
)
|
||||||
assertThat(Isgd.shorten(ShortenConfig.Builder(url).logstats(true).build()), "shorten(config:callback)")
|
assertThat(Isgd.shorten(Config.Builder().url(url).logStats(true).build()), "shorten(config:callback)")
|
||||||
.matches("https://is.gd/\\w{6}".toRegex())
|
.matches("https://is.gd/\\w{6}".toRegex())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,11 +209,11 @@ class IsgdTest {
|
||||||
fun testShortenJsonConfig() {
|
fun testShortenJsonConfig() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"{ \"shorturl\": \"$shortUrl\" }",
|
"{ \"shorturl\": \"$shortUrl\" }",
|
||||||
Isgd.shorten(ShortenConfig.Builder(url).format(Format.JSON).build()), "shorten(config:json)"
|
Isgd.shorten(Config.Builder().url(url).format(Format.JSON).build()), "shorten(config:json)"
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"test({ \"shorturl\": \"$shortUrl\" });",
|
"test({ \"shorturl\": \"$shortUrl\" });",
|
||||||
Isgd.shorten(ShortenConfig.Builder(url).callback("test").format(Format.JSON).build()),
|
Isgd.shorten(Config.Builder().url(url).callback("test").format(Format.JSON).build()),
|
||||||
"shorten(config:callback,json)"
|
"shorten(config:callback,json)"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ class IsgdTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
|
||||||
"<output><shorturl>$shortUrl</shorturl></output>",
|
"<output><shorturl>$shortUrl</shorturl></output>",
|
||||||
Isgd.shorten(ShortenConfig.Builder(url).format(Format.XML).build()),
|
Isgd.shorten(Config.Builder().url(url).format(Format.XML).build()),
|
||||||
"shorten(config:xml)"
|
"shorten(config:xml)"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ class IsgdTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testShortenWebConfig() {
|
fun testShortenWebConfig() {
|
||||||
assertThat(Isgd.shorten(ShortenConfig.Builder(url).format(Format.WEB).build()), "shorten(config:web)")
|
assertThat(Isgd.shorten(Config.Builder().url(url).format(Format.WEB).build()), "shorten(config:web)")
|
||||||
.contains(shortUrl)
|
.contains(shortUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
version.properties
Normal file
8
version.properties
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#Generated by the Semver Plugin for Gradle
|
||||||
|
#Sun May 02 21:57:08 PDT 2021
|
||||||
|
version.buildmeta=
|
||||||
|
version.major=1
|
||||||
|
version.minor=0
|
||||||
|
version.patch=0
|
||||||
|
version.prerelease=
|
||||||
|
version.semver=1.0.0
|
Loading…
Add table
Add a link
Reference in a new issue