Search in sources :

Example 71 with UncheckedIOException

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

the class DispatchingBuildCacheService method pushToLocalAndRemote.

private void pushToLocalAndRemote(BuildCacheKey key, BuildCacheEntryWriter writer) {
    File destination = temporaryFileProvider.createTemporaryFile("gradle_cache", "entry");
    try {
        writeCacheEntryLocally(writer, destination);
        BuildCacheEntryWriter copier = new CopyBuildCacheEntryWriter(destination);
        local.store(key, copier);
        remote.store(key, copier);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    } finally {
        GFileUtils.deleteQuietly(destination);
    }
}
Also used : UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) File(java.io.File) BuildCacheEntryWriter(org.gradle.caching.BuildCacheEntryWriter)

Example 72 with UncheckedIOException

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

the class DefaultCacheAwareExternalResourceAccessor method getResourceSha1.

private HashValue getResourceSha1(URI location, boolean revalidate) {
    try {
        URI sha1Location = new URI(location.toASCIIString() + ".sha1");
        ExternalResource resource = delegate.getResource(sha1Location, revalidate);
        if (resource == null) {
            return null;
        }
        try {
            return resource.withContent(new Transformer<HashValue, InputStream>() {

                @Override
                public HashValue transform(InputStream inputStream) {
                    try {
                        String sha = IOUtils.toString(inputStream, "us-ascii");
                        return HashValue.parse(sha);
                    } catch (IOException e) {
                        throw new UncheckedIOException(e);
                    }
                }
            });
        } finally {
            resource.close();
        }
    } catch (Exception e) {
        throw new ResourceException(location, String.format("Failed to download SHA1 for resource '%s'.", location), e);
    }
}
Also used : InputStream(java.io.InputStream) UncheckedIOException(org.gradle.api.UncheckedIOException) ResourceException(org.gradle.api.resources.ResourceException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) HashValue(org.gradle.internal.hash.HashValue) URI(java.net.URI) DefaultLocallyAvailableExternalResource(org.gradle.internal.resource.local.DefaultLocallyAvailableExternalResource) LocallyAvailableExternalResource(org.gradle.internal.resource.local.LocallyAvailableExternalResource) ExternalResource(org.gradle.internal.resource.ExternalResource) CachedExternalResource(org.gradle.internal.resource.cached.CachedExternalResource) UncheckedIOException(org.gradle.api.UncheckedIOException) ResourceException(org.gradle.api.resources.ResourceException) IOException(java.io.IOException)

Example 73 with UncheckedIOException

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

the class ReportGenerator method generateReport.

public void generateReport(Set<Project> projects) {
    try {
        ReportRenderer renderer = getRenderer();
        renderer.setClientMetaData(getClientMetaData());
        File outputFile = getOutputFile();
        if (outputFile != null) {
            renderer.setOutputFile(outputFile);
        } else {
            renderer.setOutput(getTextOutputFactory().create(getClass()));
        }
        for (Project project : projects) {
            renderer.startProject(project);
            projectReportGenerator.generateReport(project);
            renderer.completeProject(project);
        }
        renderer.complete();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : Project(org.gradle.api.Project) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) File(java.io.File)

Example 74 with UncheckedIOException

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

the class DefaultDeploymentDescriptor method readFrom.

@Override
public boolean readFrom(Object path) {
    if (fileResolver == null) {
        return false;
    }
    File descriptorFile = fileResolver.resolve(path);
    if (descriptorFile == null || !descriptorFile.exists()) {
        return false;
    }
    try {
        FileReader reader = new FileReader(descriptorFile);
        readFrom(reader);
        return true;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : FileReader(java.io.FileReader) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) File(java.io.File)

Example 75 with UncheckedIOException

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

the class PathFactory method getPathList.

private static List<String> getPathList(File f) {
    try {
        List<String> list = Lists.newArrayList();
        File r = f.getCanonicalFile();
        while (r != null) {
            File parent = r.getParentFile();
            list.add(parent != null ? r.getName() : r.getAbsolutePath());
            r = parent;
        }
        return list;
    } catch (IOException ex) {
        throw new UncheckedIOException(ex);
    }
}
Also used : UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) File(java.io.File)

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