Skip to content

Instantly share code, notes, and snippets.

@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>
@cdsap
cdsap / Benford.kt
Created December 15, 2022 19:05
Benford
class Benford(sample: Array<BigInteger>) {
override fun toString() = str
private val firstDigits = IntArray(9)
private val count = sample.size.toDouble()
private val str: String
init {
for (n in sample) {
firstDigits[n.toString().substring(0, 1).toInt() - 1]++
@cdsap
cdsap / CurlRequestValueSource.kt
Created October 27, 2022 21:26
CurlRequestValueSource
abstract class CurlRequestValueSource : ValueSource<String, CurlRequestValueSource.Parameters> {
interface Parameters : ValueSourceParameters {
val server: Property<String>
}
@get:Inject
abstract val execOperations: ExecOperations
override fun obtain(): String {
return execOperations.exec {
@cdsap
cdsap / README.md
Last active August 8, 2022 18:15 — forked from alextu/README.md

Snippet to apply retry plugin to all projects only supporting Junit5 platform

settings.gradle

plugins {
    id "org.gradle.test-retry" version "1.4.0" apply false
}

def isCiServer = System.getenv().containsKey("CI")
gradle.beforeProject { p ->
    p.pluginManager.withPlugin("java") {