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/
|
||||
|
||||
jobs:
|
||||
build_gradle_jdk17:
|
||||
build_gradle_jdk18:
|
||||
<<: *defaults
|
||||
|
||||
docker:
|
||||
- image: cimg/openjdk:17.0
|
||||
- image: cimg/openjdk:18.0
|
||||
|
||||
<<: *defaults_gradle
|
||||
|
||||
build_gradle_jdk8:
|
||||
build_gradle_jdk11:
|
||||
<<: *defaults
|
||||
|
||||
docker:
|
||||
- image: cimg/openjdk:8.0
|
||||
- image: cimg/openjdk:11.0
|
||||
|
||||
<<: *defaults_gradle
|
||||
|
||||
|
@ -50,5 +50,5 @@ workflows:
|
|||
version: 2
|
||||
gradle:
|
||||
jobs:
|
||||
- build_gradle_jdk8
|
||||
- build_gradle_jdk17
|
||||
- build_gradle_jdk11
|
||||
- build_gradle_jdk18
|
||||
|
|
2
.github/workflows/gradle.yml
vendored
2
.github/workflows/gradle.yml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
java-version: [ 1.8, 11, 17 ]
|
||||
java-version: [ 11, 18 ]
|
||||
|
||||
steps:
|
||||
- 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">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</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" />
|
||||
</component>
|
||||
<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
|
||||
|
||||
|
@ -44,7 +44,7 @@ Isgd.shorten(url = url, shorturl="foobar", callback = "test", logstats = true, f
|
|||
```
|
||||
returns:
|
||||
|
||||
```json
|
||||
```js
|
||||
test({ "shorturl": "https://is.gd/foobar" });
|
||||
```
|
||||
### 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:
|
||||
|
||||
```gradle
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
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
|
||||
|
||||
|
@ -64,7 +68,7 @@ An `IsgdException` is thrown when an API error occurs. The error message (text,
|
|||
|
||||
```kotlin
|
||||
try {
|
||||
Isgd.shorten("http://is.gd/Pt2sET") // already shorten
|
||||
Isgd.shorten("https://is.gd/Pt2sET") // already shorten
|
||||
} catch (e: IsgdException)
|
||||
println("Status Code: ${e.statusCode}")
|
||||
println("${e.message})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
image: openjdk:8
|
||||
image: maven:3-openjdk-18
|
||||
|
||||
pipelines:
|
||||
default:
|
||||
|
|
|
@ -3,18 +3,18 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
|||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
|
||||
plugins {
|
||||
id("com.github.ben-manes.versions") version "0.40.0"
|
||||
id("io.gitlab.arturbosch.detekt") version "1.19.0"
|
||||
id("com.github.ben-manes.versions") version "0.42.0"
|
||||
id("io.gitlab.arturbosch.detekt") version "1.21.0"
|
||||
id("java")
|
||||
id("java-library")
|
||||
id("maven-publish")
|
||||
id("net.thauvin.erik.gradle.semver") version "1.0.4"
|
||||
id("org.jetbrains.dokka") version "1.6.10"
|
||||
id("org.jetbrains.kotlinx.kover") version "0.4.4"
|
||||
id("org.sonarqube") version "3.3"
|
||||
id("org.jetbrains.dokka") version "1.7.10"
|
||||
id("org.jetbrains.kotlinx.kover") version "0.6.0"
|
||||
id("org.sonarqube") version "3.4.0.2513"
|
||||
id("signing")
|
||||
kotlin("jvm") version "1.6.10"
|
||||
kotlin("kapt") version "1.6.10"
|
||||
kotlin("jvm") version "1.7.20"
|
||||
kotlin("kapt") version "1.7.20"
|
||||
}
|
||||
|
||||
group = "net.thauvin.erik"
|
||||
|
@ -56,7 +56,7 @@ sonarqube {
|
|||
property("sonar.organization", "ethauvin-github")
|
||||
property("sonar.host.url", "https://sonarcloud.io")
|
||||
property("sonar.sourceEncoding", "UTF-8")
|
||||
property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/report.xml")
|
||||
property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/xml/report.xml")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ tasks {
|
|||
register("deploy") {
|
||||
description = "Copies all needed files to the $deployDir directory."
|
||||
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||
dependsOn(build, jar)
|
||||
dependsOn(clean, wrapper, build, jar)
|
||||
outputs.dir(deployDir)
|
||||
inputs.files(copyToDeploy)
|
||||
mustRunAfter(clean)
|
||||
|
|
|
@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||
|
||||
plugins {
|
||||
id("application")
|
||||
id("com.github.ben-manes.versions") version "0.40.0"
|
||||
kotlin("jvm") version "1.6.10"
|
||||
id("com.github.ben-manes.versions") version "0.42.0"
|
||||
kotlin("jvm") version "1.7.20"
|
||||
}
|
||||
|
||||
// ./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
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
|
||||
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
|
||||
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
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -40,7 +40,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-bom</artifactId>
|
||||
<version>1.5.31</version>
|
||||
<version>1.7.20</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -50,7 +50,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>1.5.31</version>
|
||||
<version>1.7.20</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -45,7 +45,7 @@ enum class Format(val type: 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 {
|
||||
val connection = URL(url).openConnection() as HttpURLConnection
|
||||
connection.setRequestProperty(
|
||||
"User-Agent",
|
||||
"Mozilla/5.0 (Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"
|
||||
"User-Agent",
|
||||
"Mozilla/5.0 (Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
|
||||
)
|
||||
if (connection.responseCode in 200..399) {
|
||||
return connection.inputStream.bufferedReader().readText()
|
||||
|
@ -77,10 +77,10 @@ class Isgd private constructor() {
|
|||
@JvmOverloads
|
||||
@Throws(IsgdException::class)
|
||||
fun lookup(
|
||||
shorturl: String,
|
||||
callback: String = "",
|
||||
format: Format = Format.SIMPLE,
|
||||
isVgd: Boolean = false
|
||||
shorturl: String,
|
||||
callback: String = "",
|
||||
format: Format = Format.SIMPLE,
|
||||
isVgd: Boolean = false
|
||||
): String {
|
||||
if (shorturl.isEmpty()) {
|
||||
throw IllegalArgumentException("Please specify a valid short URL to lookup.")
|
||||
|
@ -104,12 +104,12 @@ class Isgd private constructor() {
|
|||
@JvmOverloads
|
||||
@Throws(IsgdException::class)
|
||||
fun shorten(
|
||||
url: String,
|
||||
shorturl: String = "",
|
||||
callback: String = "",
|
||||
logstats: Boolean = false,
|
||||
format: Format = Format.SIMPLE,
|
||||
isVgd: Boolean = false
|
||||
url: String,
|
||||
shorturl: String = "",
|
||||
callback: String = "",
|
||||
logstats: Boolean = false,
|
||||
format: Format = Format.SIMPLE,
|
||||
isVgd: Boolean = false
|
||||
): String {
|
||||
if (url.isEmpty()) {
|
||||
throw IllegalArgumentException("Please enter a valid URL to shorten.")
|
||||
|
|
|
@ -53,8 +53,8 @@ class IsgdTest {
|
|||
try {
|
||||
Isgd.shorten(shortUrl)
|
||||
} catch (e: IsgdException) {
|
||||
assertTrue(e.statusCode == 400, "status code == 400")
|
||||
assertTrue(e.message!!.startsWith("Error: "), "error message")
|
||||
assertTrue(e.statusCode == 400, "status code != 400")
|
||||
assertTrue(e.message!!.startsWith("Error: "), "error message is invalid")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue