Skip to content

Instantly share code, notes, and snippets.

@rivancic
Created June 11, 2022 17:20
Show Gist options
  • Save rivancic/5f55224e5f3b7a608413fa5944a22013 to your computer and use it in GitHub Desktop.
Save rivancic/5f55224e5f3b7a608413fa5944a22013 to your computer and use it in GitHub Desktop.
Gradle Task Printing Content of a file
tasks.register("printBuild") { // Register task named printBuild
doLast { // What should be executed - action
// Open a file in BufferedReader
try (BufferedReader br = new BufferedReader(new FileReader(layout.buildDirectory.dir("resources/main/git.properties").get().getAsFile()))) {
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
}
}
build.finalizedBy(printBuild)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment