Skip to content

Instantly share code, notes, and snippets.

View jprinet's full-sized avatar

Jérôme Prinet jprinet

  • Bayonne, France
  • 15:56 (UTC +01:00)
View GitHub Profile
@jprinet
jprinet / wait-until-ready.sh
Created January 20, 2020 21:36
wrapper script to launch command when dependency is ready
#!/bin/sh
readonly MAX_RETRY=10
readonly DELAY_BETWEEN_TRY_IN_SECONDS=10
readonly DEPENDENCY_CHECK_COMMAND=$1
readonly CONTAINER_RUN_COMMAND=$2
# wait until a command succeeds
#
# Usage: waitUntilReady "<command arg1...argN>"
@jprinet
jprinet / build.gradle
Created July 7, 2022 11:18
Grab checkstyle issues in a configuration cache compatible way
abstract class CheckstyleReportAsCustomValueBuildService implements BuildService<CheckstyleReportAsCustomValueBuildService.Params>, OperationCompletionListener {
interface Params extends BuildServiceParameters {
ListProperty<FileSystemLocation> getReports()
Property<BuildScanExtension> getBuildScanApi()
}
@Override
void onFinish(FinishEvent finishEvent) {
if(finishEvent.getDescriptor().displayName.contains("checkstyle")){
@jprinet
jprinet / capture-classpath.gradle
Created July 20, 2022 08:24
Capture classpath entries with their size
import java.nio.file.Files
tasks.withType(JavaCompile) {
doLast {
def sizes = it.classpath.collect {
if (it.isFile()) {
return new FileSize(Files.size(it.toPath())/(1024*1024), "F ${it}")
} else {
return new FileSize(0, "D ${it}")
}
@jprinet
jprinet / capture.kts
Last active July 22, 2022 14:21
Capture Task inputs size
tasks.withType<JavaCompile>().configureEach {
doLast {
this.inputs.files.map { it ->
if(it.isFile) {
FileSize(it.length(), it.path)
} else {
FileSize(0, "DIR - " + it.path)
}
}.sortedBy {
it.size
@jprinet
jprinet / gradle-processor-arch.gradle
Last active August 4, 2022 11:00
CC compatible version of gradle-processor-arch.gradle
import java.nio.charset.Charset
import java.util.concurrent.TimeUnit
/**
* This Gradle script captures the processor architecture
* and adds these as a custom value.
* This should be applied to the root project:
* <code> apply from: file('gradle-processor-arch.gradle') </code>
*/
@jprinet
jprinet / build.gradle
Last active September 28, 2022 08:21
Ignore JavaCompile task input differences compilerArgumentProviders.$i.extractedJdkImage
// This normalization block should be combined with the Android cache fix plugin
// https://github.com/gradle/android-cache-fix-gradle-plugin#applying-the-plugin
normalization {
runtimeClasspath {
// See https://github.com/gradle/android-cache-fix-gradle-plugin/issues/341 for more details
ignore '**/java/lang/invoke/**'
}
}
@jprinet
jprinet / build.gradle.kts
Last active February 9, 2023 10:21
Capture collection fingerprints
val libraryFingerprint by tasks.registering(LibraryFingerprint::class) {
inputFiles.from(sourceSets["main"].output)
}
tasks.named("build").configure {
dependsOn(libraryFingerprint)
}
abstract class LibraryFingerprint : DefaultTask() {
#!/bin/bash
geUrl=$1
bearerToken=$2
since=$3
customKey=$4
customValue=$5
rm -f $0.out.txt
function processBuilds() {
#!/bin/bash
outputFile=$0.out.csv
rm -f $outputFile
while getopts ":u:t:s:k:v:p:" opt; do
case $opt in
u) geUrl="$OPTARG"
;;
t) bearerToken="$OPTARG"
@jprinet
jprinet / CustomGradleEnterpriseConfig.java
Last active June 9, 2023 14:30
Add Docker image IDs as extra inputs to the surefire goal.
package com.gradle;
import com.gradle.maven.extension.api.GradleEnterpriseApi;
import com.gradle.maven.extension.api.cache.BuildCacheApi;
import com.gradle.maven.extension.api.cache.MojoMetadataProvider;
import com.gradle.maven.extension.api.scan.BuildScanApi;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.model.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;