Skip to content

Commit

Permalink
Merge pull request #9 from highmobility/remove-gildor
Browse files Browse the repository at this point in the history
Remove gildor
  • Loading branch information
tonisives authored Dec 14, 2022
2 parents 3c52b7a + edcfb8d commit 603ef23
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ owner package.

### Deployment

check `./gradle/deploy-ossrh.gradle`
check `./gradle/deploy-process.md`

### License

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=0.6.2
kotlin.code.style=official
kotlin.code.style=official
14 changes: 13 additions & 1 deletion gradle/deploy-process.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Public release

Release is done via Github actions. We increment release number manually and then create a tag which starts the release
action. We don't do automatic releases on every push in order to reduce release count if there are no real changes.

- update CHANGELOG.md
- merge a pull request
- update version and create a tag. use either of these
Expand All @@ -8,4 +13,11 @@
- **manually**
- update version in `$projectRoot/gradle.properties` and push tag manually
- create a release in GitHub. Package is pushed to OSSRH staging automatically.
- close and release manually in OSSRH staging.
- close and release manually in OSSRH staging.

## Make a test release locally to staging

- comment out line `useInMemoryPgpKeys(signingKey, signingPassword)` in deploy-ossrh.gradle
- Update version in `$projectRoot/gradle.properties` and call `./gradlew -Prelease :hmkit-fleet:publishToSonatype`.
- Don't merge test version names to main. Public versions are managed via Github Actions.
- Check the package in staging URL in OSSRH.
5 changes: 4 additions & 1 deletion hmkit-fleet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ compileTestKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_17
}

test {
testLogging.exceptionFormat = 'full'
}

// publish settings
apply from: "../gradle/deploy-ossrh.gradle"
apply from: "https://raw.githubusercontent.com/tonisives/tools/master/scripts/jupiter-test-shell-logging.gradle"
Expand All @@ -31,7 +35,6 @@ dependencies {

// web
implementation('com.squareup.okhttp3:okhttp:4.10.0')
implementation("ru.gildor.coroutines:kotlin-coroutines-okhttp:1.0")

// Koin
implementation "io.insert-koin:koin-core:$koinVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import org.slf4j.Logger
import ru.gildor.coroutines.okhttp.await
import utils.await
import java.net.HttpURLConnection

internal class AccessCertificateRequests(
Expand Down
2 changes: 1 addition & 1 deletion hmkit-fleet/src/main/kotlin/network/AccessTokenRequests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import org.slf4j.Logger
import ru.gildor.coroutines.okhttp.await
import utils.await
import java.net.HttpURLConnection

internal class AccessTokenRequests(
Expand Down
2 changes: 1 addition & 1 deletion hmkit-fleet/src/main/kotlin/network/AuthTokenRequests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import okhttp3.FormBody
import okhttp3.OkHttpClient
import okhttp3.Request
import org.slf4j.Logger
import ru.gildor.coroutines.okhttp.await
import utils.await
import java.net.HttpURLConnection

internal class AuthTokenRequests(
Expand Down
2 changes: 1 addition & 1 deletion hmkit-fleet/src/main/kotlin/network/ClearanceRequests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import org.slf4j.Logger
import ru.gildor.coroutines.okhttp.await
import utils.await
import java.net.HttpURLConnection

internal class ClearanceRequests(
Expand Down
2 changes: 1 addition & 1 deletion hmkit-fleet/src/main/kotlin/network/TelematicsRequests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import kotlinx.serialization.json.jsonPrimitive
import okhttp3.OkHttpClient
import okhttp3.Request
import org.slf4j.Logger
import ru.gildor.coroutines.okhttp.await
import utils.await
import java.net.HttpURLConnection

internal class TelematicsRequests(
Expand Down
34 changes: 34 additions & 0 deletions hmkit-fleet/src/main/kotlin/utils/CallAwait.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package utils

import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.suspendCancellableCoroutine
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Response
import java.io.IOException
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException

suspend fun Call.await(): Response {
return suspendCancellableCoroutine { continuation ->
enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) {
continuation.resume(response)
}

override fun onFailure(call: Call, e: IOException) {
// Don't bother with resuming the continuation if it is already cancelled.
if (continuation.isCancelled) return
continuation.resumeWithException(e)
}
})

continuation.invokeOnCancellation {
try {
cancel()
} catch (ex: Throwable) {
//Ignore cancel exception
}
}
}
}

0 comments on commit 603ef23

Please sign in to comment.