Skip to content

Commit

Permalink
Use try-with-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
runningcode committed Apr 28, 2017
1 parent 45ba411 commit 2ea6cdc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions buckw
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ setupBuckRun ( ) {
handleParams ( ) {
# Go directly to kill. Do not run okbuck.
if [[ "kill" == $1 ]]; then
echo "skipping okbuck"
SKIP_OKBUCK=true
fi
}
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ okbuck {
}
}

task wrapper(type : Wrapper) {
gradleVersion = '3.5'
distributionUrl = "https://services.gradle.org/distributions/gradle-3.5-all.zip"
}

gradle.buildFinished {
"zip -d .okbuck/cache/org.hamcrest.hamcrest-core-1.3.jar LICENSE.txt".execute()
"zip -d .okbuck/cache/org.hamcrest.hamcrest-library-1.3.jar LICENSE.txt".execute()
Expand Down
11 changes: 4 additions & 7 deletions buildSrc/src/main/java/com/uber/okbuck/core/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ public static String getRelativePath(File root, File f) {

@SuppressWarnings("ResultOfMethodCallIgnored")
public static void copyResourceToProject(String resource, File destination) {
try {
InputStream inputStream = FileUtil.class.getResourceAsStream(resource);
destination.getParentFile().mkdirs();
OutputStream outputStream = new FileOutputStream(destination);
destination.getParentFile().mkdirs();
try (InputStream inputStream = FileUtil.class.getResourceAsStream(resource);
OutputStream outputStream = new FileOutputStream(destination)) {
IOUtils.copy(inputStream, outputStream);
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
} catch (IOException e) {
throw new IllegalStateException(e);
throw new RuntimeException(e);
}
}

Expand Down
16 changes: 6 additions & 10 deletions buildSrc/src/main/java/com/uber/okbuck/core/util/ReplaceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ final class ReplaceUtil {

@SuppressWarnings("ResultOfMethodCallIgnored")
static void copyResourceToProject(String resource, File destination, Map<String, String> templates) {
try {
InputStream inputStream = FileUtil.class.getResourceAsStream(resource);
destination.getParentFile().mkdirs();
InputStreamReader reader = new InputStreamReader(inputStream);
TemplateReader replacingReader = new TemplateReader(reader, new TemplateMapResolver(templates));

OutputStream outputStream = new FileOutputStream(destination);
destination.getParentFile().mkdirs();
try (InputStream inputStream = FileUtil.class.getResourceAsStream(resource);
InputStreamReader reader = new InputStreamReader(inputStream);
TemplateReader replacingReader = new TemplateReader(reader, new TemplateMapResolver(templates));
OutputStream outputStream = new FileOutputStream(destination)){
IOUtils.copy(replacingReader, outputStream);
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
} catch (IOException e) {
throw new IllegalStateException(e);
throw new RuntimeException(e);
}
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Mar 31 15:13:29 PDT 2017
#Thu Apr 27 20:36:07 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip

0 comments on commit 2ea6cdc

Please sign in to comment.