Skip to content

Instantly share code, notes, and snippets.

@changusmc changusmc/watchman.gradle Secret
Created Oct 11, 2019

Embed
What would you like to do?
/*
* Copyright (c) 2019, Dropbox, Inc. All rights reserved.
*/
// Watchman generates a json file to depict the xplat file structure filtered on "bmbf source" files
task watchmanCheckIfCodegenNeeded(type:Exec) {
File outputJson = new File(project.buildDir, "changed-files.json")
File watchmanJson = new File(xplatRoot, "tools/watchman/watchman-bmbf.json")
workingDir xplatRoot
commandLine "bash", "-c", "watchman watch-project $xplatRoot"
commandLine "bash", "-c", "watchman -j < $watchmanJson.absolutePath"
doFirst {
standardOutput new ByteArrayOutputStream()
}
doLast {
// Remove this piece of data that changes on every run (even with no modifications to the files)
def filteredText = standardOutput.toString().replaceFirst(".*\"clock\".*\n", "")
if (outputJson.exists()) {
outputJson.delete()
}
outputJson << filteredText
logger.lifecycle("Watchman query for BMBF files done: " + outputJson)
}
// Save the json as the output so other tasks can reference it easily
outputs.files { outputJson }
// Always run this task
outputs.upToDateWhen { false }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.