diff --git a/.github/actions/snippets-tests/action.yml b/.github/actions/snippets-tests/action.yml index 95ce4828..415b3a77 100644 --- a/.github/actions/snippets-tests/action.yml +++ b/.github/actions/snippets-tests/action.yml @@ -8,7 +8,7 @@ runs: java-version: "11" architecture: x64 - name: Build - run: ./gradlew build fatJar + run: ./gradlew build shadowJar shell: bash - name: Launch Tests run: docker-compose -f .ci/doc/docker-compose.yml run doc-tests index diff --git a/build.gradle.kts b/build.gradle.kts index 8cb8e220..c448e5bc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,5 @@ import org.gradle.jvm.tasks.Jar -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.util.Date -import org.gradle.api.publish.maven.MavenPom -import org.jetbrains.kotlin.gradle.dsl.Coroutines -import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { application @@ -12,11 +8,13 @@ plugins { signing jacoco kotlin("jvm") version "1.6.10" + id("com.github.johnrengelman.shadow") version "7.1.2" + id("org.jetbrains.dokka") version "1.7.10" } val artifactName = "sdk-jvm" val artifactGroup = "io.kuzzle" -val artifactVersion = "1.3.1" +val artifactVersion = "1.3.2" val pomUrl = "https://github.com/kuzzleio/sdk-jvm" val pomScmUrl = "https://github.com/kuzzleio/sdk-jvm" @@ -35,7 +33,7 @@ val pomDeveloperId = "kuzzleio" val pomDeveloperName = "kuzzle" group = "io.kuzzle.sdk" -version = "1.3.1" +version = "1.3.2" val ktorVersion = "1.6.8" repositories { @@ -60,50 +58,50 @@ dependencies { implementation("com.google.code.gson:gson:2.9.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit") - testImplementation("io.mockk:mockk:1.8.13") - testImplementation("io.ktor:ktor-client-mock:1.3.1") + testImplementation("io.mockk:mockk:1.12.4") + testImplementation("io.ktor:ktor-client-mock:$ktorVersion") testImplementation("io.ktor:ktor-client-mock-jvm:$ktorVersion") testImplementation("io.ktor:ktor-client-json-jvm:$ktorVersion") testImplementation("io.ktor:ktor-client-mock-js:1.3.1") testImplementation("io.ktor:ktor-client-mock-native:1.3.1") testImplementation("org.mock-server:mockserver-netty:5.3.0") - testImplementation("io.cucumber:cucumber-java8:7.0.0") - testImplementation("io.cucumber:cucumber-junit:7.0.0") + testImplementation("io.cucumber:cucumber-java8:7.3.3") + testImplementation("io.cucumber:cucumber-junit:7.3.3") +} + +application { + mainClass.set("io.kuzzle.sdk.protocol") } java { + withJavadocJar() withSourcesJar() } -application { - mainClassName = "io.kuzzle.sdk.protocol" +tasks.withType { + this.testLogging { + this.showStandardStreams = true + } } -tasks.withType { - archiveFileName.set("${artifactName}-${artifactVersion}-without-dependencies.jar") +val javadocJar = tasks.named("javadocJar") { + from(tasks.named("dokkaJavadoc")) +} + +tasks.named("jar") { + archiveClassifier.set("without-dependencies") } tasks { - register("fatJar") { - archiveFileName.set("${artifactName}-${artifactVersion}.jar") - duplicatesStrategy = DuplicatesStrategy.EXCLUDE + named("shadowJar") { + archiveClassifier.set("") + archiveBaseName.set(artifactName) manifest { - attributes("Main-Class" to application.mainClassName) + attributes(mapOf("Main-Class" to application.mainClass.get())) } - from(configurations.runtimeClasspath.get() - .onEach { println("Add from dependencies: ${it.name}") } - .map { if (it.isDirectory) it else zipTree(it) }) - val sourcesMain = sourceSets.main.get() - sourcesMain.allSource.forEach { println("Add from sources: ${it.name}") } - from(sourcesMain.output) } } -tasks.register("javadocJar") { - from(tasks.javadoc) - archiveClassifier.set("javadoc") -} - publishing { repositories { maven { @@ -115,41 +113,13 @@ publishing { } } publications { - create("kuzzle-sdk-jvm-thin") { - groupId = artifactGroup - artifactId = artifactName - version = "${artifactVersion}-without-dependencies" - artifact(tasks["sourcesJar"]) - artifact(tasks["javadocJar"]) - - from(components["java"]) - pom.withXml { - asNode().apply { - appendNode("description", pomDesc) - appendNode("name", rootProject.name) - appendNode("url", pomUrl) - appendNode("licenses").appendNode("license").apply { - appendNode("name", pomLicenseName) - appendNode("url", pomLicenseUrl) - appendNode("distribution", pomLicenseDist) - } - appendNode("developers").appendNode("developer").apply { - appendNode("id", pomDeveloperId) - appendNode("name", pomDeveloperName) - } - appendNode("scm").apply { - appendNode("url", pomScmUrl) - appendNode("connection", pomScmConnection) - } - } - } - } - create("kuzzle-sdk-jvm-fat") { + create("kuzzle-sdk-jvm") { groupId = artifactGroup artifactId = artifactName version = artifactVersion - artifact(tasks["fatJar"]) + artifact(tasks["jar"]) artifact(tasks["sourcesJar"]) + artifact(tasks["shadowJar"]) artifact(tasks["javadocJar"]) pom.withXml { @@ -178,6 +148,5 @@ publishing { signing { useInMemoryPgpKeys(System.getenv("MAVEN_CENTRAL_GPG"), System.getenv("MAVEN_CENTRAL_GPG_PASSWORD")) - sign(publishing.publications["kuzzle-sdk-jvm-thin"]) - sign(publishing.publications["kuzzle-sdk-jvm-fat"]) + sign(publishing.publications["kuzzle-sdk-jvm"]) } \ No newline at end of file diff --git a/doc/1/getting-started/java/index.md b/doc/1/getting-started/java/index.md index d09928e4..1a921f94 100644 --- a/doc/1/getting-started/java/index.md +++ b/doc/1/getting-started/java/index.md @@ -61,7 +61,7 @@ To build the project, add the following lines: io.kuzzle sdk-jvm - 1.3.1 + 1.3.2 pom ``` @@ -70,14 +70,14 @@ To build the project, add the following lines: ```groovy dependencies { - compile 'io.kuzzle:sdk-jvm:1.3.1' + compile 'io.kuzzle:sdk-jvm:1.3.2' } ``` ### Ivy ```html - + ``` diff --git a/doc/1/getting-started/kotlin/index.md b/doc/1/getting-started/kotlin/index.md index 7e3f9aa9..23da68e6 100644 --- a/doc/1/getting-started/kotlin/index.md +++ b/doc/1/getting-started/kotlin/index.md @@ -73,7 +73,7 @@ To build the project, add the following lines: io.kuzzle sdk-jvm - 1.3.1 + 1.3.2 pom ``` @@ -82,14 +82,14 @@ To build the project, add the following lines: ```groovy dependencies { - compile 'io.kuzzle:sdk-jvm:1.3.1' + compile 'io.kuzzle:sdk-jvm:1.3.2' } ``` ### Ivy ```html - + ``` diff --git a/src/main/kotlin/io/kuzzle/sdk/protocol/Http.kt b/src/main/kotlin/io/kuzzle/sdk/protocol/Http.kt index 2bc4ffb7..a89aee67 100644 --- a/src/main/kotlin/io/kuzzle/sdk/protocol/Http.kt +++ b/src/main/kotlin/io/kuzzle/sdk/protocol/Http.kt @@ -223,7 +223,13 @@ open class Http : AbstractProtocol { this.body = JsonSerializer.serialize(payload) } // trigger messageReceived - super.trigger(MessageReceivedEvent(response.receive(), payload["requestId"] as String?, response.headers.toMap())) + super.trigger( + MessageReceivedEvent( + response.receive(), + payload["requestId"] as String?, + response.headers.toMap() + ) + ) } catch (e: Exception) { super.trigger(RequestErrorEvent(e, payload["requestId"] as String?)) } finally { @@ -254,7 +260,13 @@ open class Http : AbstractProtocol { this.body = if (requestInfo.body != null) JsonSerializer.serialize(requestInfo.body) else "" } // trigger messageReceived - super.trigger(MessageReceivedEvent(response.receive(), payload["requestId"] as String?, response.headers.toMap())) + super.trigger( + MessageReceivedEvent( + response.receive(), + payload["requestId"] as String?, + response.headers.toMap() + ) + ) } catch (e: Exception) { super.trigger(RequestErrorEvent(e, payload["requestId"] as String?)) } finally { diff --git a/src/test/kotlin/io/kuzzle/sdk/protocolTest/WebSocketTests.kt b/src/test/kotlin/io/kuzzle/sdk/protocolTest/WebSocketTests.kt index ab89e502..d9bbf8e0 100644 --- a/src/test/kotlin/io/kuzzle/sdk/protocolTest/WebSocketTests.kt +++ b/src/test/kotlin/io/kuzzle/sdk/protocolTest/WebSocketTests.kt @@ -40,6 +40,7 @@ class WebSocketTests { val responseHeaders = headersOf("Content-Type" to listOf("application/json")) respond("{}", headers = responseHeaders) } + else -> error("Unhandled ${request.url.fullPath}") } }