Trying to find the manifest of "exploded plugin" in the current dir, "standard jar" manifest
location or "standard" Eclipse location (sibling to the current classpath)
979296
@CheckForNull
    private static File guessManifest(@Nonnull File parent) {
        File file = new File(parent, "MANIFEST.MF");
        if(!file.isFile()){
            file = new File(parent, "META-INF/MANIFEST.MF");
        }
        if(!file.isFile()){
            file = new File(parent, "../META-INF/MANIFEST.MF");
        }
        if(file.isFile()){
            return file;
        }
        return null;
    }
674593
static ClassLoader findClassLoader()
        throws ConfigurationError
    { 
        SecuritySupport ss = SecuritySupport.getInstance();

        // Figure out which ClassLoader to use for loading the provider
        // class.  If there is a Context ClassLoader then use it.
        ClassLoader context = ss.getContextClassLoader();
        ClassLoader system = ss.getSystemClassLoader();

        ClassLoader chain = system;
        while (true) {
            if (context == chain) {
                // Assert: we are on JDK 1.1 or we have no Context ClassLoader
                // or any Context ClassLoader in chain of system classloader
                // (including extension ClassLoader) so extend to widest
                // ClassLoader (always look in system ClassLoader if Xalan
                // is in boot/extension/system classpath and in current
                // ClassLoader otherwise); normal classloaders delegate
                // back to system ClassLoader first so this widening doesn't
                // change the fact that context ClassLoader will be consulted
                ClassLoader current = ObjectFactory.class.getClassLoader();

                chain = system;
                while (true) {
                    if (current == chain) {
                        // Assert: Current ClassLoader in chain of
                        // boot/extension/system ClassLoaders
                        return system;
                    }
                    if (chain == null) {
                        break;
                    }
                    chain = ss.getParentClassLoader(chain);
                }

                // Assert: Current ClassLoader not in chain of
                // boot/extension/system ClassLoaders
                return current;
            }

            if (chain == null) {
                // boot ClassLoader reached
                break;
            }

            // Check for any extension ClassLoaders in chain up to
            // boot ClassLoader
            chain = ss.getParentClassLoader(chain);
        };

        // Assert: Context ClassLoader not in chain of
        // boot/extension/system ClassLoaders
        return context;
    }
1257603
function parseManifest(manifest, docroot, callback)
{
  var inCache = false
    , lines = [];

    // get manifest file data
    fs.readFile(manifest, 'ascii', function(err, data)
    {
      var counter = 0;

      if (err)
      {
        // to prevent sudden continuation
        return callback(err);
      }

      cache[manifest] =
      {
        version: 0,
        files: [],
        manifest: data
      };

      lines = data.split('\n');

      lines.forEach(function(line)
      {
        var match;

        line = line.trim();

        // empty lines
        if (line.substr(0, 1) == '') return;

        // skip comments
        if (line.substr(0, 1) == '#') return;

        // process control keywords
        switch (line)
        {
          case 'CACHE MANIFEST':
          case 'CACHE:':
            inCache = true;
            return;
            break;

          // TODO: Add proper support for fallbacks
          case 'NETWORK:':
          case 'FALLBACK:':
            inCache = false;
            return;
            break;
        }

        // do nothing for network files
        if (!inCache) return;

        // check the file and setup monitoring
        if (!line.match(/^http(s)?:\/\//))
        {
          addWatcher(docroot+line, watcher(manifest), function(added, mtime)
          {
            // undo counter
            counter--;

            if (!added)
            {
              // check if everything is done
              if (counter == 0) callback();
              return;
            }

            if (mtime > cache[manifest].version) cache[manifest].version = mtime;

            cache[manifest].files.push(line);

            // check if everything is done
            if (counter == 0) callback();
          });

          // track inception
          counter++;
        }

      });
    });
}
749487
private Class lookupVirtualMachineClass() {
        try {
            return ToolsClassFinder.lookupClass("com.sun.tools.attach.VirtualMachine");
        } catch (ClassNotFoundException exp) {
            throw new ProcessingException(
                    "Cannot find classes from tools.jar. The heuristics for loading tools.jar which contains\n" +
                    "essential classes for attaching to a running JVM could locate the necessary jar file.\n" +
                    "\n" +
                    "Please call this launcher with a qualified classpath on the command line like\n" +
                    "\n" +
                    "   java -cp path/to/tools.jar:" + options.getJarFileName() + " org.jolokia.jvmagent.client.AgentLauncher [options] <command> <ppid>\n",
                    exp,
                    options);
        }
    }
139109
def jarSources(target, source, env, for_signature):
    """"""
    try:
        env['JARCHDIR']
    except KeyError:
        jarchdir_set = False
    else:
        jarchdir_set = True
        jarchdir = env.subst('$JARCHDIR', target=target, source=source)
        if jarchdir:
            jarchdir = env.fs.Dir(jarchdir)
    result = []
    for src in source:
        contents = src.get_text_contents()
        if contents[:16] != "Manifest-Version":
            if jarchdir_set:
                _chdir = jarchdir
            else:
                try:
                    _chdir = src.attributes.java_classdir
                except AttributeError:
                    _chdir = None
            if _chdir:
                # If we are changing the dir with -C, then sources should
                # be relative to that directory.
                src = SCons.Subst.Literal(src.get_path(_chdir))
                result.append('-C')
                result.append(_chdir)
            result.append(src)
    return result
8394
private static Manifest standardSoyJarManifest() {
    Manifest mf = new Manifest();
    mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
    mf.getMainAttributes().put(new Attributes.Name("Created-By"), "soy");
    return mf;
  }
293267
private ClassLoader expandClasspath(ExtendedEmailPublisherContext context, ClassLoader loader) throws IOException {
        List<ClasspathEntry> classpathList = new ArrayList<>();
        if (classpath != null && !classpath.isEmpty()) {
            transformToClasspathEntries(classpath, context, classpathList);
        }

        List<GroovyScriptPath> globalClasspath = getDescriptor().getDefaultClasspath();
        if (globalClasspath != null && !globalClasspath.isEmpty()) {
            transformToClasspathEntries(globalClasspath, context, classpathList);
        }

        boolean useSecurity = Jenkins.getActiveInstance().isUseSecurity();
        if (!classpathList.isEmpty()) {
            GroovyClassLoader gloader = new GroovyClassLoader(loader);
            gloader.setShouldRecompile(true);
            for (ClasspathEntry entry : classpathList) {
                if (useSecurity) {
                    ScriptApproval.get().using(entry);
                }
                gloader.addURL(entry.getURL());
            }
            loader = gloader;
        }
        if (useSecurity) {
            return GroovySandbox.createSecureClassLoader(loader);
        } else {
            return loader;
        }
    }
1127223
public function findManifests(){
        foreach ($this->src as $component => $source) {
            $src = $source[0]."/../manifest.php";
            if( file_exists($src) && is_readable($src) ){
                $this->manifests[$component] = $src;
            }
        }
    }
1151522
@GwtIncompatible("Unnecessary")
  private void outputManifestOrBundle(List<String> outputFiles, boolean isManifest)
      throws IOException {
    if (outputFiles.isEmpty()) {
      return;
    }

    for (String output : outputFiles) {
      if (output.isEmpty()) {
        continue;
      }

      if (shouldGenerateOutputPerModule(output)) {
        // Generate per-module manifests or bundles
        Iterable<JSModule> modules = compiler.getModuleGraph().getAllModules();
        for (JSModule module : modules) {
          try (Writer out = fileNameToOutputWriter2(expandCommandLinePath(output, module))) {
            if (isManifest) {
              printManifestTo(module.getInputs(), out);
            } else {
              printBundleTo(module.getInputs(), out);
            }
          }
        }
      } else {
        // Generate a single file manifest or bundle.
        try (Writer out = fileNameToOutputWriter2(expandCommandLinePath(output, null))) {
          if (config.module.isEmpty()) {
            if (isManifest) {
              printManifestTo(compiler.getInputsInOrder(), out);
            } else {
              printBundleTo(compiler.getInputsInOrder(), out);
            }
          } else {
            printModuleGraphManifestOrBundleTo(compiler.getModuleGraph(), out, isManifest);
          }
        }
      }
    }
  }
1231870
@SuppressWarnings( "unchecked" )
    public static String createClassPath( MavenProject project, List<Artifact> pluginArtifacts, List<String> outDirs )
    {
        String cp = new String();
        Set<Artifact> classPathElements = Collections.synchronizedSet( new LinkedHashSet<Artifact>() );
        Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
        classPathElements.addAll( dependencyArtifacts == null ? Collections.<Artifact>emptySet() : dependencyArtifacts );
        classPathElements.addAll( project.getArtifacts() );
        classPathElements.addAll( pluginArtifacts == null ? Collections.<Artifact>emptySet() : pluginArtifacts );
        for ( Artifact classPathElement  : classPathElements )
        {
            File artifact = classPathElement.getFile();
            if ( null != artifact )
            {
              String type = classPathElement.getType();
              if (!type.equals("pom")){
                cp += classPathElement.getFile().getAbsolutePath();
                cp += File.pathSeparatorChar;                
              }
            }
        }
        Iterator<String> outIter = outDirs.iterator();
        while ( outIter.hasNext() )
        {
            cp += outIter.next();
            cp += File.pathSeparatorChar;
        }

        if ( cp.endsWith( "" + File.pathSeparatorChar ) )
        {
            cp = cp.substring( 0, cp.length() - 1 );
        }

        cp = StringUtils.replace( cp, "//", "/" );
        return cp;
    }
670204
private String parseManifestForAppliesTo(File file) throws RepositoryArchiveIOException {

        Manifest mf = null;
        try (JarFile jar = new JarFile(file)) {
            try {
                mf = jar.getManifest();
            } catch (IOException ioe) {
                throw new RepositoryArchiveIOException("Error getting manifest from jar " + jar.getName(), new File(jar.getName()), ioe);
            }
        } catch (IOException ioe) {
            throw new RepositoryArchiveIOException("Unable to create JarFile from path " +
                                                   file, new File(file.getName()), ioe);
        }

        String appliesTo = null;

        Attributes mainattrs = mf.getMainAttributes();
        // Iterate over the main attributes in the manifest and look for the ones we
        // are interested in.
        for (Object at : mainattrs.keySet()) {
            String attribName = ((Attributes.Name) at).toString();
            String attribValue = (String) mainattrs.get(at);

            if (APPLIES_TO.equals(attribName)) {
                appliesTo = attribValue;
            }
        }

        return appliesTo;
    }
42957
function AndroidManifest(output, path) {

    this._output = output;
    this._path = path;

    var doc = this.read();
    this._package = doc.documentElement.getAttribute("package");
    this._versionCode = doc.documentElement.getAttribute("android:versionCode");
    this._versionName = doc.documentElement.getAttribute("android:versionName");

    this._applicationIcon = null;
    var appNode = this.findApplicationNode(doc);
    if (appNode) {
        this._applicationIcon = appNode.getAttribute("android:icon");
    }

    this._applicationLabel = null;
    appNode = this.findApplicationNode(doc);
    if (appNode) {
        this._applicationLabel = appNode.getAttribute("android:label");
    }

    var activityNode = this.findChildNode(appNode, "activity");
    if (activityNode) {
        this._screenOrientation = activityNode.getAttribute("android:screenOrientation");
    }

    // TODO read other values from manifest and initialize members
}
170868
private static File findToolsJar() {
        String javaHome = System.getProperty("java.home");
        File javaHomeFile = new File(javaHome);
        File toolsJarFile = new File(javaHomeFile, "lib" + File.separator + TOOLS_JAR_NAME);

        if (!toolsJarFile.exists()) {
            toolsJarFile = new File(System.getenv("java_home"), "lib" + File.separator + TOOLS_JAR_NAME);
        }

        if (!toolsJarFile.exists() && javaHomeFile.getAbsolutePath().endsWith(File.separator + "jre")) {
            javaHomeFile = javaHomeFile.getParentFile();
            toolsJarFile = new File(javaHomeFile, "lib" + File.separator + TOOLS_JAR_NAME);
        }

        if (!toolsJarFile.exists() && isMac() && javaHomeFile.getAbsolutePath().endsWith(File.separator + "Home")) {
            javaHomeFile = javaHomeFile.getParentFile();
            toolsJarFile = new File(javaHomeFile, "Classes" + File.separator + CLASSES_JAR_NAME);
        }

        return toolsJarFile;
    }
683441
def is_jar(path):
        
        if os.path.isfile(path) and zipfile.is_zipfile(path):
            try:
                with zipfile.ZipFile(path) as f:
                    if "META-INF/MANIFEST.MF" in f.namelist():
                        return True
            except (IOError, zipfile.BadZipfile):
                pass
        return False
834640
protected Manifest getJarManifest(String assetId) throws IOException {
        File zipFile = new File(_root, assetId);
        ZipFile zip = DirectoryUtils.createZipFile(zipFile);

        String mfName = "meta-inf/manifest.mf";
        Manifest manifest = new Manifest();
        FileInputStream fis = DirectoryUtils.createFileInputStream(zipFile);
        ZipInputStream zis = new ZipInputStream(fis);
        try {
            ZipEntry ze = zis.getNextEntry();
            while (ze != null) {
                if (ze.isDirectory()) {
                    // Do nothing with pure directory entries
                } else {
                    String fileName = ze.getName();
                    if (fileName.equalsIgnoreCase(mfName)) {
                        InputStream is = zip.getInputStream(ze);
                        manifest.read(is);
                    }
                }
                ze = zis.getNextEntry();
            }
        } finally {
            zis.closeEntry();
            zis.close();
            zip.close();
        }

        return manifest;
    }
773530
protected String getExecutableJar() throws IOException {
        Manifest manifest = new Manifest();
        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, MAIN);
        manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, getClasspath());

        Path jar = createTempDirectory("exec").resolve("generate.jar");
        try (JarOutputStream output = new JarOutputStream(Files.newOutputStream(jar), manifest)) {
            output.putNextEntry(new JarEntry("allure.properties"));
            Path allureConfig = PROPERTIES.getAllureConfig();
            if (Files.exists(allureConfig)) {
                byte[] bytes = Files.readAllBytes(allureConfig);
                output.write(bytes);
            }
            output.closeEntry();
        }

        return jar.toAbsolutePath().toString();
    }
247307
public void findDuplicateJars() throws IOException, DuplicateJarsException {
        Map<String, List<String>> artifactsToVersion = new HashMap<>();
        Enumeration<URL> manifestURLs = classPathParser.getManifestURLs();
        while (manifestURLs.hasMoreElements()) {
            parseManifestFileFromClassPathEntry(manifestURLs.nextElement(), artifactsToVersion);
        }
        checkForDuplicateJars(artifactsToVersion);
    }