Search in sources :

Example 86 with UncheckedIOException

use of org.gradle.api.UncheckedIOException in project gradle by gradle.

the class GUtil method serialize.

public static void serialize(Object object, OutputStream outputStream) {
    try {
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
        objectOutputStream.writeObject(object);
        objectOutputStream.close();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Example 87 with UncheckedIOException

use of org.gradle.api.UncheckedIOException in project gradle by gradle.

the class GUtil method loadProperties.

public static Properties loadProperties(InputStream inputStream) {
    Properties properties = new Properties();
    try {
        properties.load(inputStream);
        inputStream.close();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return properties;
}
Also used : UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) Properties(java.util.Properties)

Example 88 with UncheckedIOException

use of org.gradle.api.UncheckedIOException in project gradle by gradle.

the class DefaultBuildCacheTempFileStore method withTempFile.

@Override
public void withTempFile(BuildCacheKey key, Action<? super File> action) {
    String hashCode = key.getHashCode();
    File tempFile = null;
    try {
        try {
            tempFile = File.createTempFile(hashCode + "-", PARTIAL_FILE_SUFFIX, dir);
        } catch (IOException ex) {
            throw new UncheckedIOException(ex);
        }
        action.execute(tempFile);
    } finally {
        GFileUtils.deleteQuietly(tempFile);
    }
}
Also used : UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) File(java.io.File)

Example 89 with UncheckedIOException

use of org.gradle.api.UncheckedIOException in project gradle by gradle.

the class FileToArchiveEntrySetTransformer method transform.

public Set<ArchiveEntry> transform(File archiveFile) {
    FileInputStream fileInputStream;
    try {
        fileInputStream = new FileInputStream(archiveFile);
    } catch (FileNotFoundException e) {
        throw new UncheckedIOException(e);
    }
    ImmutableSet.Builder<ArchiveEntry> allEntries = ImmutableSet.builder();
    walk(fileInputStream, allEntries, ImmutableList.<String>of());
    return allEntries.build();
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) UncheckedIOException(org.gradle.api.UncheckedIOException)

Example 90 with UncheckedIOException

use of org.gradle.api.UncheckedIOException in project gradle by gradle.

the class CacheBackedTaskHistoryRepository method snapshotDiscoveredInputs.

private static FileCollectionSnapshot snapshotDiscoveredInputs(Task task, InputNormalizationStrategy normalizationStrategy, Collection<File> discoveredInputs, FileCollectionSnapshotterRegistry snapshotterRegistry, FileCollectionFactory fileCollectionFactory) {
    FileCollectionSnapshotter snapshotter = snapshotterRegistry.getSnapshotter(GenericFileNormalizer.class);
    if (discoveredInputs.isEmpty()) {
        LOGGER.debug("No discovered inputs for {}", task);
        return EmptyFileCollectionSnapshot.INSTANCE;
    }
    LOGGER.debug("Snapshotting discovered inputs for {}", task);
    try {
        return snapshotter.snapshot(fileCollectionFactory.fixed("Discovered input files", discoveredInputs), ABSOLUTE, normalizationStrategy);
    } catch (Exception e) {
        throw new UncheckedIOException(String.format("Failed to capture snapshot of discovered input files for %s during up-to-date check.", task), e);
    }
}
Also used : UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException)

Aggregations

UncheckedIOException (org.gradle.api.UncheckedIOException)101 IOException (java.io.IOException)79 File (java.io.File)32 InputStream (java.io.InputStream)9 FileOutputStream (java.io.FileOutputStream)7 OutputStream (java.io.OutputStream)7 BufferedReader (java.io.BufferedReader)6 StringReader (java.io.StringReader)6 FileInputStream (java.io.FileInputStream)5 Matcher (java.util.regex.Matcher)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 URI (java.net.URI)4 URL (java.net.URL)4 ArrayList (java.util.ArrayList)4 Manifest (java.util.jar.Manifest)4 ZipInputStream (java.util.zip.ZipInputStream)4 FileVisitDetails (org.gradle.api.file.FileVisitDetails)4 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 FileReader (java.io.FileReader)3