Skip to content

Instantly share code, notes, and snippets.

@166MMX
Created May 22, 2017 08:26
Show Gist options
  • Save 166MMX/541f816c32039faa8ee18e88acfb7ff4 to your computer and use it in GitHub Desktop.
Save 166MMX/541f816c32039faa8ee18e88acfb7ff4 to your computer and use it in GitHub Desktop.
jar {
final fileTree = fileTree('src/main/resources')
final rootDir = fileTree.dir.toPath()
for (file in fileTree) {
if (file.isDirectory()) {
continue
}
final name = rootDir.relativize(file.toPath()).toString()
if (name.length() <= 4) {
continue
}
if (name.charAt(name.length() - 4) != '.') {
continue
}
final fileExtension = name[-3..-1].toLowerCase(Locale.ROOT)
final contentType
switch (fileExtension) {
case 'ttf':
contentType = 'application/x-font-truetype'
break
case 'pfb':
case 'pfm':
case 'afm':
case 'otf':
contentType = 'application/x-font'
break
default:
contentType = null
break
}
if (contentType) {
manifest.attributes(['Content-Type': contentType], name)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment