private String getVersionOf(Manifest manifest) { String v = manifest.getMainAttributes().getValue("Plugin-Version"); if(v!=null) return v; // plugins generated before maven-hpi-plugin 1.3 should still have this attribute v = manifest.getMainAttributes().getValue("Implementation-Version"); if(v!=null) return v; return "???"; }
/** * {@inheritDoc} */ public void close() throws IOException { jarFile.close(); } }
/** * {@inheritDoc} */ public InputStream getInputStream() throws IOException { return file.getInputStream(entry); }
public static String getCruiseVersion(String jar) { String version = null; try { JarFile jarFile = new JarFile(jar); Manifest manifest = jarFile.getManifest(); if (manifest != null) { Attributes attributes = manifest.getMainAttributes(); version = attributes.getValue("Go-Version"); } } catch (IOException e) { } return version; }
@Override protected void scanJarFile(ClassLoader classloader, JarFile file) { Enumeration<JarEntry> entries = file.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) { continue; } resources.get(classloader).add(entry.getName()); } }
private static String defaultMainClassName(JarFile jarFile) throws IOException { return jarFile.getManifest().getMainAttributes().getValue("GoCD-Main-Class"); } }
/** * {@inheritDoc} */ public File toJar(File file) throws IOException { Manifest manifest = new Manifest(); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION); return toJar(file, manifest); }
/** * {@inheritDoc} */ public String getName() { return entry.getName(); }
String getManifestAttribute(String name, String defaultValue) { if (manifest == null) { return defaultValue; } Name attrName = new Name(name); Object value = manifest.getMainAttributes().get(attrName); return value == null ? defaultValue : value.toString(); }
/** * {@inheritDoc} */ public Manifest getManifest() throws IOException { return file.getManifest(); }
/** * {@inheritDoc} */ public void close() throws IOException { outputStream.close(); } }
@Override protected void scanJarFile(ClassLoader loader, JarFile file) throws IOException { this.found = new File(file.getName()); throw new StopScanningException(); }
public String getPluginClass() { return manifest.getMainAttributes().getValue("Plugin-Class"); }
/** * {@inheritDoc} */ public void close() throws IOException { file.close(); }
private static boolean isPluginManifest(Manifest mf) { Attributes attr = mf.getMainAttributes(); return attr.getValue("Short-Name") != null && (attr.getValue("Plugin-Version") != null || attr.getValue("Jenkins-Version") != null) || "true".equals(attr.getValue("Jenkins-ClassFilter-Whitelisted")); }
public void close() { try { jarfile.close(); jarfile = null; } catch (IOException e) {} }
static String computeShortName(Manifest manifest, String fileName) { // use the name captured in the manifest, as often plugins // depend on the specific short name in its URLs. String n = manifest.getMainAttributes().getValue("Short-Name"); if(n!=null) return n; // maven seems to put this automatically, so good fallback to check. n = manifest.getMainAttributes().getValue("Extension-Name"); if(n!=null) return n; // otherwise infer from the file name, since older plugins don't have // this entry. return getBaseName(fileName); }
/** * Returns a one-line descriptive name of this plugin. */ @Exported public String getLongName() { String name = manifest.getMainAttributes().getValue("Long-Name"); if(name!=null) return name; return shortName; }
/** * Does this plugin supports dynamic loading? */ @Exported public YesNoMaybe supportsDynamicLoad() { String v = manifest.getMainAttributes().getValue("Support-Dynamic-Loading"); if (v==null) return YesNoMaybe.MAYBE; return Boolean.parseBoolean(v) ? YesNoMaybe.YES : YesNoMaybe.NO; }