Skip to content

Commit

Permalink
Don't crash on first build due to lzma fail
Browse files Browse the repository at this point in the history
  • Loading branch information
LunNova committed Jun 20, 2017
1 parent eb3ea65 commit 93d1626
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,37 @@ static Encoder getEncoder() {
return encoder
}

static File lzma(String name) {
project.ext.lzmaFromTo = new HashMap<File, File>()

File lzma(String name) {
File from = new File(name)
File to = new File("./generated/" + from.getName() + ".lzma")
project.lzmaFromTo.put(from, to)
return to
}

if (!to.exists() || to.lastModified() != from.lastModified()) {
to.getParentFile().mkdir()
OutputStream stream = new LzmaOutputStream(new FileOutputStream(to), getEncoder())
try {
Files.copy(from.toPath(), stream)
} finally {
stream.flush()
stream.close()
void createLzma() {
for (entry in project.lzmaFromTo.entrySet()) {
File from = entry.getKey()
File to = entry.getValue()
if (!to.exists() || to.lastModified() != from.lastModified()) {
to.getParentFile().mkdir()
OutputStream stream = new LzmaOutputStream(new FileOutputStream(to), getEncoder())
try {
Files.copy(from.toPath(), stream)
} finally {
stream.flush()
stream.close()
}
to.setLastModified(from.lastModified())
}
to.setLastModified(from.lastModified())
}

return to
}

jar {
doFirst {
createLzma()
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from lzma(mappingsPath + 'methods.csv')
from lzma(mappingsPath + 'fields.csv')
Expand Down

0 comments on commit 93d1626

Please sign in to comment.