Skip to content

Commit 76123c3

Browse files
haroldadminLeandro
andauthored
v5: Sealed interfaces, Raw Retrofit Responses, Kotest Migration, Kotlin 1.6.0 (#50)
* Implement sealed interfaces Sealed interfaces allow for exhaustive when expressions evaluating only Success and Error. * Simplify types * fix: Remove deprecated adapter and factory * feat: Switch to sealed interfaces based implementation * feat: Modify generic type parameters to be more convenient on NetworkResponse * feat: Add sample app module using kotlinx.serialization * fix: Remove workaround for status code 204 * fix: Update Python dependencies for mkdocs * feat: Refactor NetworkResponse to have backward compatible names Other changes: - Improve documentation on the public API surface - Implement OkHttp timeout for faster test execution - Add tests for successful responses with errors during body deserialization - Add CompletableResponse type alias for NetworkResponse<Unit, E> * feat: Update dokka config * fix: Cleanup build config * fix: Mark NetworkResponse.Success as a data class * fix: Remove unneeded lint suppressor * fix: Specify explicit version constraints for mkdocs and mkdocs-material Co-authored-by: Leandro <[email protected]>
1 parent ed86c0e commit 76123c3

39 files changed

+1393
-1331
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="NetworkResponseAdapter [format]" type="GradleRunConfiguration" factoryName="Gradle">
3+
<ExternalSystemSettings>
4+
<option name="executionName" />
5+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
6+
<option name="externalSystemIdString" value="GRADLE" />
7+
<option name="scriptParameters" value="ktlintFormat" />
8+
<option name="taskDescriptions">
9+
<list />
10+
</option>
11+
<option name="taskNames">
12+
<list />
13+
</option>
14+
<option name="vmOptions" />
15+
</ExternalSystemSettings>
16+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
17+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
18+
<DebugAllEnabled>false</DebugAllEnabled>
19+
<method v="2" />
20+
</configuration>
21+
</component>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="NetworkResponseAdapter [lint]" type="GradleRunConfiguration" factoryName="Gradle">
3+
<ExternalSystemSettings>
4+
<option name="executionName" />
5+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
6+
<option name="externalSystemIdString" value="GRADLE" />
7+
<option name="scriptParameters" value="ktlintCheck" />
8+
<option name="taskDescriptions">
9+
<list />
10+
</option>
11+
<option name="taskNames">
12+
<list />
13+
</option>
14+
<option name="vmOptions" />
15+
</ExternalSystemSettings>
16+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
17+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
18+
<DebugAllEnabled>false</DebugAllEnabled>
19+
<method v="2" />
20+
</configuration>
21+
</component>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="NetworkResponseAdapter [test]" type="GradleRunConfiguration" factoryName="Gradle">
3+
<ExternalSystemSettings>
4+
<option name="executionName" />
5+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
6+
<option name="externalSystemIdString" value="GRADLE" />
7+
<option name="scriptParameters" value="test" />
8+
<option name="taskDescriptions">
9+
<list />
10+
</option>
11+
<option name="taskNames">
12+
<list />
13+
</option>
14+
<option name="vmOptions" />
15+
</ExternalSystemSettings>
16+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
17+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
18+
<DebugAllEnabled>false</DebugAllEnabled>
19+
<method v="2" />
20+
</configuration>
21+
</component>

build.gradle.kts

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,68 @@
1+
import org.jlleitschuh.gradle.ktlint.KtlintExtension
2+
13
plugins {
2-
kotlin("jvm") version "1.5.20"
3-
id("org.jetbrains.dokka") version "1.4.32"
4+
kotlin("jvm") version "1.6.0"
5+
id("org.jetbrains.dokka") version "1.6.0"
6+
id("org.jlleitschuh.gradle.ktlint") version "10.2.0"
47
`maven-publish`
58
}
69

10+
val GroupID = "com.github.haroldadmin"
11+
val ArtifactID = "NetworkResponseAdapter"
12+
val ProjectName = "NetworkResponseAdapter"
13+
val ProjectVersion = "5.0.0"
14+
715
repositories {
8-
mavenCentral()
16+
mavenCentral()
17+
}
18+
19+
kotlin {
20+
explicitApi()
921
}
1022

1123
val test by tasks.getting(Test::class) {
1224
useJUnitPlatform()
1325
}
1426

27+
configure<KtlintExtension> {
28+
version.set("0.43.0")
29+
ignoreFailures.set(false)
30+
disabledRules.set(setOf("no-wildcard-imports"))
31+
}
32+
1533
publishing {
1634
publications {
1735
create<MavenPublication>("NetworkResponseAdapter") {
18-
groupId = "com.github.haroldadmin"
19-
artifactId = "NetworkResponseAdapter"
20-
version = "4.2.2"
36+
groupId = GroupID
37+
artifactId = ArtifactID
38+
version = ProjectVersion
2139

2240
from(components["java"])
2341
}
2442
}
2543
}
2644

2745
dependencies {
28-
val coroutinesVersion = "1.5.0"
46+
val coroutinesVersion = "1.5.2"
2947
val retrofitVersion = "2.9.0"
30-
val okHttpVersion = "4.9.1"
48+
val okHttpVersion = "4.9.3"
49+
val kotestVersion = "5.0.1"
3150

3251
api("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
3352
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
3453
api("com.squareup.retrofit2:retrofit:$retrofitVersion")
3554
api("com.squareup.okhttp3:okhttp:$okHttpVersion")
3655

3756
testImplementation("com.squareup.okhttp3:mockwebserver:$okHttpVersion")
38-
testImplementation("com.google.guava:guava:26.0-jre")
39-
testImplementation("io.kotlintest:kotlintest-runner-junit5:3.3.2")
40-
testImplementation("com.squareup.moshi:moshi-kotlin:1.9.2")
57+
testImplementation("com.google.guava:guava:31.0.1-jre")
58+
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
59+
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
60+
testImplementation("com.squareup.moshi:moshi-kotlin:1.12.0")
4161
testImplementation("com.squareup.retrofit2:converter-moshi:$retrofitVersion")
4262
}
4363

4464
tasks.dokkaGfm.configure {
65+
moduleName.set(ProjectName)
66+
moduleVersion.set(ProjectVersion)
4567
outputDirectory.set(buildDir.resolve("dokka"))
46-
}
68+
}

docs/Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
mkdocs = "*"
8-
mkdocs-material = "*"
7+
mkdocs = "~=1.2.3"
8+
mkdocs-material = "~=8.1.0"
99

1010
[dev-packages]
1111

0 commit comments

Comments
 (0)