From bb00a79eaa2b6fc2d63ed10aa0550a34f47219fc Mon Sep 17 00:00:00 2001 From: Gabriel Feo Date: Tue, 23 May 2023 21:56:07 +0100 Subject: [PATCH 1/2] Update versions in examples --- .../MostFrequentBuilds.ipynb | 95 ++++++++++++++++++- examples/example-project/app/build.gradle.kts | 2 +- examples/example-script.main.kts | 5 +- 3 files changed, 96 insertions(+), 6 deletions(-) diff --git a/examples/example-notebooks/MostFrequentBuilds.ipynb b/examples/example-notebooks/MostFrequentBuilds.ipynb index 398837367..2c6b51602 100644 --- a/examples/example-notebooks/MostFrequentBuilds.ipynb +++ b/examples/example-notebooks/MostFrequentBuilds.ipynb @@ -52,7 +52,7 @@ "outputs": [], "source": [ "%useLatestDescriptors\n", - "%use gradle-enterprise-api-kotlin(version=0.15.1)\n", + "%use gradle-enterprise-api-kotlin(version=0.16.0)\n", "%use coroutines(v=1.7.1)" ] }, @@ -153,7 +153,7 @@ "\n", "val builds: List = runBlocking {\n", " val startMilli = startDate.atStartOfDay(ZoneId.of(\"UTC\")).toInstant().toEpochMilli()\n", - " GradleEnterprise.api.getGradleAttributesFlow(since = startMilli)\n", + " GradleEnterpriseApi.buildsApi.getGradleAttributesFlow(since = startMilli)\n", " .filter(buildFilter)\n", " .printProgress { i, build ->\n", " val buildDate = Instant.ofEpochMilli(build.buildStartTime).atOffset(ZoneOffset.UTC)\n", @@ -409,7 +409,96 @@ "outputs": [ { "data": { - "application/kotlindataframe+json": "{\"nrow\":682,\"ncol\":2,\"columns\":[\"tasks\",\"count\"],\"kotlin_dataframe\":[{\"tasks\":\"app:assembleBrazilDebug\",\"count\":3173},{\"tasks\":\"IDE sync\",\"count\":974},{\"tasks\":\"droid-cli:installDist\",\"count\":205},{\"tasks\":\"clean\",\"count\":147},{\"tasks\":\"feature:order-delivery:customer-satisfaction:impl:compileReleaseSources\",\"count\":92},{\"tasks\":\"infrastructure:design-system:compose:compileReleaseSources\",\"count\":85},{\"tasks\":\"app:assembleBrazilDebug :app:installBrazilDebug\",\"count\":54},{\"tasks\":\"build-plugins:functionalTest --tests rasp.AndroidRaspProtectionPluginTest\",\"count\":51},{\"tasks\":\"analytics-braze:testReleaseUnitTest --tests br.com.ifood.analytics.braze.AppBrazeAnalyticsProviderTest\",\"count\":44},{\"tasks\":\"feature:survey:impl:compileReleaseSources\",\"count\":44},{\"tasks\":\"clean app:assembleBrazilDebug\",\"count\":33},{\"tasks\":\"feature:voucher-android-training:impl:compileReleaseSources\",\"count\":31},{\"tasks\":\"feature:search:impl:compileReleaseSources\",\"count\":30},{\"tasks\":\"droid-cli:run --args ci run-jupyter-notebook\",\"count\":29},{\"tasks\":\"clean :feature:internal-settings:sample:assemble\",\"count\":27},{\"tasks\":\"clean :app:assembleBrazilDebug\",\"count\":24},{\"tasks\":\"protectArtifact\",\"count\":20},{\"tasks\":\"analytics-braze:testReleaseUnitTest --tests br.com.ifood.analytics.braze.AppBrazeAnalyticsProviderTest.sendEvent_featureFlagCanSendEvent_sendEvent\",\"count\":19},{\"tasks\":\"setupDependencies\",\"count\":19},{\"tasks\":\"feature:checkout:core:impl:testReleaseUnitTest --tests br.com.ifood.checkout.presentation.plugin.standard.delivery.DeliveryPluginViewModelTest\",\"count\":16}]}", + "application/kotlindataframe+json": { + "columns": [ + "tasks", + "count" + ], + "kotlin_dataframe": [ + { + "count": 3173, + "tasks": "app:assembleBrazilDebug" + }, + { + "count": 974, + "tasks": "IDE sync" + }, + { + "count": 205, + "tasks": "droid-cli:installDist" + }, + { + "count": 147, + "tasks": "clean" + }, + { + "count": 92, + "tasks": "feature:order-delivery:customer-satisfaction:impl:compileReleaseSources" + }, + { + "count": 85, + "tasks": "infrastructure:design-system:compose:compileReleaseSources" + }, + { + "count": 54, + "tasks": "app:assembleBrazilDebug :app:installBrazilDebug" + }, + { + "count": 51, + "tasks": "build-plugins:functionalTest --tests rasp.AndroidRaspProtectionPluginTest" + }, + { + "count": 44, + "tasks": "analytics-braze:testReleaseUnitTest --tests br.com.ifood.analytics.braze.AppBrazeAnalyticsProviderTest" + }, + { + "count": 44, + "tasks": "feature:survey:impl:compileReleaseSources" + }, + { + "count": 33, + "tasks": "clean app:assembleBrazilDebug" + }, + { + "count": 31, + "tasks": "feature:voucher-android-training:impl:compileReleaseSources" + }, + { + "count": 30, + "tasks": "feature:search:impl:compileReleaseSources" + }, + { + "count": 29, + "tasks": "droid-cli:run --args ci run-jupyter-notebook" + }, + { + "count": 27, + "tasks": "clean :feature:internal-settings:sample:assemble" + }, + { + "count": 24, + "tasks": "clean :app:assembleBrazilDebug" + }, + { + "count": 20, + "tasks": "protectArtifact" + }, + { + "count": 19, + "tasks": "analytics-braze:testReleaseUnitTest --tests br.com.ifood.analytics.braze.AppBrazeAnalyticsProviderTest.sendEvent_featureFlagCanSendEvent_sendEvent" + }, + { + "count": 19, + "tasks": "setupDependencies" + }, + { + "count": 16, + "tasks": "feature:checkout:core:impl:testReleaseUnitTest --tests br.com.ifood.checkout.presentation.plugin.standard.delivery.DeliveryPluginViewModelTest" + } + ], + "ncol": 2, + "nrow": 682 + }, "text/html": [ " \n", " \n", diff --git a/examples/example-project/app/build.gradle.kts b/examples/example-project/app/build.gradle.kts index e03ed0558..b8566c339 100644 --- a/examples/example-project/app/build.gradle.kts +++ b/examples/example-project/app/build.gradle.kts @@ -13,5 +13,5 @@ repositories { } dependencies { - implementation("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.15.1") + implementation("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.16.0") } diff --git a/examples/example-script.main.kts b/examples/example-script.main.kts index 855e5b0ee..fd5d31796 100644 --- a/examples/example-script.main.kts +++ b/examples/example-script.main.kts @@ -16,10 +16,11 @@ */ @file:Repository("https://jitpack.io") -@file:DependsOn("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.15.1") +@file:DependsOn("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.16.0") import com.gabrielfeo.gradle.enterprise.api.* import com.gabrielfeo.gradle.enterprise.api.model.* +import com.gabrielfeo.gradle.enterprise.api.extension.* import kotlinx.coroutines.* import kotlinx.coroutines.flow.* import java.time.* @@ -58,7 +59,7 @@ fun Flow.printProgress(produceMsg: (i: Int, current: T) -> String): Flow< // Fetch builds from the API val builds: List = runBlocking { val startMilli = startDate.atStartOfDay(ZoneId.of("UTC")).toInstant().toEpochMilli() - GradleEnterprise.api.getGradleAttributesFlow(since = startMilli) + GradleEnterpriseApi.buildsApi.getGradleAttributesFlow(since = startMilli) .filter(buildFilter) .printProgress { i, build -> val buildDate = Instant.ofEpochMilli(build.buildStartTime).atOffset(ZoneOffset.UTC) From 528b71583b60edc0d359c15555b16e42c1ca1421 Mon Sep 17 00:00:00 2001 From: Gabriel Feo Date: Tue, 23 May 2023 22:03:32 +0100 Subject: [PATCH 2/2] Add setup snippets --- README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d08b93022..c58750dd2 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,58 @@ That's it! You can now use the library without any code configuration from: - [Kotlin projects](./examples/example-project) - [Jupyter notebooks with the Kotlin kernel](./examples/example-notebooks) +### Setup snippets + +
+ Add to a Kotlin script + +```kotlin +@file:Repository("https://jitpack.io") +@file:DependsOn("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.16.0") +``` + +
+ +
+ Add to a Kotlin project + +Groovy + +```groovy +repositories { + maven { url = 'https://jitpack.io' } +} +dependencies { + implementation 'com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.16.0' +} +``` + +Kotlin + +```kotlin +repositories { + maven(url = "https://jitpack.io") +} +dependencies { + implementation("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.16.0") +} +``` + +
+ +
+ Add to a Jupyter notebook + +``` +%useLatestDescriptors +%use gradle-enterprise-api-kotlin(version=0.16.0) +``` + +
+ ## Usage -The [`GradleEnterpriseApi`][9] interface represents the Gradle Enterprise REST API. It contains +The [`GradleEnterpriseApi`][9] interface represents the Gradle Enterprise REST API. It contains the 4 APIs exactly as listed in the [REST API Manual][5]: ```kotlin @@ -63,7 +112,7 @@ finishes, as an [expected behavior of OkHttp][4]. ### Caching HTTP caching is available, which can speed up queries significantly, but is -off by default. Enable by simply setting [`GRADLE_ENTERPRISE_API_CACHE_ENABLED`][12] to `true`. See +off by default. Enable by simply setting [`GRADLE_ENTERPRISE_API_CACHE_ENABLED`][12] to `true`. See [`CacheConfig`][13] for caveats. ### Extensions @@ -71,10 +120,10 @@ off by default. Enable by simply setting [`GRADLE_ENTERPRISE_API_CACHE_ENABLED`] Explore the library's convenience extensions: [`com.gabrielfeo.gradle.enterprise.api.extension`][25]. -What you'll probably use the most is [`getGradleAttributesFlow`][24], which will call +What you'll probably use the most is [`getGradleAttributesFlow`][24], which will call `/api/builds` to get the list of build IDs since a given date and join each with -`/api/builds/{id}/gradle-attributes`, which contains tags and custom values on each build. It -also takes care of paging under-the-hood, returning a [`Flow`][26] of all builds since the given +`/api/builds/{id}/gradle-attributes`, which contains tags and custom values on each build. It +also takes care of paging under-the-hood, returning a [`Flow`][26] of all builds since the given date, so you don't have to worry about the REST API's limit of 1000 builds per request: ```kotlin @@ -88,14 +137,14 @@ builds.collect { [![Javadoc](https://img.shields.io/badge/javadoc-latest-orange)][7] -The javadoc of API interfaces and models, such as [`BuildsApi`][18] and [`GradleAttributes`][19], -matches the [REST API Manual][5] exactly. Both these classes and Gradle's own manual are generated +The javadoc of API interfaces and models, such as [`BuildsApi`][18] and [`GradleAttributes`][19], +matches the [REST API Manual][5] exactly. Both these classes and Gradle's own manual are generated from the same OpenAPI spec. ## Optional setup -Creating a custom [`Config`][8] allows you to change library settings via code instead of -environment variables. It also lets you share resource between the library's `OkHttpClient` and +Creating a custom [`Config`][8] allows you to change library settings via code instead of +environment variables. It also lets you share resource between the library's `OkHttpClient` and your own. For example: ```kotlin @@ -112,11 +161,11 @@ See the [`Config`][8] documentation for more. ## More info -- Currently built for Gradle Enterprise `2022.4`, but should work fine with previous and +- Currently built for Gradle Enterprise `2022.4`, but should work fine with previous and future versions. The library will be updated regularly for new API versions. - Use JDK 8 or 14+ to run, if you want to avoid the ["illegal reflective access" warning about Retrofit][3] -- All classes live in these packages. If you need to make small edits to scripts where there's +- All classes live in these packages. If you need to make small edits to scripts where there's no auto-complete, wildcard imports can be used: ```kotlin