File tree Expand file tree Collapse file tree 4 files changed +22
-4
lines changed
src/main/kotlin/com/gabrielfeo/gradle/enterprise/api Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,25 @@ openApiGenerate {
3737 packageName.set(" com.gabrielfeo.gradle.enterprise.api.internal" )
3838 invokerPackage.set(" com.gabrielfeo.gradle.enterprise.api.internal" )
3939 additionalProperties.put(" library" , " jvm-retrofit2" )
40+ additionalProperties.put(" useCoroutines" , true )
41+ }
42+
43+ tasks.openApiGenerate.configure {
44+ // Replace Response<X> with X in every method return type of GradleEnterpriseApi.kt
45+ doLast {
46+ val apiFile = File (
47+ outputDir.get(),
48+ " src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/GradleEnterpriseApi.kt" ,
49+ )
50+ ant.withGroovyBuilder {
51+ " replaceregexp" (
52+ " file" to apiFile,
53+ " match" to " : Response<(.*?)>$" ,
54+ " replace" to """ : \1""" ,
55+ " flags" to " gm" ,
56+ )
57+ }
58+ }
4059}
4160
4261sourceSets {
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import kotlinx.coroutines.CoroutineScope
88import kotlinx.coroutines.DelicateCoroutinesApi
99import kotlinx.coroutines.GlobalScope
1010import kotlinx.coroutines.flow.*
11- import retrofit2.await
1211
1312/* *
1413 * Gets builds on demand from the API, in as many requests as necessary. It allows
@@ -31,7 +30,7 @@ fun GradleEnterpriseApi.getBuildsFlow(
3130 fromInstant = fromInstant,
3231 fromBuild = fromBuild,
3332 maxBuilds = API_MAX_BUILDS ,
34- ).await()
33+ )
3534 val pagedBuilds = firstBuilds.asFlow().pagedUntilLastBuild(maxPerRequest = API_MAX_BUILDS )
3635 emitAll(pagedBuilds)
3736}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ internal fun Flow<Build>.pagedUntilLastBuild(
2323 if (lastBuildId.isEmpty()) {
2424 return @flow
2525 } else while (true ) {
26- val builds = api.getBuilds(fromBuild = lastBuildId, maxBuilds = maxPerRequest).await()
26+ val builds = api.getBuilds(fromBuild = lastBuildId, maxBuilds = maxPerRequest)
2727 emitAll(builds.asFlow())
2828 when {
2929 builds.isEmpty() || builds.size < API_MAX_BUILDS -> break
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ internal fun Flow<Build>.withGradleAttributes(
1818): Flow <Pair <Build , GradleAttributes >> =
1919 map { build ->
2020 build to scope.async {
21- api.getGradleAttributes(build.id).await()
21+ api.getGradleAttributes(build.id)
2222 }
2323 }.buffer(Int .MAX_VALUE ).map { (build, attrs) ->
2424 build to attrs.await()
You can’t perform that action at this time.
0 commit comments