Skip to content

Instantly share code, notes, and snippets.

@Frontrider
Created December 15, 2018 21:38
Show Gist options
  • Save Frontrider/c275897a8e7a20ccb68a3226c469729e to your computer and use it in GitHub Desktop.
Save Frontrider/c275897a8e7a20ccb68a3226c469729e to your computer and use it in GitHub Desktop.
def resourceDir = "generatedResources/"
def resourceBuildDir = "build/resourceSource/"
mkdir(file(resourceDir))
mkdir(file(resourceBuildDir))
sourceSets {
main {
resources {
srcDirs "src/main/resources", resourceBuildDir
}
}
}
def variants = ["stone", "oak", "granite", "diorite", "birch", "andesite"]
task generateResources(type: Copy) {
doFirst{
delete(resourceBuildDir)
}
variants.forEach{ String name->
from (resourceDir) {
include '**/*.json'
filter {
it.replace('@replace@', name)
}
rename { String fileName ->
fileName.replace("@replace@", "$name")
}
}
}
into resourceBuildDir
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment