Skip to content

Commit

Permalink
Fix build gradle (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
CustomEntity authored Aug 8, 2022
1 parent 2ffa773 commit 7dc5286
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/actions/snippets-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
95 changes: 32 additions & 63 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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 {
Expand All @@ -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<Test> {
this.testLogging {
this.showStandardStreams = true
}
}

tasks.withType<Jar> {
archiveFileName.set("${artifactName}-${artifactVersion}-without-dependencies.jar")
val javadocJar = tasks.named<Jar>("javadocJar") {
from(tasks.named("dokkaJavadoc"))
}

tasks.named<Jar>("jar") {
archiveClassifier.set("without-dependencies")
}

tasks {
register<Jar>("fatJar") {
archiveFileName.set("${artifactName}-${artifactVersion}.jar")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
named<ShadowJar>("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<Jar>("javadocJar") {
from(tasks.javadoc)
archiveClassifier.set("javadoc")
}

publishing {
repositories {
maven {
Expand All @@ -115,41 +113,13 @@ publishing {
}
}
publications {
create<MavenPublication>("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<MavenPublication>("kuzzle-sdk-jvm-fat") {
create<MavenPublication>("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 {
Expand Down Expand Up @@ -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"])
}
6 changes: 3 additions & 3 deletions doc/1/getting-started/java/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To build the project, add the following lines:
<dependency>
<groupId>io.kuzzle</groupId>
<artifactId>sdk-jvm</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<type>pom</type>
</dependency>
```
Expand All @@ -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
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.3.1'>
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.3.2'>
<artifact name='sdk-jvm' ext='pom' ></artifact>
</dependency>
```
Expand Down
6 changes: 3 additions & 3 deletions doc/1/getting-started/kotlin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ To build the project, add the following lines:
<dependency>
<groupId>io.kuzzle</groupId>
<artifactId>sdk-jvm</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<type>pom</type>
</dependency>
```
Expand All @@ -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
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.3.1'>
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.3.2'>
<artifact name='sdk-jvm' ext='pom' ></artifact>
</dependency>
```
Expand Down
16 changes: 14 additions & 2 deletions src/main/kotlin/io/kuzzle/sdk/protocol/Http.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class WebSocketTests {
val responseHeaders = headersOf("Content-Type" to listOf("application/json"))
respond("{}", headers = responseHeaders)
}

else -> error("Unhandled ${request.url.fullPath}")
}
}
Expand Down

0 comments on commit 7dc5286

Please sign in to comment.