Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated gradle data capturing samples to Develocity #1325

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Set Maven version
if: ${{ matrix.versions.version != '(Current)' }}
working-directory: convention-develocity-maven-extension/examples/maven_${{ matrix.versions.sample }}
run: ./mvnw wrapper:wrapper -Dmaven=${{ matrix.versions.version }} -Dgradle.enterprise.url=https://ge.solutions-team.gradle.com
run: ./mvnw wrapper:wrapper -Dmaven=${{ matrix.versions.version }} -Ddevelocity.url=https://ge.solutions-team.gradle.com
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_SOLUTIONS_ACCESS_TOKEN }}
- name: Verify example build
Expand Down
2 changes: 1 addition & 1 deletion build-data-capturing-gradle-samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This directory contains samples demonstrating various ways to extend and customi
tags, links, and custom values.

To learn more, see the Develocity documentation
on [Extending build scans](https://docs.gradle.com/enterprise/gradle-plugin/#extending_build_scans).
on [Extending build scans](https://docs.gradle.com/develocity/gradle-plugin/current/#extending_build_scans).

### Capture Develocity Plugin Version

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration

/**
* This Kotlin script captures the Develocity Gradle plugin version as a custom value.
*/
project.extensions.configure<GradleEnterpriseExtension>() {

project.extensions.configure<DevelocityConfiguration> {
buildScan {
val url = GradleEnterpriseExtension::class.java.classLoader.getResource("com.gradle.scan.plugin.internal.meta.buildAgentVersion.txt")
val url = DevelocityConfiguration::class.java.classLoader.getResource("com.gradle.scan.plugin.internal.meta.buildAgentVersion.txt")
val buildAgentVersion = url.readText()
value("Develocity Gradle plugin version", buildAgentVersion)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.scan.plugin.BuildScanExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import com.gradle.develocity.agent.gradle.scan.BuildScanConfiguration
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper

Expand All @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit
* See https://docs.github.com/en/rest/gists/gists#create-a-gist for reference.
*/

project.extensions.configure<GradleEnterpriseExtension>() {
project.extensions.configure<DevelocityConfiguration> {

val capture = Capture(gradle.startParameter.isOffline,
gradle.startParameter.isContinuous,
Expand Down Expand Up @@ -49,7 +49,7 @@ class Capture(val offline: Boolean,
return true
}

fun captureGitDiffInGist(api: BuildScanExtension) {
fun captureGitDiffInGist(api: BuildScanConfiguration) {
val hasCredentials = gistTokenProvider.isPresent
if (!hasCredentials) {
logger.warn("User has not set 'gistToken'. Cannot publish gist.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration

project.extensions.configure<GradleEnterpriseExtension>() {
project.extensions.configure<DevelocityConfiguration>() {
buildScan {
allprojects {
tasks.withType<Test>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.scan.plugin.BuildScanExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import com.gradle.develocity.agent.gradle.scan.BuildScanConfiguration
import java.nio.charset.Charset
import java.util.concurrent.TimeUnit

Expand All @@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit
* and adds these as a custom value.
*/

project.extensions.configure<GradleEnterpriseExtension>() {
project.extensions.configure<DevelocityConfiguration>() {
buildScan {
background {
Capture.captureOsProcesses(buildScan)
Expand All @@ -18,7 +18,7 @@ project.extensions.configure<GradleEnterpriseExtension>() {

class Capture {
companion object {
fun captureOsProcesses(api: BuildScanExtension) {
fun captureOsProcesses(api: BuildScanConfiguration) {
val psOutput = execAndGetStdout("ps", "-o pid,ppid,time,command")
api.value("OS processes", psOutput)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.scan.plugin.BuildScanExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import com.gradle.develocity.agent.gradle.scan.BuildScanConfiguration
import java.nio.charset.Charset
import java.util.concurrent.TimeUnit

Expand All @@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit
* and adds these as a custom value.
*/

project.extensions.configure<GradleEnterpriseExtension>() {
project.extensions.configure<DevelocityConfiguration>() {
buildScan {
background {
Capture.captureProcessorArch(buildScan)
Expand All @@ -18,7 +18,7 @@ project.extensions.configure<GradleEnterpriseExtension>() {

class Capture {
companion object {
fun captureProcessorArch(api: BuildScanExtension) {
fun captureProcessorArch(api: BuildScanConfiguration) {
val osName = System.getProperty("os.name")
api.value("os.name", osName)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.scan.plugin.BuildScanExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import groovy.xml.XmlSlurper
import groovy.xml.slurpersupport.Node
import groovy.xml.slurpersupport.NodeChild
import groovy.xml.slurpersupport.NodeChildren
import groovy.xml.slurpersupport.GPathResult

/**
* This Gradle script captures issues found by reporting tasks,
* and adds these as custom values.
*/

project.extensions.configure<GradleEnterpriseExtension>() {
project.extensions.configure<DevelocityConfiguration>() {
buildScan {
gradle.taskGraph.beforeTask {
if (this.reportingSupported && this is Reporting<*>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.scan.plugin.BuildScanExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import com.gradle.develocity.agent.gradle.scan.BuildScanConfiguration

/**
* This Gradle script captures all tasks of a given type taking longer to execute than a certain threshold,
* and adds these as custom values.
*/

project.extensions.configure<GradleEnterpriseExtension>() {
project.extensions.configure<DevelocityConfiguration>() {
buildScan {
val THRESHOLD_MILLIS = 15 * 60 * 1000 // 15 min
val api = buildScan
Expand All @@ -29,7 +29,7 @@ project.extensions.configure<GradleEnterpriseExtension>() {

class Capture {
companion object {
fun addbuildScanValue(api: BuildScanExtension, key: String, value: String) {
fun addbuildScanValue(api: BuildScanConfiguration, key: String, value: String) {
api.value(key, value)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.scan.plugin.BuildScanExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import com.gradle.develocity.agent.gradle.scan.BuildScanConfiguration
import java.nio.charset.StandardCharsets
import java.security.MessageDigest

Expand All @@ -8,7 +8,7 @@ import java.security.MessageDigest
* and adds these as custom values.
*/

project.extensions.configure<GradleEnterpriseExtension>() {
project.extensions.configure<DevelocityConfiguration>() {
buildScan {
val api = buildScan
allprojects {
Expand All @@ -25,7 +25,7 @@ class Capture {
companion object {
val MESSAGE_DIGEST = MessageDigest.getInstance("SHA-256")

fun addbuildScanValue(api: BuildScanExtension, key: String, value: Any?) {
fun addbuildScanValue(api: BuildScanConfiguration, key: String, value: Any?) {
api.value(key, hash(value))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.scan.plugin.BuildScanExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import com.gradle.develocity.agent.gradle.scan.BuildScanConfiguration
import org.gradle.util.internal.VersionNumber
import java.nio.charset.StandardCharsets
import java.util.Collections
Expand All @@ -14,7 +14,7 @@ import groovy.transform.Field
* adding a flag as custom value.
*/

project.extensions.configure<GradleEnterpriseExtension>() {
project.extensions.configure<DevelocityConfiguration>() {
buildScan {
val api = buildScan
val capture = Capture(api, gradle.rootProject.logger)
Expand All @@ -28,7 +28,7 @@ project.extensions.configure<GradleEnterpriseExtension>() {
}
}

class Capture(val api: BuildScanExtension, val logger: Logger) {
class Capture(val api: BuildScanConfiguration, val logger: Logger) {
val supportedEngines: Map<String, String> = mapOf(
"org.junit.support.testng.engine.TestNGTestEngine" to "testng",
"org.junit.jupiter.engine.JupiterTestEngine" to "junit-jupiter",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import org.gradle.api.internal.project.ProjectInternal
import org.gradle.api.services.BuildService
import org.gradle.api.services.BuildServiceParameters
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import com.gradle.develocity.agent.gradle.scan.BuildScanConfiguration
import org.gradle.internal.os.OperatingSystem
import com.gradle.scan.plugin.BuildScanExtension

import java.nio.charset.Charset
import java.util.concurrent.ConcurrentLinkedQueue
Expand All @@ -26,7 +26,7 @@ import org.gradle.tooling.events.FinishEvent
* - This is supported on MacOS only.
*/

project.extensions.configure<GradleEnterpriseExtension>() {
project.extensions.configure<DevelocityConfiguration>() {
buildScan {
val api = buildScan
if (OperatingSystem.current().isMacOsX()) {
Expand Down Expand Up @@ -92,7 +92,7 @@ abstract class ThermalThrottlingService : BuildService<BuildServiceParameters.No
}
}

fun processResults(api: BuildScanExtension) {
fun processResults(api: BuildScanConfiguration) {
if (!samples.isEmpty()) {
val average = samples.stream().mapToInt{ it as Int }.average().getAsDouble()
if (average < 100.0) {
Expand Down
2 changes: 1 addition & 1 deletion build-data-capturing-maven-samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This directory contains samples demonstrating various ways to extend and customi
tags, links, and custom values.

To learn more, see the Develocity documentation
on [Extending build scans](https://docs.gradle.com/enterprise/maven-extension/#extending_build_scans).
on [Extending build scans](https://docs.gradle.com/develocity/maven-extension/current/#extending_build_scans).

### Capture Develocity Extension Version

Expand Down
8 changes: 4 additions & 4 deletions git-user-count/unique-git-repos.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/bash

# Command line options for GRADLE_ENTERPRISE_URL and ACCESS_KEY
# Command line options for DEVELOCITY_URL and ACCESS_KEY
if [[ $# -lt 2 ]]; then
echo "Usage: $0 <gradle_enterprise_url> <access_key> [number_of_days]"
echo "Usage: $0 <develocity_url> <access_key> [number_of_days]"
exit 1
fi

GRADLE_ENTERPRISE_URL="$1"
DEVELOCITY_URL="$1"
ACCESS_KEY="$2"
NUMBER_OF_DAYS="${3:-7}" # Default to 7 days if not provided
FROM_INSTANT=$(date -d "$NUMBER_OF_DAYS days ago" +%s)000 # Days ago in milliseconds

# Function to fetch builds
fetch_builds() {
local from_build=$1
local url="$GRADLE_ENTERPRISE_URL/api/builds?models=gradle-attributes&models=maven-attributes&fromInstant=$FROM_INSTANT&maxBuilds=1000"
local url="$DEVELOCITY_URL/api/builds?models=gradle-attributes&models=maven-attributes&fromInstant=$FROM_INSTANT&maxBuilds=1000"
if [[ -n "$from_build" ]]; then
url="$url&fromBuild=$from_build"
fi
Expand Down
6 changes: 3 additions & 3 deletions quarkus-build-caching-extension/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Custom Maven Extension to make Quarkus build goal cacheable
This Maven extension allows to make the [Quarkus Maven plugin](https://quarkus.io/guides/quarkus-maven-plugin) `build` goal cacheable.

This project performs programmatic configuration of the [Develocity Build Cache](https://docs.gradle.com/enterprise/maven-extension/#using_the_build_cache) through a Maven extension. See [here](https://docs.gradle.com/enterprise/maven-extension/#custom_extension) for more details.
This project performs programmatic configuration of the [Develocity Build Cache](https://docs.gradle.com/develocity/maven-extension/current/#using_the_build_cache) through a Maven extension. See [here](https://docs.gradle.com/develocity/maven-extension/current/#custom_extension) for more details.

*Note:*<br>
A native executable can be a very large file. Copying it from/to the local cache, or transferring it from/to the remote cache can be an expensive operation that has to be balanced with the duration of the work being avoided.
Expand Down Expand Up @@ -212,7 +212,7 @@ The presence of the file is required to mark the Quarkus `build` goal as cacheab
The `track-config-changes` goal creates a file `target/quarkus-prod-config-check` containing all the properties from the `.quarkus/quarkus-prod-config-dump` with their actual value.
If property values are identical in the two files, it means that the Quarkus configuration was not changed since the last Quarkus `build`, therefore the Quarkus `build` goal can be marked cacheable.

When the Quarkus `build` goal is marked cacheable, the regular caching process using [inputs](#goal-inputs) and [outputs](#goal-outputs) kicks in as described [here](https://docs.gradle.com/enterprise/maven-extension/#using_the_build_cache).
When the Quarkus `build` goal is marked cacheable, the regular caching process using [inputs](#goal-inputs) and [outputs](#goal-outputs) kicks in as described [here](https://docs.gradle.com/develocity/maven-extension/current/#using_the_build_cache).

### Illustrated sequence of operations
Let's illustrate the extension behavior with the following sequence of builds:
Expand Down Expand Up @@ -300,7 +300,7 @@ Here are the files added as output:
## Quarkus Test goals

When the test goals (`maven-surefire-plugin` and `maven-failsafe-plugin`) are running some `@QuarkusTest` or `@QuarkusIntegrationTest`,
it is important for consistency to add [implicit dependencies](#quarkus-extra-dependencies) as goal [additional input](https://docs.gradle.com/enterprise/maven-extension/#declaring_additional_inputs).
it is important for consistency to add [implicit dependencies](#quarkus-extra-dependencies) as goal [additional input](https://docs.gradle.com/develocity/maven-extension/current/#declaring_additional_inputs).

Specifically for `maven-failsafe-plugin`, the Quarkus artifact descriptor `quarkus-artifact.properties` also needs to be added.

Expand Down
2 changes: 1 addition & 1 deletion rollout-maven-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Overview

The Develocity Maven Extension rollout script provides a means to automate the application and upgrade of the [Develocity Maven extension](https://docs.gradle.com/enterprise/maven-extension) on multiple Maven projects stored in separate Git repositories.
The Develocity Maven Extension rollout script provides a means to automate the application and upgrade of the [Develocity Maven extension](https://docs.gradle.com/develocity/maven-extension/current/) on multiple Maven projects stored in separate Git repositories.

### Usage

Expand Down