This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task checkForOverlappingOutputs { | |
doLast { | |
def rootNode = new TreeNode() | |
rootNode.name = '' | |
// Gather the outputs of all tasks | |
allprojects { | |
tasks.all { task -> | |
try { | |
task.outputs.files.each { file -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.gradle.api.services.* | |
subprojects { | |
apply plugin: OneTestTaskOnly | |
} | |
class OneTestTaskOnly implements Plugin<Project> { | |
void apply(Project project) { | |
// Register a service to constrain parallelism of test tasks to 1 | |
Provider<SharedResource> testLimitingService = project.gradle.sharedServices.registerIfAbsent("testLimitingService", SharedResource) { spec -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'java' | |
} | |
tasks.withType(JavaCompile).configureEach { | |
// Set up the localization values | |
def localizationMethod = "foo" | |
def localizationOutputDir = file("${buildDir}/localizationTool") | |
// Add the argument provider to the compiler arguments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gradle.settingsEvaluated { | |
def buildCacheEnabled = gradle.startParameter.buildCacheEnabled | |
gradleEnterprise { | |
buildScan { | |
tag buildCacheEnabled ? "CACHED" : "NOTCACHED" | |
value "Local Build Cache", (buildCacheEnabled && buildCache.local?.enabled) ? "enabled" : "disabled" | |
value "Remote Build Cache", (buildCacheEnabled && buildCache.remote?.enabled) ? "enabled" : "disabled" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks.withType(Test).configureEach { task -> | |
project.gradle.taskGraph.beforeTask { | |
if (task == it) { | |
if (!includes.empty || !excludes.empty || !filter.includePatterns.empty || !filter.excludePatterns.empty || !filter.commandLineIncludePatterns.empty) { | |
buildScan.tag 'FILTERED_TESTS' | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompileWithWorkers) { task -> | |
project.gradle.taskGraph.beforeTask { | |
if (task == it) { | |
// Get the 'commonSourceSet' property and make it accessible | |
def field = task.class.superclass.superclass.superclass.getDeclaredField('commonSourceSet') | |
field.setAccessible(true) | |
// Store the current value, and if the 'source' property contains everything in 'commonSourceSet', | |
// clear it out for the purposes of snapshotting (i.e. the directories are already tracked by a different | |
// input property) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allprojects { | |
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompileWithWorkers) { task -> | |
project.gradle.taskGraph.beforeTask { | |
if (task == it) { | |
def field = task.class.superclass.superclass.superclass.getDeclaredField('commonSourceSet') | |
field.setAccessible(true) | |
project.rootProject.buildScan.value "${task.path}.commonSourceSets", field.get(task).files.join("\n") | |
def compilationBySourceSet = task.project.ext."kotlin.compilations.bySourceSets".get() | |
project.rootProject.buildScan.value "${task.path}.compilations", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks.withType(ProGuardTask).configureEach { task -> | |
// Enable caching for the proguard tasks | |
outputs.cacheIf { true } | |
// Fix inputs and outputs so that caching works | |
def originalOutJars = [] | |
def originalInJars = [] | |
def originalLibraryJars = [] | |
def originalConfigurationFiles = [] | |
project.gradle.taskGraph.beforeTask { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Field | |
import java.lang.reflect.Modifier | |
allprojects { | |
pluginManager.withPlugin('io.freefair.lombok') { | |
def javaExtension = project.getConvention().getPlugin(JavaPluginConvention.class) | |
// Reconfigure the lombok config input for each compile task | |
javaExtension.sourceSets.all { sourceSet -> | |
def compileJavaTask = project.tasks.named(sourceSet.compileJavaTaskName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fingerprinter = services.get(org.gradle.internal.fingerprint.classpath.ClasspathFingerprinter) | |
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { task -> | |
doFirst { | |
ClassLoader classLoader = task.getClass().classLoader | |
while (classLoader instanceof URLClassLoader) { | |
def fingerprints = [] as Set | |
def allFiles = [] as Set | |
classLoader.getURLs().each { | |
fingerprints.add(["${task.path}:${file(it.file).name}", "${fingerprinter.fingerprint(files(it.file)).hash}"]) | |
allFiles.add(file(it.file)) |