Skip to content

Instantly share code, notes, and snippets.

@cdsap
cdsap / monitor.sh
Created March 25, 2025 20:32
JVM Memory process monitor
#!/bin/bash
PATTERNS=("GradleDaemon" "KotlinCompileDaemon" "GradleWorkerMain")
LOG_FILE="java_mem_monitor.log"
INTERVAL=5
echo "Starting memory monitor at $(date)" > "$LOG_FILE"
echo "Timestamp | PID | Name | Heap_Used_MB | Heap_Capacity_MB | RSS_MB" >> "$LOG_FILE"
while true; do
@cdsap
cdsap / request.sh
Created March 7, 2025 01:46
Get Modules executed in a set Of builds
curl --location -G 'https://$DV_URL/api/builds?maxBuilds=50&models=gradle-build-cache-performance&reverse=true' --header "Authorization: Bearer $TOKEN" --data-urlencode 'query=project:nowinandroid_test gradle.requestedTasks:assembleDebug'
$RESPONSE | jq '[.[]
| {
id: .models.gradleBuildCachePerformance.model.id,
buildDuration: .models.gradleBuildCachePerformance.model.buildTime,
modules: (
(.models.gradleBuildCachePerformance.model.taskExecution // [])
| map(select(.taskType=="org.jetbrains.kotlin.gradle.tasks.KotlinCompile" and .avoidanceOutcome=="executed_cacheable")
| (.taskPath // "") | split(":")[:-1] | join(":")
@cdsap
cdsap / jps_commands.txt
Created January 27, 2025 16:57
Jps commands
#Kill all Gradle/Kotlin processes
jps | grep -E "GradleDaemon|KotlinCompileDaemon" | awk '{print $1}' | xargs -r kill
@cdsap
cdsap / main.kt
Created June 5, 2024 20:49
Module used classes by target module
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import java.io.File
fun main() {
// the project needs to execute the dependency-analysis plugin in order to generate the usage json files
val path = "PATH_TO_THE_PROJECT"
val references = getModuleUsages(path)
@cdsap
cdsap / retrieve_r8_duration.sh
Last active April 22, 2024 13:54
Retrieve R8 duration API < 2023.4
#!/bin/bash
TOKEN="" # Develocity API token
TASK_PATH=":app:minifyDemoReleaseWithR8" # task path under investigation
URL="https://ge.solutions-team.gradle.com" # Develocity url
QUERY="query=user:runner requested:assembleRelease" # Query advanced search: https://docs.gradle.com/enterprise/api-manual/#advanced_search_syntax
# Using `requested:assembleRelease` to filter build scans only requesting this type of build
MAX_BUILDS=50
json_ids=$(curl -s --location -G "$URL/api/builds?maxBuilds=$MAX_BUILDS&reverse=true" \
@cdsap
cdsap / .kts
Created March 6, 2024 19:32
Example Configuration build.gradle.kts
import com.google.devtools.ksp.gradle.KspTaskJvm
buildscript {
repositories {
google()
mavenCentral()
// Android Build Server
maven { url = uri("../nowinandroid-prebuilts/m2repository") }
}
@cdsap
cdsap / csv
Created August 4, 2023 23:14
results.csv
type metric main k2
:app-nia-catalog:compileDebugKotlin Compiler code generation 956.59 2754.76
:app-nia-catalog:compileDebugKotlin Analysis lines per second 270 386
:app-nia-catalog:compileDebugKotlin Shrink and save current classpath snapshot after compilation 73.89 124.83
:app-nia-catalog:compileDebugKotlin Load current classpath snapshot 15.97 27.27
:app-nia-catalog:compileDebugKotlin Run compilation in Gradle worker 4000 4332.23
:app-nia-catalog:compileDebugKotlin Sources compilation round 3646.6 3961.63
:app-nia-catalog:compileDebugKotlin Run compilation 3989.38 4321.78
:app-nia-catalog:compileDebugKotlin Incremental compilation in daemon 3940.88 4264.52
:app-nia-catalog:compileDebugKotlin Total Gradle task time 4203.52 4541.3
@cdsap
cdsap / Dockerfile
Created May 18, 2023 21:45
Docker file buidling Test Distribution Agent + Android SDK
FROM gradle/gradle-enterprise-test-distribution-agent:2.0.1
USER 0
RUN apt-get update \
&& apt-get install -y wget \
&& apt-get install -y unzip \
&& rm -rf /var/lib/apt/lists/*
USER gradle
RUN mkdir -p /home/gradle/android-sdk
ENV ANDROID_HOME "/home/gradle/android-sdk"
@cdsap
cdsap / settings.gradle
Created March 13, 2023 16:54
GE configuration with incorrect server avoiding the Build Scan publication
import javax.inject.Inject
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
plugins {
@cdsap
cdsap / pom.xml
Created February 23, 2023 00:42
Plugin Management block
<pluginManagement>
<plugins>
<plugin>
<groupId>com.gradle</groupId>
<artifactId>gradle-enterprise-maven-extension</artifactId>
<configuration>
<gradleEnterprise>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>