Upgraded to Gradle 6.6 and Kotlin 1.4.0.

This commit is contained in:
Erik C. Thauvin 2020-08-18 00:31:13 -07:00
parent 414a096314
commit 7adbddd3a3
16 changed files with 74 additions and 119 deletions

6
.idea/kotlinScripting.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinScriptingSettings">
<option name="suppressDefinitionsCheck" value="true" />
</component>
</project>

View file

@ -4,7 +4,7 @@
# [Akismet](https://www.akismet.com) for Kotlin/Java # [Akismet](https://www.akismet.com) for Kotlin/Java
Akismet for Kotlin/Java is a pretty complete and straightforward implementation of the [Automattic's Akismet](https://akismet.com/development/api/) API, a free service which can be used to actively stop comments spam. Akismet for Kotlin/Java/Android is a pretty complete and straightforward implementation of the [Automattic's Akismet](https://akismet.com/development/api/) API, a free service which can be used to actively stop comments spam.
## Examples (TL;DR) ## Examples (TL;DR)

View file

@ -1,23 +1,21 @@
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.net.URL import java.net.URL
import java.util.Date import java.util.*
import java.util.Properties
plugins { plugins {
jacoco jacoco
java java
`maven-publish` `maven-publish`
id("com.github.ben-manes.versions") version "0.28.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.9.1" 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.jetbrains.kotlin.plugin.serialization") version "1.3.72" id("org.jetbrains.kotlin.plugin.serialization") version "1.4.0"
id("org.sonarqube") version "3.0" id("org.sonarqube") version "3.0"
} }
@ -34,7 +32,7 @@ var semverProcessor = "net.thauvin.erik:semver:1.2.0"
val publicationName = "mavenJava" val publicationName = "mavenJava"
object VersionInfo { object VersionInfo {
const val okhttp = "4.7.2" const val okhttp = "4.8.1"
} }
val versions: VersionInfo by extra { VersionInfo } val versions: VersionInfo by extra { VersionInfo }
@ -66,12 +64,9 @@ dependencies {
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}")
// Align versions of all Kotlin components implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc-218")
implementation(platform("org.jetbrains.kotlin:kotlin-bom")) testImplementation("org.mockito:mockito-core:3.5.0")
implementation(kotlin("stdlib")) testImplementation("org.testng:testng:7.3.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0-1.3.70-eap-274-2")
testImplementation("org.mockito:mockito-core:3.3.3")
testImplementation("org.testng:testng:7.2.0")
} }
kapt { kapt {
@ -81,9 +76,7 @@ kapt {
} }
detekt { detekt {
//input = files("src/main/kotlin", "src/test/kotlin") baseline = project.rootDir.resolve("config/detekt/baseline.xml")
//filters = ".*/resources/.*,.*/build/.*"
baseline = project.rootDir.resolve("detekt-baseline.xml")
} }
jacoco { jacoco {
@ -108,37 +101,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
externalDocumentationLink {
url = URL("https://javaee.github.io/javaee-spec/javadocs/")
packageListUrl = URL("https://javaee.github.io/javaee-spec/javadocs/package-list")
}
includes = listOf("config/dokka/packages.md")
includeNonPublic = false
}
}
tasks { tasks {
withType<Test> { withType<Test> {
useTestNG() useTestNG()
@ -169,32 +138,42 @@ tasks {
} }
} }
dokka { dokkaHtml {
outputFormat = "html" outputDirectory = "$projectDir/docs"
outputDirectory = "$buildDir/javadoc"
configuration { dokkaSourceSets {
sourceLink { configureEach {
path = file("$projectDir/src/main/kotlin").toURI().toString().replace("file:", "") jdkVersion = 8
url = "https://github.com/ethauvin/${project.name}/tree/master/src/main/kotlin" includes = listOf("config/dokka/packages.md")
lineSuffix = "#L" sourceLink {
path = "/src/main/kotlin/"
url = "https://github.com/ethauvin/${project.name}/tree/master/src/main/kotlin/"
lineSuffix = "#L"
}
externalDocumentationLink {
url = URL("https://javaee.github.io/javaee-spec/javadocs/")
packageListUrl = URL("https://javaee.github.io/javaee-spec/javadocs/package-list")
}
} }
jdkVersion = 8
externalDocumentationLink {
url = URL("https://javaee.github.io/javaee-spec/javadocs/")
packageListUrl = URL("https://javaee.github.io/javaee-spec/javadocs/package-list")
}
includes = listOf("config/dokka/packages.md")
includeNonPublic = false
} }
dependsOn(dokkaDocs) }
dokkaJavadoc {
dokkaSourceSets {
configureEach {
jdkVersion = 8
includes = listOf("config/dokka/packages.md")
externalDocumentationLink {
url = URL("https://javaee.github.io/javaee-spec/javadocs/")
packageListUrl = URL("https://javaee.github.io/javaee-spec/javadocs/package-list")
}
}
}
dependsOn(dokkaHtml)
} }
val copyToDeploy by registering(Copy::class) { val copyToDeploy by registering(Copy::class) {
from(configurations.runtime) { from(configurations.runtimeClasspath) {
exclude("annotations-*.jar") exclude("annotations-*.jar")
} }
from(jar) from(jar)
@ -261,7 +240,7 @@ bintray {
githubRepo = gitHub githubRepo = gitHub
githubReleaseNotesFile = "README.md" githubReleaseNotesFile = "README.md"
vcsUrl = "$mavenUrl.git" vcsUrl = "$mavenUrl.git"
setLabels("kotlin", "java", "akismet", "comments", "spam", "blog", "automattic", "kismet") setLabels("akismet", "android", "automattic", "blog", "comments", "java", "kismet", "kotlin", "spam")
setLicenses("BSD 3-Clause") setLicenses("BSD 3-Clause")
publicDownloadNumbers = true publicDownloadNumbers = true
version.apply { version.apply {

View file

@ -1,6 +1,6 @@
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.29.0"
application application
} }
@ -14,10 +14,6 @@ repositories {
} }
dependencies { dependencies {
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation(kotlin("stdlib"))
implementation("javax.servlet:javax.servlet-api:4.0.1") implementation("javax.servlet:javax.servlet-api:4.0.1")
implementation("net.thauvin.erik:akismet-kotlin:0.9.2") implementation("net.thauvin.erik:akismet-kotlin:0.9.2")

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

2
examples/gradlew vendored
View file

@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath

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-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

2
gradlew vendored
View file

@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath

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

@ -32,7 +32,6 @@
package net.thauvin.erik.akismet package net.thauvin.erik.akismet
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import net.thauvin.erik.semver.Version import net.thauvin.erik.semver.Version
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.HttpUrl import okhttp3.HttpUrl
@ -46,7 +45,7 @@ import java.time.OffsetDateTime
import java.time.ZoneId import java.time.ZoneId
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit import java.time.temporal.ChronoUnit
import java.util.Date import java.util.*
import java.util.logging.Level import java.util.logging.Level
import java.util.logging.Logger import java.util.logging.Logger
@ -65,7 +64,7 @@ open class Akismet(apiKey: String) {
*/ */
@JvmStatic @JvmStatic
fun jsonComment(json: String): AkismetComment { fun jsonComment(json: String): AkismetComment {
return Json(JsonConfiguration.Stable).parse(AkismetComment.serializer(), json) return Json.decodeFromString(AkismetComment.serializer(), json)
} }
/** /**

View file

@ -33,9 +33,14 @@
package net.thauvin.erik.akismet package net.thauvin.erik.akismet
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletRequest
import kotlin.collections.HashMap
import kotlin.collections.Map
import kotlin.collections.emptyMap
import kotlin.collections.iterator
import kotlin.collections.set
private fun String?.ifNull() = this ?: "" private fun String?.ifNull() = this ?: ""
@ -259,7 +264,7 @@ open class AkismetComment(val userIp: String, val userAgent: String) {
* @see [Akismet.jsonComment] * @see [Akismet.jsonComment]
*/ */
override fun toString(): String { override fun toString(): String {
return Json(JsonConfiguration.Stable).stringify(serializer(), this) return Json.encodeToString(this)
} }
/** /**

View file

@ -354,7 +354,7 @@ class AkismetTest {
@Test @Test
fun jsonCommentTest() { fun jsonCommentTest() {
val jsonComment = Akismet.jsonComment(mockComment.toString()) val jsonComment = Akismet.jsonComment(mockComment.toJson())
assertEquals(jsonComment, mockComment, "equals") assertEquals(jsonComment, mockComment, "equals")
assertEquals(jsonComment.hashCode(), mockComment.hashCode(), "hashcode") assertEquals(jsonComment.hashCode(), mockComment.hashCode(), "hashcode")