use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class EffectiveClassPath method findAvailableClasspathFiles.
private static List<File> findAvailableClasspathFiles(ClassLoader classLoader) {
List<URL> rawClasspath = ClasspathUtil.getClasspath(classLoader).getAsURLs();
List<File> classpathFiles = new ArrayList<File>();
for (URL url : rawClasspath) {
if (url.getProtocol().equals("file")) {
try {
File classpathFile = new File(url.toURI());
addClasspathFile(classpathFile, classpathFiles);
} catch (URISyntaxException e) {
throw new UncheckedIOException(e);
}
}
}
// from the system classpath
if (classLoader == ClassLoader.getSystemClassLoader()) {
for (String value : System.getProperty("java.class.path").split(File.pathSeparator)) {
addClasspathFile(new File(value), classpathFiles);
}
}
return classpathFiles;
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class ManifestUtil method readManifestClasspathString.
private static String[] readManifestClasspathString(File classpathFile) {
try {
Manifest manifest = findManifest(classpathFile);
if (manifest == null) {
return EMPTY;
}
String classpathEntry = manifest.getMainAttributes().getValue("Class-Path");
if (classpathEntry == null || classpathEntry.trim().length() == 0) {
return EMPTY;
}
return classpathEntry.split(" ");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class ManifestUtil method parseManifestClasspath.
public static List<URI> parseManifestClasspath(File jarFile) {
List<URI> manifestClasspath = new ArrayList<URI>();
for (String value : readManifestClasspathString(jarFile)) {
try {
URI uri = new URI(value);
uri = jarFile.toURI().resolve(uri);
manifestClasspath.add(uri);
} catch (URISyntaxException e) {
throw new UncheckedIOException(e);
}
}
return manifestClasspath;
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultTemporaryFileProvider method createTemporaryFile.
public File createTemporaryFile(String prefix, @Nullable String suffix, String... path) {
File dir = new File(baseDirFactory.create(), CollectionUtils.join("/", path));
GFileUtils.mkdirs(dir);
try {
return File.createTempFile(prefix, suffix, dir);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class FileOrUriNotationConverter method convert.
public void convert(Object notation, NotationConvertResult<? super Object> result) throws TypeConversionException {
if (notation instanceof File) {
result.converted(notation);
return;
}
if (notation instanceof Path) {
result.converted(((Path) notation).toFile());
return;
}
if (notation instanceof URL) {
try {
notation = ((URL) notation).toURI();
} catch (URISyntaxException e) {
throw new UncheckedIOException(e);
}
}
if (notation instanceof URI) {
URI uri = (URI) notation;
if (uri.getScheme().equals("file")) {
result.converted(new File(uri.getPath()));
} else {
result.converted(uri);
}
return;
}
if (notation instanceof CharSequence) {
String notationString = notation.toString();
if (notationString.startsWith("file:")) {
result.converted(new File(uriDecode(notationString.substring(5))));
return;
}
for (File file : File.listRoots()) {
String rootPath = file.getAbsolutePath();
String normalisedStr = notationString;
if (!fileSystem.isCaseSensitive()) {
rootPath = rootPath.toLowerCase();
normalisedStr = normalisedStr.toLowerCase();
}
if (normalisedStr.startsWith(rootPath) || normalisedStr.startsWith(rootPath.replace(File.separatorChar, '/'))) {
result.converted(new File(notationString));
return;
}
}
// Check if string starts with a URI scheme
if (URI_SCHEME.matcher(notationString).matches()) {
try {
result.converted(new URI(notationString));
return;
} catch (URISyntaxException e) {
throw new UncheckedIOException(e);
}
}
result.converted(new File(notationString));
}
}
Aggregations