use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class TestFile method copyFrom.
public void copyFrom(final URL resource) {
final TestFile testFile = this;
RetryUtil.retry(new Closure(null, null) {
@SuppressWarnings("UnusedDeclaration")
void doCall() {
try {
FileUtils.copyURLToFile(resource, testFile);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
});
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultManifest method read.
private void read(Object manifestPath) {
File manifestFile = fileResolver.resolve(manifestPath);
try {
byte[] manifestBytes = FileUtils.readFileToByteArray(manifestFile);
manifestBytes = prepareManifestBytesForInteroperability(manifestBytes);
// Eventually convert manifest content to UTF-8 before handing it to java.util.jar.Manifest
if (!DEFAULT_CONTENT_CHARSET.equals(contentCharset)) {
manifestBytes = new String(manifestBytes, contentCharset).getBytes(DEFAULT_CONTENT_CHARSET);
}
// Effectively read the manifest
Manifest javaManifest = new Manifest(new ByteArrayInputStream(manifestBytes));
addJavaManifestToAttributes(javaManifest);
addJavaManifestToSections(javaManifest);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultManifest method writeTo.
@Override
public org.gradle.api.java.archives.Manifest writeTo(Object path) {
File manifestFile = fileResolver.resolve(path);
try {
File parentFile = manifestFile.getParentFile();
if (parentFile != null) {
FileUtils.forceMkdir(parentFile);
}
IoActions.withResource(new FileOutputStream(manifestFile), new Action<FileOutputStream>() {
@Override
public void execute(FileOutputStream fileOutputStream) {
writeTo(fileOutputStream);
}
});
return this;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultManifest method writeTo.
static void writeTo(org.gradle.api.java.archives.Manifest manifest, OutputStream outputStream, String contentCharset) {
try {
Manifest javaManifest = generateJavaManifest(manifest.getEffectiveManifest());
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
javaManifest.write(buffer);
byte[] manifestBytes;
if (DEFAULT_CONTENT_CHARSET.equals(contentCharset)) {
manifestBytes = buffer.toByteArray();
} else {
// Convert the UTF-8 manifest bytes to the requested content charset
manifestBytes = buffer.toString(DEFAULT_CONTENT_CHARSET).getBytes(contentCharset);
}
outputStream.write(manifestBytes);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultManifest method writeTo.
@Deprecated
@Override
public DefaultManifest writeTo(Writer writer) {
SingleMessageLogger.nagUserOfDeprecated("Manifest.writeTo(Writer)", "Please use Manifest.writeTo(Object) instead");
try {
Manifest javaManifest = generateJavaManifest(getEffectiveManifest());
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
javaManifest.write(buffer);
String manifestContent = buffer.toString(DEFAULT_CONTENT_CHARSET);
if (!DEFAULT_CONTENT_CHARSET.equals(contentCharset)) {
// Convert the UTF-8 manifest bytes to the requested content charset
manifestContent = new String(manifestContent.getBytes(contentCharset), contentCharset);
}
writer.write(manifestContent);
writer.flush();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return this;
}
Aggregations