use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class SimpleVersionControlSystem method populate.
@Override
public File populate(File versionDir, VersionRef ref, VersionControlSpec spec) {
File sourceDir = ((DirectoryRepositorySpec) spec).getSourceDir();
File workingDir = new File(versionDir, sourceDir.getName());
File checkoutFlag = new File(workingDir, "checkedout");
try {
if (!checkoutFlag.exists()) {
GFileUtils.copyDirectory(sourceDir, workingDir);
checkoutFlag.createNewFile();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return workingDir;
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultTaskExecutionPlan method canonicalizedPaths.
private static ImmutableSet<String> canonicalizedPaths(final Map<File, String> cache, Iterable<File> files) {
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
for (File file : files) {
String path;
try {
path = cache.get(file);
if (path == null) {
path = file.getCanonicalPath();
cache.put(file, path);
}
builder.add(path);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
return builder.build();
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultScriptSourceHasher method hash.
@Override
public HashCode hash(ScriptSource scriptSource) {
TextResource resource = scriptSource.getResource();
File file = resource.getFile();
if (file != null) {
try {
return fileHasher.hash(file);
} catch (UncheckedIOException e) {
if (e.getCause() instanceof FileNotFoundException) {
throw new UncheckedIOException("Could not read " + scriptSource.getDisplayName() + " as it does not exist.", e.getCause());
}
throw e;
}
}
Hasher hasher = contentHasherFactory.create();
hasher.putString(resource.getText());
return hasher.hash();
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class ValueSnapshotter method serialize.
private SerializedValueSnapshot serialize(Object value) {
ByteArrayOutputStream outputStream;
try {
outputStream = new ByteArrayOutputStream();
ObjectOutputStream objectStr = new ObjectOutputStream(outputStream);
objectStr.writeObject(value);
objectStr.flush();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return new SerializedValueSnapshot(classLoaderHasher.getClassLoaderHash(value.getClass().getClassLoader()), outputStream.toByteArray());
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultModuleRegistry method loadModuleProperties.
private Properties loadModuleProperties(String name, File jarFile) {
try {
ZipFile zipFile = new ZipFile(jarFile);
try {
final String entryName = name + "-classpath.properties";
ZipEntry entry = zipFile.getEntry(entryName);
if (entry == null) {
throw new IllegalStateException("Did not find " + entryName + " in " + jarFile.getAbsolutePath());
}
return GUtil.loadProperties(zipFile.getInputStream(entry));
} finally {
zipFile.close();
}
} catch (IOException e) {
throw new UncheckedIOException(String.format("Could not load properties for module '%s' from %s", name, jarFile), e);
}
}
Aggregations