use of com.typelead.gradle.utils.EtaInfo in project gradle-eta by typelead.
the class EtaSetupEnvironment method fetchEtaInfo.
private EtaInfo fetchEtaInfo(EtlasCommand etlas, ResolvedExecutable eta, boolean changed) {
File infoFile = getProject().getLayout().getBuildDirectory().file(INFO_FILENAME).get().getAsFile();
List<String> lines;
if (!infoFile.exists() || changed) {
lines = etlas.getLanguagesAndExtensions();
final StringBuilder sb = new StringBuilder();
for (String line : lines) {
println(sb, line);
}
FileUtils.write(infoFile, sb.toString());
} else {
try {
lines = new ArrayList<String>();
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(infoFile));
String line = null;
while ((line = in.readLine()) != null) {
lines.add(line);
}
} finally {
if (in != null) {
in.close();
}
}
} catch (IOException io) {
throw new GradleException("fetchEtaInfo: While reading " + infoFile.getPath() + ", encountered an IOException", io);
}
}
Set<String> validLanguages = new LinkedHashSet<String>();
Set<String> validExtensions = new LinkedHashSet<String>();
Iterator<String> it = lines.iterator();
validLanguages.add(it.next());
validLanguages.add(it.next());
while (it.hasNext()) {
validExtensions.add(it.next());
}
return new EtaInfo(PrintHelper.friendlyVersion(eta.getVersion()), validLanguages, validExtensions);
}
Aggregations