use of org.revapi.Archive in project revapi by revapi.
the class Compiler method copyArchives.
private IdentityHashMap<Archive, File> copyArchives(Iterable<? extends Archive> archives, File parentDir, int startIdx, int prefixLength) {
IdentityHashMap<Archive, File> ret = new IdentityHashMap<>();
if (archives == null) {
return ret;
}
for (Archive a : archives) {
String name = formatName(startIdx++, prefixLength, a.getName());
File f = new File(parentDir, name);
ret.put(a, f);
if (f.exists()) {
LOG.warn("File " + f.getAbsolutePath() + " with the data of archive '" + a.getName() + "' already exists." + " Assume it already contains the bits we need.");
continue;
}
Path target = new File(parentDir, name).toPath();
try (InputStream data = a.openStream()) {
Files.copy(data, target);
} catch (IOException e) {
throw new IllegalStateException("Failed to copy class path element: " + a.getName() + " to " + f.getAbsolutePath(), e);
}
}
return ret;
}
use of org.revapi.Archive in project revapi by revapi.
the class BuildTimeReporter method getAllProblemsMessage.
public String getAllProblemsMessage() {
StringBuilder errors = new StringBuilder("The following API problems caused the build to fail:\n");
StringBuilder ignores = new StringBuilder();
for (Report r : allProblems) {
Element element = r.getNewElement();
Archive archive;
if (element == null) {
element = r.getOldElement();
assert element != null;
archive = shouldOutputArchive(oldApi, element.getArchive()) ? element.getArchive() : null;
} else {
archive = shouldOutputArchive(newApi, element.getArchive()) ? element.getArchive() : null;
}
for (Difference d : r.getDifferences()) {
if (isReportable(d)) {
errors.append(d.code).append(": ").append(element.getFullHumanReadableString()).append(": ").append(d.description);
if (archive != null) {
errors.append(" [").append(archive.getName()).append("]");
}
errors.append("\n");
ignores.append("{\n");
ignores.append(" \"code\": \"").append(escape(d.code)).append("\",\n");
if (r.getOldElement() != null) {
ignores.append(" \"old\": \"").append(escape(r.getOldElement())).append("\",\n");
}
if (r.getNewElement() != null) {
ignores.append(" \"new\": \"").append(escape(r.getNewElement())).append("\",\n");
}
for (Map.Entry<String, String> e : d.attachments.entrySet()) {
ignores.append(" \"").append(escape(e.getKey())).append("\": \"").append(escape(e.getValue())).append("\",\n");
}
ignores.append(" \"justification\": <<<<< ADD YOUR EXPLANATION FOR THE NECESSITY OF THIS CHANGE" + " >>>>>\n");
ignores.append("},\n");
}
}
}
if (errors.length() == 0) {
return null;
} else {
ignores.replace(ignores.length() - 2, ignores.length(), "");
return errors.toString() + "\nIf you're using the semver-ignore extension, update your module's version to one compatible " + "with the current changes (e.g. mvn package revapi:update-versions). If you want to " + "explicitly ignore this change and provide a justification for it, add the following JSON snippet " + "to your Revapi configuration under \"revapi.ignore\" path:\n" + ignores.toString();
}
}
Aggregations