use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class ClientProcess method start.
/**
* Call this to attempt to connect to the server.
*
* @param port where the server is listening. Since it launched this client, it should have either been passed to it on the command line or via a system property (-D).
*/
public void start(int port) {
Socket clientSocket;
try {
clientSocket = new Socket((String) null, port);
socketWrapper = new ObjectSocketWrapper(clientSocket);
if (protocol.serverConnected(clientSocket)) {
return;
}
} catch (IOException e) {
throw new UncheckedIOException(String.format("Could not connect to GUI server at port %s.", port), e);
}
try {
clientSocket.close();
socketWrapper = null;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
throw new UncheckedIOException("GUI protocol failed to connect.");
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class AbstractGradleServerProtocol method extractInitScriptFile.
/**
* If you do have an init script that's a resource, this will extract it based on the name and write it to a temporary file and delete it on exit.
*
* @param resourceClass the class associated with the resource
* @param resourceName the name (minus extension or '.') of the resource
*/
protected File extractInitScriptFile(Class resourceClass, String resourceName) {
File file = null;
try {
file = temporaryFileProvider.createTemporaryFile(resourceName, INIT_SCRIPT_EXTENSION);
} catch (UncheckedIOException e) {
logger.error("Creating init script file temp file", e);
return null;
}
file.deleteOnExit();
if (extractResourceAsFile(resourceClass, resourceName + INIT_SCRIPT_EXTENSION, file)) {
return file;
}
logger.error("Internal error! Failed to extract init script for executing commands!");
return null;
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class AbstractNamedFileSnapshotTaskStateChanges method buildSnapshots.
protected static ImmutableSortedMap<String, FileCollectionSnapshot> buildSnapshots(String taskName, FileCollectionSnapshotterRegistry snapshotterRegistry, String title, SortedSet<? extends TaskFilePropertySpec> fileProperties) {
ImmutableSortedMap.Builder<String, FileCollectionSnapshot> builder = ImmutableSortedMap.naturalOrder();
for (TaskFilePropertySpec propertySpec : fileProperties) {
FileCollectionSnapshot result;
try {
FileCollectionSnapshotter snapshotter = snapshotterRegistry.getSnapshotter(propertySpec.getSnapshotter());
result = snapshotter.snapshot(propertySpec.getPropertyFiles(), propertySpec.getCompareStrategy(), propertySpec.getSnapshotNormalizationStrategy());
} catch (UncheckedIOException e) {
throw new UncheckedIOException(String.format("Failed to capture snapshot of %s files for task '%s' property '%s' during up-to-date check.", title.toLowerCase(), taskName, propertySpec.getPropertyName()), e);
}
builder.put(propertySpec.getPropertyName(), result);
}
return builder.build();
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class FileToArchiveEntrySetTransformer method walk.
private ImmutableSet<ArchiveEntry> walk(InputStream archiveInputStream, ImmutableSet.Builder<ArchiveEntry> allEntries, ImmutableList<String> parentPaths) {
ImmutableSet.Builder<ArchiveEntry> entries = ImmutableSet.builder();
ZipInputStream zipStream = new ZipInputStream(archiveInputStream);
try {
ZipEntry entry = zipStream.getNextEntry();
while (entry != null) {
ArchiveEntry.Builder builder = new ArchiveEntry.Builder();
builder.setParentPaths(parentPaths);
builder.setPath(entry.getName());
builder.setCrc(entry.getCrc());
builder.setDirectory(entry.isDirectory());
builder.setSize(entry.getSize());
if (!builder.isDirectory() && (zipStream.available() == 1)) {
boolean zipEntry;
final BufferedInputStream bis = new BufferedInputStream(zipStream) {
@Override
public void close() throws IOException {
}
};
bis.mark(Integer.MAX_VALUE);
zipEntry = new ZipInputStream(bis).getNextEntry() != null;
bis.reset();
if (zipEntry) {
ImmutableList<String> nextParentPaths = ImmutableList.<String>builder().addAll(parentPaths).add(entry.getName()).build();
ImmutableSet<ArchiveEntry> subEntries = walk(bis, allEntries, nextParentPaths);
builder.setSubEntries(subEntries);
}
}
ArchiveEntry archiveEntry = builder.build();
entries.add(archiveEntry);
allEntries.add(archiveEntry);
zipStream.closeEntry();
entry = zipStream.getNextEntry();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
IOUtils.closeQuietly(zipStream);
}
return entries.build();
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class GUtil method loadProperties.
public static Properties loadProperties(URL url) {
try {
URLConnection uc = url.openConnection();
uc.setUseCaches(false);
return loadProperties(uc.getInputStream());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
Aggregations