Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public void put(String platform, String key, File source) throws ExtenderClientE
throw new ExtenderClientException(String.format("Failed to create cache dir %s", parentDir.getAbsolutePath()));
}

try {
Files.copy(new FileInputStream(source), cachedFile.toPath(), REPLACE_EXISTING);
try(InputStream is = new FileInputStream(source)) {
Files.copy(is, cachedFile.toPath(), REPLACE_EXISTING);
} catch (IOException e) {
throw new ExtenderClientException(String.format("Failed to copy %s to %s", source.getAbsolutePath(), cachedFile.getAbsolutePath()), e);
}
Expand All @@ -152,15 +152,13 @@ public void get(String platform, String key, File destination) throws ExtenderCl
throw new ExtenderClientException(String.format("The file %s wasn't cached with key %s", cachedFile.getAbsolutePath(), key));
}

try {
Files.copy(new FileInputStream(cachedFile), destination.toPath(), REPLACE_EXISTING);
try(InputStream is = new FileInputStream(cachedFile)) {
Files.copy(is, destination.toPath(), REPLACE_EXISTING);
} catch (IOException e) {
throw new ExtenderClientException(String.format("Failed to copy %s to %s", cachedFile.getAbsolutePath(), destination.getAbsolutePath()), e);
}
}

//

private static MessageDigest getHasher() throws ExtenderClientException {
MessageDigest md = null;
try {
Expand Down Expand Up @@ -198,8 +196,8 @@ private void saveCache() {

private void loadCache() {
Properties properties = new Properties();
try {
properties.load(new FileInputStream(getCacheFile()));
try(InputStream is = new FileInputStream(getCacheFile())) {
properties.load(is);
} catch (IOException e) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,19 @@ public void testUploadStructure(String cacheResponse, List<String> expectedFilen
assertNotNull(sourceCodeArchiveEntity);
assertTrue(sourceCodeArchiveEntity.getBody() instanceof BinaryBody);
BinaryBody archiveBody = (BinaryBody)sourceCodeArchiveEntity.getBody();
ZipInputStream zis = new ZipInputStream(archiveBody.getInputStream());
ZipEntry zipEntry = zis.getNextEntry();
List<String> zipEntriesFilenames = new ArrayList<>();
while (zipEntry != null) {
zipEntriesFilenames.add(zipEntry.getName());
zipEntry = zis.getNextEntry();
try (ZipInputStream zis = new ZipInputStream(archiveBody.getInputStream())) {
ZipEntry zipEntry = zis.getNextEntry();
List<String> zipEntriesFilenames = new ArrayList<>();
while (zipEntry != null) {
zipEntriesFilenames.add(zipEntry.getName());
zipEntry = zis.getNextEntry();
}
assertTrue(
expectedFilenames.size() == zipEntriesFilenames.size() &&
expectedFilenames.containsAll(zipEntriesFilenames) &&
zipEntriesFilenames.containsAll(expectedFilenames)
);
}
assertTrue(
expectedFilenames.size() == zipEntriesFilenames.size() &&
expectedFilenames.containsAll(zipEntriesFilenames) &&
zipEntriesFilenames.containsAll(expectedFilenames)
);
}
catch (Exception e) {
System.out.println("ERROR LOG:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,23 @@ private static class ILoggerWrapper implements ILogger {
public ILoggerWrapper(Logger logger) {
this.logger = logger;
}

@Override
public void error(Throwable t, String msgFormat, Object... args) {
AndroidManifestMerger.logger.log(Level.SEVERE, msgFormat, args);
}

@Override
public void warning(String msgFormat, Object... args) {
AndroidManifestMerger.logger.log(Level.WARNING, msgFormat, args);
}

@Override
public void info(String msgFormat, Object... args) {
AndroidManifestMerger.logger.log(Level.INFO, msgFormat, args);
}

@Override
public void verbose(String msgFormat, Object... args) {
AndroidManifestMerger.logger.log(Level.FINE, msgFormat, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.FileNotFoundException;
import java.util.Iterator;
import java.util.ArrayList;
Expand Down Expand Up @@ -151,14 +152,16 @@ else if (baseMergePolicy == MergePolicy.MERGE) {


private XMLPropertyListConfiguration loadPlist(File file) {
try {
try(Reader fr = new FileReader(file)) {
XMLPropertyListConfiguration plist = new XMLPropertyListConfiguration();
plist.read(new FileReader(file));
plist.read(fr);
return plist;
} catch (ConfigurationException e) {
throw new RuntimeException(String.format("Failed to parse plist '%s': %s", file.getAbsolutePath(), e.toString()));
} catch (FileNotFoundException e) {
throw new RuntimeException(String.format("File not found: %s", file.getAbsolutePath()));
} catch (IOException e) {
throw new RuntimeException(String.format("Exception when closing file %s", e.getMessage()));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.defold.manifestmergetool;

import java.io.File;
import java.io.Reader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
Expand Down Expand Up @@ -129,14 +130,16 @@ private void mergeConfigs(XMLPropertyListConfiguration base, XMLPropertyListConf
}

private XMLPropertyListConfiguration loadConfig(File file) {
try {
try(Reader fr = new FileReader(file)) {
XMLPropertyListConfiguration plist = new XMLPropertyListConfiguration();
plist.read(new FileReader(file));
plist.read(fr);
return plist;
} catch (ConfigurationException e) {
throw new RuntimeException(String.format("Failed to parse plist '%s': %s", file.getAbsolutePath(), e.toString()));
} catch (FileNotFoundException e) {
throw new RuntimeException(String.format("File not found: %s", file.getAbsolutePath()));
} catch (IOException e) {
throw new RuntimeException(String.format("Exception when closing file %s", e.getMessage()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ private static void dumpDir(File file, int indent) throws IOException {

/**
* Create the main Podfile with a list of all dependencies for all uploaded extensions
* @param podFiles List of podfiles to merge into the main Pofile
* @param jobDirectory The job directory from where to search for Podfiles
* @param workingDir The working directory where pods should be resolved
* @param platform For which platform to resolve pods
* @param buildState Extender's build state
* @param cocoapodsBuildState Cocoapods build state
* @param jobEnvContext Map of environemnt variables defined for the current build
* @return Main pod file structure
* @throws PodfileParsingException
* @throws IOException
Expand Down Expand Up @@ -354,9 +353,7 @@ private Map<String, Object> createJobEnvContext(Map<String, Object> env) {
/**
* Entry point for Cocoapod dependency resolution.
* @param config Platform config
* @param jobDir Root directory of the job to resolve
* @param platform Which platform to resolve pods for
* @param configuration Build configuration ("debug", "release", "headless")
* @param buildState Extender's build state
* @return ResolvedPods instance with list of pods, install directory etc
*/
public ResolvedPods resolveDependencies(PlatformConfig config, ExtenderBuildState buildState) throws IOException, ExtenderException {
Expand Down