Created
May 22, 2017 08:26
-
-
Save 166MMX/541f816c32039faa8ee18e88acfb7ff4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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