Upgraded to Gradle 6.6 and Kotlin 1.4.0.

This commit is contained in:
Erik C. Thauvin 2020-08-18 00:12:41 -07:00
parent b12931c6ad
commit 720986b83f
15 changed files with 87 additions and 120 deletions

View file

@ -2,7 +2,7 @@
[![Known Vulnerabilities](https://snyk.io/test/github/ethauvin/bitly-shorten/badge.svg?targetFile=pom.xml)](https://snyk.io/test/github/ethauvin/bitly-shorten?targetFile=pom.xml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_bitly-shorten&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_bitly-shorten) [![Build Status](https://travis-ci.com/ethauvin/bitly-shorten.svg?branch=master)](https://travis-ci.com/ethauvin/bitly-shorten) [![CircleCI](https://circleci.com/gh/ethauvin/bitly-shorten/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/bitly-shorten/tree/master)
# [Bitly](https://dev.bitly.com/v4/) Shortener for Kotlin/Java
# [Bitly](https://dev.bitly.com/v4/) Shortener for Kotlin/Java/Android
A simple implementation of the link shortening ([bitlinks](https://dev.bitly.com/v4/#tag/Bitlinks)) abilities of the [Bitly v4 API](https://dev.bitly.com/v4).
@ -46,7 +46,7 @@ val bitly = Bitly(File("my.properties"))
BITLY_ACCESS_TOKEN=abc123def456ghi789jkl0
```
### Gradle
### Gradle, Maven, etc.
To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/bitly-shorten/blob/master/examples/build.gradle.kts) file:
@ -60,9 +60,11 @@ dependencies {
}
```
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/artifact/net.thauvin.erik/bitly-shorten/0.9.2/jar).
### JSON
All implemented methods can return the full API JSON responses:
All implemented API calls can return the full JSON responses:
```kotlin
bitly.bitlinks().shorten("https://www.erik.thauvin.net/blog", toJson = true)
@ -76,7 +78,21 @@ bitly.bitlinks().shorten("https://www.erik.thauvin.net/blog", toJson = true)
}
```
Non-implemented methods can also be called directly:
You can also access the last response from implemented API calls using:
```kotlin
val bitlinks = Bitlinks(apikey)
val shortUrl = bitlinks.shorten(longUrl)
val response = bitlinks.lastCallResponse
if (response.isSuccessful) {
println(response.body)
}
```
Non-implemented API calls can also be called directly:
```kotlin
val response = bitly.call("/user".toEndPoint(), method = Methods.GET)

View file

@ -1,5 +1,4 @@
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.FileInputStream
import java.util.Date
@ -11,11 +10,11 @@ plugins {
`maven-publish`
id("com.github.ben-manes.versions") version "0.29.0"
id("com.jfrog.bintray") version "1.8.5"
id("io.gitlab.arturbosch.detekt") version "1.10.0"
id("io.gitlab.arturbosch.detekt") version "1.11.0"
id("net.thauvin.erik.gradle.semver") version "1.0.4"
id("org.jetbrains.dokka") version "0.10.1"
id("org.jetbrains.kotlin.jvm") version "1.3.72"
id("org.jetbrains.kotlin.kapt") version "1.3.72"
id("org.jetbrains.dokka") version "1.4.0-rc"
id("org.jetbrains.kotlin.jvm") version "1.4.0"
id("org.jetbrains.kotlin.kapt") version "1.4.0"
id("org.sonarqube") version "3.0"
}
@ -32,7 +31,7 @@ var semverProcessor = "net.thauvin.erik:semver:1.2.0"
val publicationName = "mavenJava"
object VersionInfo {
const val okhttp = "4.8.0"
const val okhttp = "4.8.1"
}
val versions: VersionInfo by extra { VersionInfo }
@ -57,11 +56,6 @@ repositories {
}
dependencies {
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.squareup.okhttp3:okhttp:${versions.okhttp}")
implementation("com.squareup.okhttp3:logging-interceptor:${versions.okhttp}")
implementation("org.json:json:20200518")
@ -79,7 +73,7 @@ kapt {
}
detekt {
baseline = project.rootDir.resolve("detekt-baseline.xml")
baseline = project.rootDir.resolve("config/detekt/baseline.xml")
}
jacoco {
@ -104,32 +98,13 @@ val sourcesJar by tasks.creating(Jar::class) {
}
val javadocJar by tasks.creating(Jar::class) {
dependsOn(tasks.dokka)
from(tasks.dokka)
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc)
archiveClassifier.set("javadoc")
description = "Assembles a JAR of the generated Javadoc."
group = JavaBasePlugin.DOCUMENTATION_GROUP
}
val dokkaDocs by tasks.creating(DokkaTask::class) {
outputFormat = "gfm"
outputDirectory = "$projectDir"
configuration {
moduleName = "docs"
sourceLink {
path = file("$projectDir/src/main/kotlin").toURI().toString().replace("file:", "")
url = "https://github.com/ethauvin/${project.name}/tree/master/src/main/kotlin"
lineSuffix = "#L"
}
jdkVersion = 8
includes = listOf("config/dokka/packages.md")
includeNonPublic = false
}
}
tasks {
withType<JacocoReport> {
reports {
@ -156,23 +131,31 @@ tasks {
}
}
dokka {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
dokkaHtml {
outputDirectory = "$projectDir/docs"
configuration {
dokkaSourceSets {
configureEach {
jdkVersion = 8
includes = listOf("config/dokka/packages.md")
sourceLink {
path = file("$projectDir/src/main/kotlin").toURI().toString().replace("file:", "")
url = "https://github.com/ethauvin/${project.name}/tree/master/src/main/kotlin"
path = "/src/main/kotlin/"
url = "https://github.com/ethauvin/${project.name}/tree/master/src/main/kotlin/"
lineSuffix = "#L"
}
jdkVersion = 8
includes = listOf("config/dokka/packages.md")
includeNonPublic = false
}
dependsOn(dokkaDocs)
}
}
dokkaJavadoc {
dokkaSourceSets {
configureEach {
jdkVersion = 8
includes = listOf("config/dokka/packages.md")
}
}
dependsOn(dokkaHtml)
}
val copyToDeploy by registering(Copy::class) {
@ -244,6 +227,7 @@ bintray {
githubReleaseNotesFile = "README.md"
vcsUrl = "$mavenUrl.git"
setLabels(
"android",
"bitlinks",
"bitly",
"bitly-api",

View file

@ -0,0 +1,21 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>ComplexMethod:Bitlinks.kt$Bitlinks$ @Synchronized @JvmOverloads fun update( bitlink: String, references: Map&lt;String, String&gt; = emptyMap(), archived: Boolean = false, tags: Array&lt;String&gt; = emptyArray(), created_at: String = Constants.EMPTY, title: String = Constants.EMPTY, deeplinks: Array&lt;Map&lt;String, String&gt;&gt; = emptyArray(), created_by: String = Constants.EMPTY, long_url: String = Constants.EMPTY, client_id: String = Constants.EMPTY, custom_bitlinks: Array&lt;String&gt; = emptyArray(), link: String = Constants.EMPTY, id: String = Constants.EMPTY, toJson: Boolean = false ): String</ID>
<ID>ComplexMethod:Utils.kt$Utils.Companion$ @JvmOverloads fun call( accessToken: String, endPoint: String, params: Map&lt;String, Any&gt; = emptyMap(), method: Methods = Methods.POST ): CallResponse</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$bitlink_id: String</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$client_id: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$created_at: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$created_by: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$custom_bitlinks: Array&lt;String&gt; = emptyArray()</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$group_guid: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$long_url: String</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$long_url: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$unit_reference: String = Constants.EMPTY</ID>
<ID>MagicNumber:CallResponse.kt$CallResponse$200</ID>
<ID>MagicNumber:CallResponse.kt$CallResponse$299</ID>
<ID>NestedBlockDepth:Utils.kt$Utils.Companion$ @JvmOverloads fun call( accessToken: String, endPoint: String, params: Map&lt;String, Any&gt; = emptyMap(), method: Methods = Methods.POST ): CallResponse</ID>
<ID>NestedBlockDepth:Utils.kt$Utils.Companion$private fun parseBody(endPoint: String, result: Response): String</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -1,21 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<Blacklist></Blacklist>
<Whitelist>
<ID>ComplexMethod:Bitlinks.kt$Bitlinks$update</ID>
<ID>ComplexMethod:Utils.kt$Utils.Companion$call</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$bitlink_id: String</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$client_id: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$created_at: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$created_by: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$custom_bitlinks: Array&lt;String&gt; = emptyArray()</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$group_guid: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$long_url: String</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$long_url: String = Constants.EMPTY</ID>
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$unit_reference: String = Constants.EMPTY</ID>
<ID>MagicNumber:CallResponse.kt$CallResponse$200</ID>
<ID>MagicNumber:CallResponse.kt$CallResponse$299</ID>
<ID>NestedBlockDepth:Utils.kt$Utils.Companion$call</ID>
<ID>NestedBlockDepth:Utils.kt$Utils.Companion$parseBody</ID>
</Whitelist>
</SmellBaseline>

View file

@ -1,5 +1,5 @@
plugins {
id("org.jetbrains.kotlin.jvm") version "1.3.72"
id("org.jetbrains.kotlin.jvm") version "1.4.0"
id("com.github.ben-manes.versions") version "0.28.0"
application
}
@ -15,10 +15,7 @@ repositories {
}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("net.thauvin.erik:bitly-shorten:0.9.2")
implementation("net.thauvin.erik:bitly-shorten:0.9.3")
implementation("org.json:json:20200518")
}

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

21
examples/gradlew.bat vendored
View file

@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
@ -86,7 +71,7 @@ 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 %CMD_LINE_ARGS%
"%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

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

21
gradlew.bat vendored
View file

@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
@ -86,7 +71,7 @@ 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 %CMD_LINE_ARGS%
"%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

View file

@ -3,6 +3,6 @@
version.buildmeta=
version.major=0
version.minor=9
version.patch=2
version.patch=3
version.prerelease=
version.semver=0.9.2
version.semver=0.9.3