Skip to content

Instantly share code, notes, and snippets.

@ghale
ghale / build.gradle
Created April 17, 2020 15:57
Compiler argument provider example
plugins {
id 'java'
}
tasks.withType(JavaCompile).configureEach {
def resourcesDir = project.file("${projectDir}/resources")
options.compilerArgumentProviders.add(MyAnnotationArgumentProvider.from(resourcesDir))
// This captures the argument provider as a custom value in the build scan for troubleshooting purposes only
doFirst {
project.afterEvaluate {
tasks.withType(MergeJavaResourceTask).configureEach { task ->
def projectJavaResOriginal = task.projectJavaRes
// This file collection will hold all of the kotlin_module files
def projectJavaResWithKotlinModuleFiles = project.files(task.projectJavaRes).filter { it.name.endsWith(".kotlin_module") }
// This file collection will hold everything but the kotlin_module files
def projectJavaResWithoutKotlinModuleFiles = project.files(task.projectJavaRes).filter { !it.name.endsWith(".kotlin_module") }
@ghale
ghale / build.gradle
Last active February 10, 2020 21:33
Make GitProperties plugin only gather properties once
plugins {
id 'java'
// Only add the git-properties plugin to the classpath, don't apply (yet)
id 'com.gorylenko.gradle-git-properties' version '2.2.1' apply false
}
// This plugin is only applied to the root project
apply plugin: GitRootProjectPropertiesPlugin
subprojects {
import org.gradle.launcher.daemon.registry.DaemonRegistry
def registry = services.get(DaemonRegistry)
if (registry.all.size() > 1) {
registry.all.each { info ->
buildScan {
value "daemon-${info.pid}", "${info.lastBusy} ${info.toString()}"
}
}
/*
* Adds extended data to a build scan so that this data can be searched on in the scans ui.
*
* Add this script to the gradle directory and apply it in your build.gradle
* e.g.
*
* apply from: "gradle/buildScan-extended-data.gradle"
*
*
* Note that this script requires the following to be added to your settings.gradle:
apply plugin: DbPlugin
tasks.register("subtask1")
tasks.register("subtask2")
tasks.named("fixDbPermissions") {
addStep subtask1
addStep subtask2
}
@ghale
ghale / init.gradle
Created May 3, 2018 13:33
Standard error capturing init script
rootProject {
def errorFile = file("${rootProject.buildDir}/errors.log")
def errorListener = new ErrorCapture(errorFile)
allprojects {
logging.addStandardErrorListener(errorListener)
tasks.all {
logging.addStandardErrorListener(errorListener)
}
value host_statistics_pages host_statistics_mb vm_stat_mb vm_stat_pages
free 286318 1118 1115 285662
inactive 806602 3150 3150 806602
wired 948824 3706 3706 948865
active 1439810 5624 5626 1440300
external 407294064 1590992 1561 399654
speculative 1 0 79 20247
total 4194304 16384 16384 4194304
available_fcache 407580381 1592110 2597 665069
available_inact 1092919 4269 4187 1072017
@ghale
ghale / triggerWebsitePullDocs
Created April 19, 2016 16:54
triggerWebsitePullDocs
/var/www/gradleware-web/master/backend-ops.gradle.org/update-docs/../docs-raw 2.12 https://services.gradle.org/distributions/gradle-2.12-patched-docs-2.zip
2.12 exists, not downloading
2.12 docs already transformed
ln -sfT 2.12 current
/var/www/gradleware-web/master/backend-ops.gradle.org/update-docs/../docs-raw 2.13-rc-2 https://services.gradle.org/distributions/gradle-2.13-rc-2-all.zip
wget --no-check-certificate -O 2.13-rc-2.zip https://services.gradle.org/distributions/gradle-2.13-rc-2-all.zip
@ghale
ghale / gist:b45bbb804d5d438cb212
Created November 9, 2015 20:13
example of redistributing gradle with init scripts
apply plugin: "base"
apply plugin: "maven-publish"
repositories {
maven {
url "http://repo.gradle.org/gradle/gradle"
}
}
configurations {