Skip to content

Commit 835e9ab

Browse files
Bump GE API spec version to 2024.1 (#172)
- Bump API spec version to 2024.0 - Bump library version to 2024.1.0 (next release) - Expose new `AuthApi` from library - Speed up integration test execution by requesting less builds
1 parent de97cca commit 835e9ab

File tree

9 files changed

+48
-31
lines changed

9 files changed

+48
-31
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,17 @@ dependencies {
6565
## Usage
6666

6767
The [`GradleEnterpriseApi`][9] interface represents the Gradle Enterprise REST API. It contains
68-
the 6 APIs exactly as listed in the [REST API Manual][5]:
68+
all the APIs exactly as listed in the [REST API Manual][5]:
6969

7070
```kotlin
7171
interface GradleEnterpriseApi {
7272
val buildsApi: BuildsApi
73-
val buildCacheApi: BuildCacheApi
74-
val projectsApi: projectsApi
7573
val testsApi: TestsApi
74+
val buildCacheApi: BuildCacheApi
75+
val projectsApi: ProjectsApi
7676
val metaApi: MetaApi
7777
val testDistributionApi: TestDistributionApi
78+
val authApi: AuthApi
7879
// ...
7980
}
8081
```

build-logic/src/main/kotlin/com/gabrielfeo/develocity-api-code-generation.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ plugins {
1111
val localSpecPath = providers.gradleProperty("localSpecPath")
1212
val remoteSpecUrl = providers.gradleProperty("remoteSpecUrl").orElse(
1313
providers.gradleProperty("gradle.enterprise.version").map { geVersion ->
14-
val specName = "gradle-enterprise-$geVersion-api.yaml"
14+
val majorVersion = geVersion.substringBefore('.').toInt()
15+
val specName = when {
16+
majorVersion <= 2023 -> "gradle-enterprise-$geVersion-api.yaml"
17+
else -> "develocity-$geVersion-api.yaml"
18+
}
1519
"https://docs.gradle.com/enterprise/api-manual/ref/$specName"
1620
}
1721
)
@@ -47,6 +51,7 @@ openApiGenerate {
4751
invokerPackage.set("com.gabrielfeo.gradle.enterprise.api.internal")
4852
additionalProperties.put("library", "jvm-retrofit2")
4953
additionalProperties.put("useCoroutines", true)
54+
cleanupOutput.set(true)
5055
}
5156

5257
val postProcessGeneratedApi by tasks.registering(PostProcessGeneratedApi::class) {

gradle.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
group=com.gabrielfeo
22
artifact=gradle-enterprise-api-kotlin
3-
version=2023.4.0
4-
gradle.enterprise.version=2023.4
3+
version=2024.1.0
4+
gradle.enterprise.version=2024.1
55
org.gradle.jvmargs=-Xmx5g
66
org.gradle.caching=true
77
# Becomes default in Gradle 9.0
88
org.gradle.kotlin.dsl.skipMetadataVersionCheck=false
9+
systemProp.scan.capture-build-logging=false
10+
systemProp.scan.capture-test-logging=false

library/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ tasks.named<Jar>("javadocJar") {
5252
}
5353

5454
tasks.named<Test>("integrationTest") {
55-
jvmArgs("-Xmx512m")
5655
environment("GRADLE_ENTERPRISE_API_LOG_LEVEL", "DEBUG")
5756
}
5857

library/src/integrationTest/kotlin/com/gabrielfeo/gradle/enterprise/api/extension/BuildsApiExtensionsIntegrationTest.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,32 @@ class BuildsApiExtensionsIntegrationTest {
2828
}
2929

3030
@Test
31-
fun getBuildsFlowPreservesParamsAcrossRequests() = runTest(timeout = 3.minutes) {
31+
fun getBuildsFlowPreservesParamsAcrossRequests() = runTest(timeout = 6.minutes) {
3232
api.buildsApi.getBuildsFlow(
3333
since = 0,
3434
query = "user:*",
3535
models = listOf(BuildModelName.gradleAttributes),
36+
allModels = true,
3637
reverse = true,
37-
).take(2000).collect()
38+
buildsPerPage = 2,
39+
).take(4).collect()
3840
recorder.requests.forEach {
3941
assertUrlParam(it, "query", "user:*")
4042
assertUrlParam(it, "models", "gradle-attributes")
43+
assertUrlParam(it, "allModels", "true")
4144
assertUrlParam(it, "reverse", "true")
4245
}
4346
}
4447

4548
@Test
4649
fun getBuildsFlowReplacesSinceForFromBuildAfterFirstRequest() = runTest {
47-
api.buildsApi.getBuildsFlow(since = 1).take(2000).collect()
50+
api.buildsApi.getBuildsFlow(since = 1, buildsPerPage = 2).take(10).collect()
4851
assertReplacedForFromBuildAfterFirstRequest(param = "since" to "1")
4952
}
5053

5154
@Test
5255
fun getBuildsFlowReplacesFromInstantForFromBuildAfterFirstRequest() = runTest {
53-
api.buildsApi.getBuildsFlow(fromInstant = 1).take(2000).collect()
56+
api.buildsApi.getBuildsFlow(fromInstant = 1, buildsPerPage = 2).take(10).collect()
5457
assertReplacedForFromBuildAfterFirstRequest(param = "fromInstant" to "1")
5558
}
5659

library/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/GradleEnterpriseApi.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import retrofit2.create
3434
*/
3535
interface GradleEnterpriseApi {
3636

37+
val authApi: AuthApi
3738
val buildsApi: BuildsApi
3839
val buildCacheApi: BuildCacheApi
3940
val projectsApi: ProjectsApi
@@ -79,6 +80,7 @@ internal class RealGradleEnterpriseApi(
7980
)
8081
}
8182

83+
override val authApi: AuthApi by lazy { retrofit.create() }
8284
override val buildsApi: BuildsApi by lazy { retrofit.create() }
8385
override val buildCacheApi: BuildCacheApi by lazy { retrofit.create() }
8486
override val projectsApi: ProjectsApi by lazy { retrofit.create() }

library/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/extension/BuildsApiExtensions.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fun BuildsApi.getBuildsFlow(
3333
maxWaitSecs: Int? = null,
3434
buildsPerPage: Int = API_MAX_BUILDS,
3535
models: List<BuildModelName>? = null,
36+
allModels: Boolean? = false,
3637
): Flow<Build> {
3738
return flow {
3839
var builds = getBuilds(
@@ -45,6 +46,7 @@ fun BuildsApi.getBuildsFlow(
4546
maxWaitSecs = maxWaitSecs,
4647
maxBuilds = buildsPerPage,
4748
models = models,
49+
allModels = allModels,
4850
)
4951
emitAll(builds.asFlow())
5052
while (builds.isNotEmpty()) {
@@ -55,6 +57,7 @@ fun BuildsApi.getBuildsFlow(
5557
maxWaitSecs = maxWaitSecs,
5658
maxBuilds = buildsPerPage,
5759
models = models,
60+
allModels = allModels,
5861
)
5962
emitAll(builds.asFlow())
6063
}

library/src/test/kotlin/com/gabrielfeo/gradle/enterprise/api/FakeBuildsApi.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class FakeBuildsApi(
2121
maxWaitSecs: Int?,
2222
query: String?,
2323
models: List<BuildModelName>?,
24+
allModels: Boolean?,
2425
): List<Build> {
2526
getBuildsCallCount.value++
2627
check((reverse ?: maxWaitSecs ?: query ?: models) == null) { "Not supported" }

library/src/testFixtures/kotlin/com/gabrielfeo/gradle/enterprise/api/FakeGradleEnterpriseApiScaffold.kt

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface FakeBuildsApiScaffold : BuildsApi {
1212
override suspend fun getBuild(
1313
id: String,
1414
models: List<BuildModelName>?,
15+
allModels: Boolean?,
1516
availabilityWaitTimeoutSecs: Int?,
1617
): Build {
1718
TODO("Not yet implemented")
@@ -27,49 +28,45 @@ interface FakeBuildsApiScaffold : BuildsApi {
2728
maxWaitSecs: Int?,
2829
query: String?,
2930
models: List<BuildModelName>?,
31+
allModels: Boolean?,
3032
): List<Build> {
3133
TODO("Not yet implemented")
3234
}
3335

34-
override suspend fun getGradleNetworkActivity(
36+
override suspend fun getGradleArtifactTransformExecutions(
3537
id: String,
3638
availabilityWaitTimeoutSecs: Int?,
37-
): GradleNetworkActivity {
39+
): GradleArtifactTransformExecutions {
3840
TODO("Not yet implemented")
3941
}
4042

41-
override suspend fun getMavenDependencyResolution(
42-
id: String,
43-
availabilityWaitTimeoutSecs: Int?,
44-
): MavenDependencyResolution {
43+
override suspend fun getGradleAttributes(id: String, availabilityWaitTimeoutSecs: Int?): GradleAttributes {
4544
TODO("Not yet implemented")
4645
}
4746

48-
override suspend fun getGradleAttributes(
47+
override suspend fun getGradleBuildCachePerformance(
4948
id: String,
5049
availabilityWaitTimeoutSecs: Int?,
51-
): GradleAttributes {
50+
): GradleBuildCachePerformance {
5251
TODO("Not yet implemented")
5352
}
5453

55-
override suspend fun getGradleBuildCachePerformance(
56-
id: String,
57-
availabilityWaitTimeoutSecs: Int?,
58-
): GradleBuildCachePerformance {
54+
override suspend fun getGradleDeprecations(id: String, availabilityWaitTimeoutSecs: Int?): GradleDeprecations {
5955
TODO("Not yet implemented")
6056
}
6157

62-
override suspend fun getGradleProjects(
58+
override suspend fun getGradleNetworkActivity(
6359
id: String,
6460
availabilityWaitTimeoutSecs: Int?,
65-
): List<GradleProject> {
61+
): GradleNetworkActivity {
6662
TODO("Not yet implemented")
6763
}
6864

69-
override suspend fun getMavenAttributes(
70-
id: String,
71-
availabilityWaitTimeoutSecs: Int?,
72-
): MavenAttributes {
65+
override suspend fun getGradleProjects(id: String, availabilityWaitTimeoutSecs: Int?): List<GradleProject> {
66+
TODO("Not yet implemented")
67+
}
68+
69+
override suspend fun getMavenAttributes(id: String, availabilityWaitTimeoutSecs: Int?): MavenAttributes {
7370
TODO("Not yet implemented")
7471
}
7572

@@ -80,10 +77,14 @@ interface FakeBuildsApiScaffold : BuildsApi {
8077
TODO("Not yet implemented")
8178
}
8279

83-
override suspend fun getMavenModules(
80+
override suspend fun getMavenDependencyResolution(
8481
id: String,
8582
availabilityWaitTimeoutSecs: Int?,
86-
): List<MavenModule> {
83+
): MavenDependencyResolution {
84+
TODO("Not yet implemented")
85+
}
86+
87+
override suspend fun getMavenModules(id: String, availabilityWaitTimeoutSecs: Int?): List<MavenModule> {
8788
TODO("Not yet implemented")
8889
}
8990
}

0 commit comments

Comments
 (0)