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) [![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). 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 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: 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 ### JSON
All implemented methods can return the full API JSON responses: All implemented API calls can return the full JSON responses:
```kotlin ```kotlin
bitly.bitlinks().shorten("https://www.erik.thauvin.net/blog", toJson = true) 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 ```kotlin
val response = bitly.call("/user".toEndPoint(), method = Methods.GET) val response = bitly.call("/user".toEndPoint(), method = Methods.GET)

View file

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

Binary file not shown.

View file

@ -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-6.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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 set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 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_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail 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 :execute
@rem Setup the command line @rem Setup the command line
@ -86,7 +71,7 @@ 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%" 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 :end
@rem End local scope for the variables with windows NT shell @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 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

21
gradlew.bat vendored
View file

@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 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_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail 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 :execute
@rem Setup the command line @rem Setup the command line
@ -86,7 +71,7 @@ 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%" 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 :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

View file

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