diff --git a/.idea/kotlinScripting.xml b/.idea/kotlinScripting.xml
new file mode 100644
index 0000000..bc444de
--- /dev/null
+++ b/.idea/kotlinScripting.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index ed596cc..21dd7bb 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
# [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)
diff --git a/build.gradle.kts b/build.gradle.kts
index 1e47788..30ce289 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,23 +1,21 @@
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.net.URL
-import java.util.Date
-import java.util.Properties
+import java.util.*
plugins {
jacoco
java
`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("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("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.kotlin.plugin.serialization") 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.jetbrains.kotlin.plugin.serialization") version "1.4.0"
id("org.sonarqube") version "3.0"
}
@@ -34,7 +32,7 @@ var semverProcessor = "net.thauvin.erik:semver:1.2.0"
val publicationName = "mavenJava"
object VersionInfo {
- const val okhttp = "4.7.2"
+ const val okhttp = "4.8.1"
}
val versions: VersionInfo by extra { VersionInfo }
@@ -66,12 +64,9 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp:${versions.okhttp}")
implementation("com.squareup.okhttp3:logging-interceptor:${versions.okhttp}")
- // Align versions of all Kotlin components
- implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
- implementation(kotlin("stdlib"))
- 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")
+ implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc-218")
+ testImplementation("org.mockito:mockito-core:3.5.0")
+ testImplementation("org.testng:testng:7.3.0")
}
kapt {
@@ -81,9 +76,7 @@ kapt {
}
detekt {
- //input = files("src/main/kotlin", "src/test/kotlin")
- //filters = ".*/resources/.*,.*/build/.*"
- baseline = project.rootDir.resolve("detekt-baseline.xml")
+ baseline = project.rootDir.resolve("config/detekt/baseline.xml")
}
jacoco {
@@ -108,37 +101,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
-
- 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 {
withType {
useTestNG()
@@ -169,32 +138,42 @@ tasks {
}
}
- dokka {
- outputFormat = "html"
- outputDirectory = "$buildDir/javadoc"
+ dokkaHtml {
+ outputDirectory = "$projectDir/docs"
- configuration {
- 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"
+ dokkaSourceSets {
+ configureEach {
+ jdkVersion = 8
+ includes = listOf("config/dokka/packages.md")
+ 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) {
- from(configurations.runtime) {
+ from(configurations.runtimeClasspath) {
exclude("annotations-*.jar")
}
from(jar)
@@ -261,7 +240,7 @@ bintray {
githubRepo = gitHub
githubReleaseNotesFile = "README.md"
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")
publicDownloadNumbers = true
version.apply {
diff --git a/detekt-baseline.xml b/config/detekt/baseline.xml
similarity index 100%
rename from detekt-baseline.xml
rename to config/detekt/baseline.xml
diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts
index a45bf50..73c05c3 100644
--- a/examples/build.gradle.kts
+++ b/examples/build.gradle.kts
@@ -1,6 +1,6 @@
plugins {
- id("org.jetbrains.kotlin.jvm") version "1.3.72"
- id("com.github.ben-manes.versions") version "0.28.0"
+ id("org.jetbrains.kotlin.jvm") version "1.4.0"
+ id("com.github.ben-manes.versions") version "0.29.0"
application
}
@@ -14,10 +14,6 @@ repositories {
}
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("net.thauvin.erik:akismet-kotlin:0.9.2")
diff --git a/examples/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/wrapper/gradle-wrapper.jar
index 62d4c05..e708b1c 100644
Binary files a/examples/gradle/wrapper/gradle-wrapper.jar and b/examples/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties
index 622ab64..6c9a224 100644
--- a/examples/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/gradle/wrapper/gradle-wrapper.properties
@@ -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
diff --git a/examples/gradlew b/examples/gradlew
index fbd7c51..4f906e0 100644
--- a/examples/gradlew
+++ b/examples/gradlew
@@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
+
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
diff --git a/examples/gradlew.bat b/examples/gradlew.bat
index 5093609..107acd3 100644
--- a/examples/gradlew.bat
+++ b/examples/gradlew.bat
@@ -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
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 62d4c05..e708b1c 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 622ab64..6c9a224 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -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
diff --git a/gradlew b/gradlew
index fbd7c51..4f906e0 100755
--- a/gradlew
+++ b/gradlew
@@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
+
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
diff --git a/gradlew.bat b/gradlew.bat
index 5093609..107acd3 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -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
diff --git a/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt b/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt
index 9a150a7..4709cb0 100644
--- a/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt
+++ b/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt
@@ -32,7 +32,6 @@
package net.thauvin.erik.akismet
import kotlinx.serialization.json.Json
-import kotlinx.serialization.json.JsonConfiguration
import net.thauvin.erik.semver.Version
import okhttp3.FormBody
import okhttp3.HttpUrl
@@ -46,7 +45,7 @@ import java.time.OffsetDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
-import java.util.Date
+import java.util.*
import java.util.logging.Level
import java.util.logging.Logger
@@ -65,7 +64,7 @@ open class Akismet(apiKey: String) {
*/
@JvmStatic
fun jsonComment(json: String): AkismetComment {
- return Json(JsonConfiguration.Stable).parse(AkismetComment.serializer(), json)
+ return Json.decodeFromString(AkismetComment.serializer(), json)
}
/**
diff --git a/src/main/kotlin/net/thauvin/erik/akismet/AkismetComment.kt b/src/main/kotlin/net/thauvin/erik/akismet/AkismetComment.kt
index c6d5b29..49f765c 100644
--- a/src/main/kotlin/net/thauvin/erik/akismet/AkismetComment.kt
+++ b/src/main/kotlin/net/thauvin/erik/akismet/AkismetComment.kt
@@ -33,9 +33,14 @@
package net.thauvin.erik.akismet
import kotlinx.serialization.Serializable
+import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
-import kotlinx.serialization.json.JsonConfiguration
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 ?: ""
@@ -259,7 +264,7 @@ open class AkismetComment(val userIp: String, val userAgent: String) {
* @see [Akismet.jsonComment]
*/
override fun toString(): String {
- return Json(JsonConfiguration.Stable).stringify(serializer(), this)
+ return Json.encodeToString(this)
}
/**
diff --git a/src/test/kotlin/net/thauvin/erik/akismet/AkismetTest.kt b/src/test/kotlin/net/thauvin/erik/akismet/AkismetTest.kt
index ab542d3..c18598e 100644
--- a/src/test/kotlin/net/thauvin/erik/akismet/AkismetTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/akismet/AkismetTest.kt
@@ -354,7 +354,7 @@ class AkismetTest {
@Test
fun jsonCommentTest() {
- val jsonComment = Akismet.jsonComment(mockComment.toString())
+ val jsonComment = Akismet.jsonComment(mockComment.toJson())
assertEquals(jsonComment, mockComment, "equals")
assertEquals(jsonComment.hashCode(), mockComment.hashCode(), "hashcode")