@Nullable private static MavenPluginInfo createPluginDocument(File file) { try { if (!file.exists()) return null; ZipFile jar = new ZipFile(file); ZipEntry entry = jar.getEntry(MAVEN_PLUGIN_DESCRIPTOR); if (entry == null) { MavenLog.LOG.info(IndicesBundle.message("repository.plugin.corrupt", file)); return null; } InputStream is = jar.getInputStream(entry); try { return new MavenPluginInfo(is); } finally { is.close(); jar.close(); } } catch (IOException e) { MavenLog.LOG.info(e); return null; } }
private static String resolveVersion(File pluginDir) { List<String> versions = new ArrayList<String>(); File[] children; try { children = pluginDir.listFiles(); if (children == null) return ""; } catch (Exception e) { MavenLog.LOG.warn(e); return ""; } for (File version : children) { if (version.isDirectory()) { versions.add(version.getName()); } } if (versions.isEmpty()) return ""; Collections.sort(versions); return versions.get(versions.size() - 1); }
public static void showError(Project project, String title, Throwable e) { MavenLog.LOG.warn(title, e); Notifications.Bus.notify( new Notification(MAVEN_NOTIFICATION_GROUP, title, e.getMessage(), NotificationType.ERROR), project); }