Skip to content

Instantly share code, notes, and snippets.

@ylxs90
Last active April 2, 2021 14:19
Show Gist options
  • Save ylxs90/eb8e0bbc0f594d1f795f8e5154379fe8 to your computer and use it in GitHub Desktop.
Save ylxs90/eb8e0bbc0f594d1f795f8e5154379fe8 to your computer and use it in GitHub Desktop.
gradle tasks
def configPath = "H:\\fc\\config"
/**
* copy spring config file from subprojects to direct path(configPath)
*/
task collectConfigFiles() {
def path = new File(configPath)
path.deleteDir()
path.mkdirs()
project.subprojects.findAll { it.subprojects.isEmpty() }.each({ p ->
p.sourceSets.main.resources.files.each { File file ->
def matcher = file.name =~ /application(\-(?<profile>\w{3,5}))?\.((yaml)|(yml))/
if (!matcher.matches()) {
return
}
def profile = matcher.group("profile");
new File("${configPath}${File.separator}${p.name}${profile == null ? "" : "-$profile"}.yaml") << file.text
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment