use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultJvmVersionDetector method parseJavaVersionCommandOutput.
private JavaVersion parseJavaVersionCommandOutput(String javaExecutable, BufferedReader reader) {
try {
String versionStr = reader.readLine();
while (versionStr != null) {
Matcher matcher = Pattern.compile("(?:java|openjdk) version \"(.+?)\"( \\d{4}-\\d{2}-\\d{2}( LTS)?)?").matcher(versionStr);
if (matcher.matches()) {
return JavaVersion.toVersion(matcher.group(1));
}
versionStr = reader.readLine();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
throw new GradleException(String.format("Could not determine Java version using executable %s.", javaExecutable));
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class GenerateModuleMapFile method generateFile.
public static void generateFile(File moduleMapFile, String moduleName, List<String> publicHeaderDirs) {
List<String> lines = Lists.newArrayList("module " + moduleName + " {");
List<String> validHeaderDirs = filter(publicHeaderDirs, new Spec<String>() {
@Override
public boolean isSatisfiedBy(String path) {
return new File(path).exists();
}
});
lines.addAll(collect(validHeaderDirs, new Transformer<String, String>() {
@Override
public String transform(String path) {
return "\tumbrella \"" + path + "\"";
}
}));
lines.add("\texport *");
lines.add("}");
try {
Files.createParentDirs(moduleMapFile);
FileUtils.writeLines(moduleMapFile, lines);
} catch (IOException e) {
throw new UncheckedIOException("Could not generate a module map for " + moduleName, e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class GccMetadataProvider method determineVendor.
private String determineVendor(String error, VersionNumber versionNumber, File gccBinary) {
BufferedReader reader = new BufferedReader(new StringReader(error));
String majorMinorOnly = versionNumber.getMajor() + "." + versionNumber.getMinor();
String line;
try {
while ((line = reader.readLine()) != null) {
if (line.contains(majorMinorOnly) && line.contains(" version ") && line.contains(compilerType.getIdentifier()) && !line.contains(" default target ")) {
return line;
}
}
} catch (IOException e) {
// Should not happen reading from a StringReader
throw new UncheckedIOException(e);
}
throw new BrokenResultException(String.format("Could not determine %s metadata: could not find vendor in output of %s.", compilerType.getDescription(), gccBinary));
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class GccMetadataProvider method determineSystemIncludes.
private ImmutableList<File> determineSystemIncludes(String error) {
BufferedReader reader = new BufferedReader(new StringReader(error));
String line;
ImmutableList.Builder<File> builder = ImmutableList.builder();
boolean systemIncludesStarted = false;
try {
while ((line = reader.readLine()) != null) {
if (SYSTEM_INCLUDES_END.equals(line)) {
break;
}
if (SYSTEM_INCLUDES_START.equals(line)) {
systemIncludesStarted = true;
continue;
}
if (systemIncludesStarted) {
// Exclude frameworks for CLang - they need to be handled differently
if (compilerType == CLANG && line.contains(FRAMEWORK_INCLUDE)) {
continue;
}
// Exclude framework directories for GCC - they are added as system search paths but they are actually not
if (compilerType == GCC && line.endsWith("/Library/Frameworks")) {
continue;
}
builder.add(new File(line.trim()));
}
}
return builder.build();
} catch (IOException e) {
// Should not happen reading from a StringReader
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class GenerateModuleMetadata method run.
@TaskAction
void run() {
File file = outputFile.get().getAsFile();
PublicationInternal publication = (PublicationInternal) this.publication.get();
List<PublicationInternal> publications = Cast.uncheckedCast(this.publications.get());
try {
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "utf8"));
try {
new ModuleMetadataFileGenerator(getBuildInvocationScopeId(), getProjectDependencyPublicationResolver()).generateTo(publication, publications, writer);
} finally {
writer.close();
}
} catch (IOException e) {
throw new UncheckedIOException("Could not generate metadata file " + outputFile.get(), e);
}
}
Aggregations