Upgraded to Kotlin 1.7.20
This commit is contained in:
parent
035aa73fab
commit
28d86b8b14
14 changed files with 54 additions and 54 deletions
|
@ -30,19 +30,19 @@ defaults_gradle: &defaults_gradle
|
||||||
path: build/reports/
|
path: build/reports/
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_gradle_jdk17:
|
build_gradle_jdk18:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/openjdk:17.0
|
- image: cimg/openjdk:18.0
|
||||||
|
|
||||||
<<: *defaults_gradle
|
<<: *defaults_gradle
|
||||||
|
|
||||||
build_gradle_jdk8:
|
build_gradle_jdk11:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/openjdk:8.0
|
- image: cimg/openjdk:11.0
|
||||||
|
|
||||||
<<: *defaults_gradle
|
<<: *defaults_gradle
|
||||||
|
|
||||||
|
@ -50,5 +50,5 @@ workflows:
|
||||||
version: 2
|
version: 2
|
||||||
gradle:
|
gradle:
|
||||||
jobs:
|
jobs:
|
||||||
- build_gradle_jdk8
|
- build_gradle_jdk11
|
||||||
- build_gradle_jdk17
|
- build_gradle_jdk18
|
||||||
|
|
2
.github/workflows/gradle.yml
vendored
2
.github/workflows/gradle.yml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [ 1.8, 11, 17 ]
|
java-version: [ 11, 18 ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
6
.idea/kotlinc.xml
generated
Normal file
6
.idea/kotlinc.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="KotlinJpsPluginSettings">
|
||||||
|
<option name="version" value="1.7.10" />
|
||||||
|
</component>
|
||||||
|
</project>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -4,7 +4,7 @@
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$" />
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="15" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="18" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
10
.idea/runConfigurations.xml
generated
10
.idea/runConfigurations.xml
generated
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
14
README.md
14
README.md
|
@ -1,6 +1,6 @@
|
||||||
[](http://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/isgd-shorten/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten)
|
[](https://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/isgd-shorten/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten)
|
||||||
|
|
||||||
[](https://snyk.io/test/github/ethauvin/isgd-shorten?targetFile=pom.xml) [](https://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten) [](https://github.com/ethauvin/isgd-shorten/actions/workflows/gradle.yml) [](https://circleci.com/gh/ethauvin/isgd-shorten/tree/master)
|
[](https://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten) [](https://github.com/ethauvin/isgd-shorten/actions/workflows/gradle.yml) [](https://circleci.com/gh/ethauvin/isgd-shorten/tree/master)
|
||||||
|
|
||||||
# [is.gd](https://is.gd/developers.php) Shortener for Kotlin/Java/Android
|
# [is.gd](https://is.gd/developers.php) Shortener for Kotlin/Java/Android
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ Isgd.shorten(url = url, shorturl="foobar", callback = "test", logstats = true, f
|
||||||
```
|
```
|
||||||
returns:
|
returns:
|
||||||
|
|
||||||
```json
|
```js
|
||||||
test({ "shorturl": "https://is.gd/foobar" });
|
test({ "shorturl": "https://is.gd/foobar" });
|
||||||
```
|
```
|
||||||
### Gradle
|
### Gradle
|
||||||
|
@ -52,11 +52,15 @@ test({ "shorturl": "https://is.gd/foobar" });
|
||||||
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:
|
To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/isgd-shorten/blob/master/examples/build.gradle.kts) file:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.thauvin.erik:isgd-shorten:0.9.2")
|
implementation("net.thauvin.erik:isgd-shorten:0.9.2")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/artifact/net.thauvin.erik/isgd-shorten/0.9.2/jar).
|
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten).
|
||||||
|
|
||||||
### Errors
|
### Errors
|
||||||
|
|
||||||
|
@ -64,7 +68,7 @@ An `IsgdException` is thrown when an API error occurs. The error message (text,
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
try {
|
try {
|
||||||
Isgd.shorten("http://is.gd/Pt2sET") // already shorten
|
Isgd.shorten("https://is.gd/Pt2sET") // already shorten
|
||||||
} catch (e: IsgdException)
|
} catch (e: IsgdException)
|
||||||
println("Status Code: ${e.statusCode}")
|
println("Status Code: ${e.statusCode}")
|
||||||
println("${e.message})
|
println("${e.message})
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
image: openjdk:8
|
image: maven:3-openjdk-18
|
||||||
|
|
||||||
pipelines:
|
pipelines:
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -3,18 +3,18 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.github.ben-manes.versions") version "0.40.0"
|
id("com.github.ben-manes.versions") version "0.42.0"
|
||||||
id("io.gitlab.arturbosch.detekt") version "1.19.0"
|
id("io.gitlab.arturbosch.detekt") version "1.21.0"
|
||||||
id("java")
|
id("java")
|
||||||
id("java-library")
|
id("java-library")
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("net.thauvin.erik.gradle.semver") version "1.0.4"
|
id("net.thauvin.erik.gradle.semver") version "1.0.4"
|
||||||
id("org.jetbrains.dokka") version "1.6.10"
|
id("org.jetbrains.dokka") version "1.7.10"
|
||||||
id("org.jetbrains.kotlinx.kover") version "0.4.4"
|
id("org.jetbrains.kotlinx.kover") version "0.6.0"
|
||||||
id("org.sonarqube") version "3.3"
|
id("org.sonarqube") version "3.4.0.2513"
|
||||||
id("signing")
|
id("signing")
|
||||||
kotlin("jvm") version "1.6.10"
|
kotlin("jvm") version "1.7.20"
|
||||||
kotlin("kapt") version "1.6.10"
|
kotlin("kapt") version "1.7.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "net.thauvin.erik"
|
group = "net.thauvin.erik"
|
||||||
|
@ -56,7 +56,7 @@ sonarqube {
|
||||||
property("sonar.organization", "ethauvin-github")
|
property("sonar.organization", "ethauvin-github")
|
||||||
property("sonar.host.url", "https://sonarcloud.io")
|
property("sonar.host.url", "https://sonarcloud.io")
|
||||||
property("sonar.sourceEncoding", "UTF-8")
|
property("sonar.sourceEncoding", "UTF-8")
|
||||||
property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/report.xml")
|
property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/xml/report.xml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ tasks {
|
||||||
register("deploy") {
|
register("deploy") {
|
||||||
description = "Copies all needed files to the $deployDir directory."
|
description = "Copies all needed files to the $deployDir directory."
|
||||||
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||||
dependsOn(build, jar)
|
dependsOn(clean, wrapper, build, jar)
|
||||||
outputs.dir(deployDir)
|
outputs.dir(deployDir)
|
||||||
inputs.files(copyToDeploy)
|
inputs.files(copyToDeploy)
|
||||||
mustRunAfter(clean)
|
mustRunAfter(clean)
|
||||||
|
|
|
@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("application")
|
id("application")
|
||||||
id("com.github.ben-manes.versions") version "0.40.0"
|
id("com.github.ben-manes.versions") version "0.42.0"
|
||||||
kotlin("jvm") version "1.6.10"
|
kotlin("jvm") version "1.7.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
|
// ./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -40,7 +40,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-bom</artifactId>
|
<artifactId>kotlin-bom</artifactId>
|
||||||
<version>1.5.31</version>
|
<version>1.7.20</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
<version>1.5.31</version>
|
<version>1.7.20</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -45,7 +45,7 @@ enum class Format(val type: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.encode(): String {
|
fun String.encode(): String {
|
||||||
return URLEncoder.encode(this, StandardCharsets.UTF_8.name())
|
return URLEncoder.encode(this, StandardCharsets.UTF_8).replace("+", "%20").replace("*", "%2A").replace("%7E", "~")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,8 +56,8 @@ class Isgd private constructor() {
|
||||||
private fun callApi(url: String): String {
|
private fun callApi(url: String): String {
|
||||||
val connection = URL(url).openConnection() as HttpURLConnection
|
val connection = URL(url).openConnection() as HttpURLConnection
|
||||||
connection.setRequestProperty(
|
connection.setRequestProperty(
|
||||||
"User-Agent",
|
"User-Agent",
|
||||||
"Mozilla/5.0 (Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"
|
"Mozilla/5.0 (Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
|
||||||
)
|
)
|
||||||
if (connection.responseCode in 200..399) {
|
if (connection.responseCode in 200..399) {
|
||||||
return connection.inputStream.bufferedReader().readText()
|
return connection.inputStream.bufferedReader().readText()
|
||||||
|
@ -77,10 +77,10 @@ class Isgd private constructor() {
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@Throws(IsgdException::class)
|
@Throws(IsgdException::class)
|
||||||
fun lookup(
|
fun lookup(
|
||||||
shorturl: String,
|
shorturl: String,
|
||||||
callback: String = "",
|
callback: String = "",
|
||||||
format: Format = Format.SIMPLE,
|
format: Format = Format.SIMPLE,
|
||||||
isVgd: Boolean = false
|
isVgd: Boolean = false
|
||||||
): String {
|
): String {
|
||||||
if (shorturl.isEmpty()) {
|
if (shorturl.isEmpty()) {
|
||||||
throw IllegalArgumentException("Please specify a valid short URL to lookup.")
|
throw IllegalArgumentException("Please specify a valid short URL to lookup.")
|
||||||
|
@ -104,12 +104,12 @@ class Isgd private constructor() {
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@Throws(IsgdException::class)
|
@Throws(IsgdException::class)
|
||||||
fun shorten(
|
fun shorten(
|
||||||
url: String,
|
url: String,
|
||||||
shorturl: String = "",
|
shorturl: String = "",
|
||||||
callback: String = "",
|
callback: String = "",
|
||||||
logstats: Boolean = false,
|
logstats: Boolean = false,
|
||||||
format: Format = Format.SIMPLE,
|
format: Format = Format.SIMPLE,
|
||||||
isVgd: Boolean = false
|
isVgd: Boolean = false
|
||||||
): String {
|
): String {
|
||||||
if (url.isEmpty()) {
|
if (url.isEmpty()) {
|
||||||
throw IllegalArgumentException("Please enter a valid URL to shorten.")
|
throw IllegalArgumentException("Please enter a valid URL to shorten.")
|
||||||
|
|
|
@ -53,8 +53,8 @@ class IsgdTest {
|
||||||
try {
|
try {
|
||||||
Isgd.shorten(shortUrl)
|
Isgd.shorten(shortUrl)
|
||||||
} catch (e: IsgdException) {
|
} catch (e: IsgdException) {
|
||||||
assertTrue(e.statusCode == 400, "status code == 400")
|
assertTrue(e.statusCode == 400, "status code != 400")
|
||||||
assertTrue(e.message!!.startsWith("Error: "), "error message")
|
assertTrue(e.message!!.startsWith("Error: "), "error message is invalid")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue