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
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") } |
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 { | |
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 { |
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
// Key is the tag to add if includes or excludes match. Value is a map containing include and/or exclude patterns. | |
// Pattern is a regex that will be matched against the task name. | |
def tags = [ | |
'dexGuard': [include: 'dexGuardDebug'], | |
'incremental': [include: 'assemble.*', exclude: 'clean'] | |
] | |
gradle.taskGraph.whenReady { taskGraph -> | |
tags.each { tag, criteria -> | |
if (matchesInclude(taskGraph, criteria) && doesNotMatchExclude(taskGraph, criteria)) { |
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
// Creaate an implementation of the task using all of the types below | |
task reverseFiles(type: ReverseFiles) { | |
outputDir = file("$buildDir/reversed") | |
source("sources") | |
} | |
// The parameters for a single unit of work | |
interface ReverseParameters extends WorkParameters { | |
RegularFileProperty getFileToReverse() | |
DirectoryProperty getDestinationDir() |
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
android { | |
libraryVariants.all { | |
def kotlinCompileProvider = tasks.named("compile${name.capitalize()}Kotlin") | |
kotlinCompileProvider.configure { | |
// We do this because the way Kotlin wires itself into the Android build pipeline, | |
// it maps directly to the destinationDir property. This means if we change it, the | |
// Android configuration just follows it around. Instead, we let it generate the | |
// class files where it wants to, then we move them to where we want them, set this | |
// new location as an output directory (for caching/incrementality) and delete the |
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
// Declare a new attribute type to use for selection | |
def usageAttribute = Attribute.of("com.adyen.usage", String) | |
// In both the producer and consumer, register the new attribute and set | |
// up a configuration associated to the attribute | |
subprojects { | |
dependencies.attributesSchema { | |
attribute(usageAttribute) | |
} | |
configurations { | |
web { |
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
// Set up two different pipelines | |
createPipeline("foo") | |
createPipeline("bar") | |
// Insert a cleanup task that is automatically slotted into the foo "prepare" phase | |
tasks.register("cleanupFoo", Cleanup) { pipelineName = "foo" } | |
// Insert a start task that is automatically slotted into the foo "start" phase | |
tasks.register("startFooTestContainer", StartContainer) { pipelineName = "foo" } |
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 | |
tasks.withType(getKaptWithoutKotlincTaskClass()).configureEach { task -> | |
doFirst { | |
buildScan.value "${task.path}.processorOptions", getCompilerPluginOptions(task).collect { "${it.key} = ${it.value}" }.join("\n") | |
} | |
} | |
static def getCompilerPluginOptions(Task task) { | |
def processorOptionsField = getAccessibleField(task.class, "processorOptions") |
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(com.apollographql.apollo.gradle.ApolloCodegenTask).configureEach { task -> | |
FileTree originalSource | |
// Create a synthetic input with the original source value and RELATIVE path sensitivity | |
project.gradle.taskGraph.beforeTask { | |
if (it == task) { | |
originalSource = task.getSource() | |
// Set the source to something static for the purpose of input calculation | |
task.source = fileTree("foo") | |
task.inputs.files(originalSource) | |
.withPathSensitivity(PathSensitivity.RELATIVE) |
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(com.android.build.gradle.tasks.MergeResources) { task -> | |
Map<String, FileCollection> originalResources = [:] | |
// Create a synthetic input with the original value and RELATIVE path sensitivity | |
project.gradle.taskGraph.beforeTask { | |
if (it == task) { | |
originalResources.putAll(task.resourcesComputer.resources) | |
task.resourcesComputer.resources.clear() | |
task.inputs.files(originalResources.values()) | |
.withPathSensitivity(PathSensitivity.RELATIVE) | |
.withPropertyName("rawLocalResources.workaround") |