Returns a simple jar manifest.
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;
  }
70448
protected function getJar()
	{
		if ($this->parentEnabled)
		{
			return array_merge($this->parent->getJar(), $this->jar);
		}
		else
		{
			return $this->jar;
		}
	}
380859
def Jar(env, target = None, source = [], *args, **kw):
    

    # jar target should not be a list so assume they passed
    # no target and want implicit target to be made and the arg
    # was actaully the list of sources
    if SCons.Util.is_List(target) and source == []:
        SCons.Warnings.Warning("Making implicit target jar file, " +
                              "and treating the list as sources")
        source = target
        target = None

    # mutiple targets pass so build each target the same from the 
    # same source
    #TODO Maybe this should only be done once, and the result copied
    #     for each target since it should result in the same?
    if SCons.Util.is_List(target) and SCons.Util.is_List(source):
        jars = []
        for single_target in target:
            jars += env.Jar( target = single_target, source = source, *args, **kw)
        return jars

    # they passed no target so make a target implicitly
    if target == None:
        try:
            # make target from the first source file
            target = os.path.splitext(str(source[0]))[0] + env.subst('$JARSUFFIX')
        except:
            # something strange is happening but attempt anyways
            SCons.Warnings.Warning("Could not make implicit target from sources, using directory")
            target = os.path.basename(str(env.Dir('.'))) + env.subst('$JARSUFFIX')

    # make lists out of our target and sources
    if not SCons.Util.is_List(target):
        target = [target]
    if not SCons.Util.is_List(source):
        source = [source]

    # setup for checking through all the sources and handle accordingly
    java_class_suffix = env.subst('$JAVACLASSSUFFIX')
    java_suffix = env.subst('$JAVASUFFIX')
    target_classes = []

    # function for determining what to do with a file and not a directory
    # if its already a class file then it can be used as a
    # source for jar, otherwise turn it into a class file then
    # return the source
    def file_to_class(s):
        if(str(_my_normcase(s)).endswith(java_suffix)):
            return env.JavaClassFile(source = s, *args, **kw)
        else:
            return [env.fs.File(s)]

    # In the case that we are passed just string to a node which is directory
    # but does not exist, we need to check all the current targets to see if
    # that directory is going to exist so we can add it as a source to Jar builder
    def get_all_targets(env, node='.'):
        def get_all_targets_iter(env, node):
            if node.has_builder():
                yield node
            for kid in node.all_children():
                for kid in get_all_targets(env, kid):
                    yield kid
        node = env.arg2nodes(node, env.fs.Entry)[0]
        return list(get_all_targets_iter(env, node))

    # loop through the sources and handle each accordingly
    # the goal here is to get all the source files into a class
    # file or a directory that contains class files
    for s in source:
        s = env.subst(s)
        if isinstance(s, SCons.Node.FS.Base):
            if isinstance(s, SCons.Node.FS.File):
                # found a file so make sure its a class file
                target_classes.extend(file_to_class(s))
            else:
                # found a dir so make sure its a dir of class files
                target_classes.extend(env.JavaClassDir(source = env.fs.Dir(s), *args, **kw))
        else:
            if os.path.isfile(s):
                # found a file that exists on the FS, make sure its a class file
                target_classes.extend(file_to_class(s))
            elif os.path.isdir(s):
                # found a dir on the FS, add it as a dir of class files
                target_classes.append(env.fs.Dir(s))
            elif s[-len(java_suffix):] == java_suffix or s[-len(java_class_suffix):] == java_class_suffix:
                # found a file that may not exists and is only a string
                # so add it after converting it to a class file
                target_classes.extend(file_to_class(s))
            else:
                # found a swig file so add it after converting it to class files
                if(os.path.splitext(str(s))[1] == ".i"):
                    target_classes.extend(env.JavaClassFile(source = s, *args, **kw))
                else:
                    # found a directory that does not yet exist, but can exist as a node
                    # check the target nodes to make sure it will be built, then add
                    # it as a source
                    for node in get_all_targets(env):
                        if(s in str(node) and os.path.splitext(str(node))[1] == ""):
                            target_classes.append(node)
    # at this point all our sources have been converted to classes or directories of class
    # so pass it to the Jar builder
    return env.JarFile(target = target, source = target_classes, *args, **kw)
415202
public static File toJar(File sourceDir, String jarName) {
		if (!sourceDir.isAbsolute()) {
			throw new IllegalArgumentException("Source must be expressed through absolute path");
		}
		Manifest manifest = new Manifest();
		manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
		File jarFile = new File(jarName);
		try {
			JarOutputStream target = new JarOutputStream(new FileOutputStream(jarFile), manifest);
			add(sourceDir, sourceDir.getAbsolutePath().length(), target);
			target.close();
		}
		catch (Exception e) {
			throw new IllegalStateException("Failed to create JAR file '"
					+ jarName + "' from " + sourceDir.getAbsolutePath(), e);
		}
		return jarFile;
	}
109442
protected String resolveJarFile() {
        Class resourceClass = resourceInfo.getResourceClass();
        if (resourceClass == null) return null;
        String classFile = resourceClass.getName().replace(".", "/") + ".class";
        URL classUrl = IOUtils.getResource(classFile);
        String urlProtocol = classUrl.getProtocol();
        if (urlProtocol.equals("jar")) {
            String path = classUrl.getPath();
            return path.substring(0, path.length() - classFile.length() - 1);
        }
        return null;
    }
793153
private static File getToolsJar() {
        String javaHome = System.getProperty("java.home");
        File file = new File(javaHome, "../lib/tools.jar");
        if (!file.exists()) {
            file = new File(javaHome, "lib/tools.jar");
            if (!file.exists()) {
                return null;
            }
        }

        return file;
    }
439561
private void createClasspathJar(File outputFile, String classpath) throws IOException {
        FileOutputStream out = new FileOutputStream(outputFile);
        try {
            Manifest manifest = new Manifest();
            Attributes attrs = manifest.getMainAttributes();
            attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
            attrs.put(Attributes.Name.CLASS_PATH, classpath);
            new JarOutputStream(out, manifest).close();
        } finally {
            out.close();
        }
    }
229884
public static JarClassLoader loadJar(File jarFile) {
		final JarClassLoader loader = new JarClassLoader();
		loader.addJar(jarFile);
		return loader;
	}
755317
def add_main_manifest_entry(jar, binary):
    
    main = binary.main
    if main is not None:
      jar.main(main)
1095091
def _getCleanupCommand(self):
        """"""
        return textwrap.dedent("""\
            set -v
            if [ -d .repo/manifests ]
            then
                # repo just refuse to run if manifest is messed up
                # so ensure we are in a known state
                cd .repo/manifests
                rm -f .git/index.lock
                git fetch origin
                git reset --hard remotes/origin/%(manifestBranch)s
                git config branch.default.merge %(manifestBranch)s
                cd ..
                ln -sf manifests/%(manifestFile)s manifest.xml
                cd ..
             fi
             repo forall -c rm -f .git/index.lock
             repo forall -c git clean -f -d -x 2>/dev/null
             repo forall -c git reset --hard HEAD 2>/dev/null
             rm -f %(workdir)s/.repo/project.list
             """) % dict(manifestBranch=self.manifestBranch,
                         manifestFile=self.manifestFile,
                         workdir=self.workdir)
128125
public static Manifest readManifestFromExternalJar(File jarFile) {
        if (!jarFile.getName().endsWith(".jar")) {
            throw new IllegalArgumentException("not jar file : " + jarFile);
        }
        InputStream in = null;
        String urlStr = "jar:file:" + jarFile.getAbsolutePath() + "!/META-INF/MANIFEST.MF";
          try {
            URL inputURL = new URL(urlStr);
            JarURLConnection conn = (JarURLConnection) inputURL.openConnection();
            in = conn.getInputStream();
            return new Manifest(in);
          } catch (FileNotFoundException e) {
              return null;
          } catch (IOException e) {
              throw new RuntimeException(e);
          } finally {
              IOUtils.closeQuietly(in);
          }
    }
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();
    }
467240
private static String jarFileName() {
        // do this first so we can access extractor, ok to invoke more than once
        createExtractor();
        // get <name> from path/<name>.jar
        String fullyQualifiedFileName = extractor.container.getName();
        int lastSeparator = fullyQualifiedFileName.lastIndexOf(File.separatorChar);
        String simpleFileName = fullyQualifiedFileName.substring(lastSeparator + 1);
        int dotIdx = simpleFileName.lastIndexOf('.');
        if (dotIdx != -1) {
            return simpleFileName.substring(0, simpleFileName.lastIndexOf('.'));
        }
        return simpleFileName;
    }
945058
private JarFile getJarFile(String jarFileUrl) throws IOException {
        if (jarFileUrl.startsWith("file:")) {
            try {
                final URI uri = new URI(jarFileUrl.replaceAll(" ", "\\%20"));
                final String jarFileName = uri.getSchemeSpecificPart();
                logger.info("Creating new JarFile based on URI-scheme filename: {}", jarFileName);
                return new JarFile(jarFileName);
            } catch (URISyntaxException ex) {
                // Fallback for URLs that are not valid URIs (should hardly ever
                // happen).
                final String jarFileName = jarFileUrl.substring("file:".length());
                logger.info("Creating new JarFile based on alternative filename: {}", jarFileName);
                return new JarFile(jarFileName);
            }
        } else {
            logger.info("Creating new JarFile based on URI (with '!/'): {}", jarFileUrl);
            return new JarFile(jarFileUrl);
        }
    }
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;
    }
606952
public static String getApplicationVersionFromJar(Class<?> _class, String _default) {
        try {
            Enumeration<URL> resources = _class.getClassLoader().getResources("META-INF/MANIFEST.MF");
            while (resources.hasMoreElements()) {

                Manifest manifest = new Manifest(resources.nextElement().openStream());
                Attributes attribs = manifest.getMainAttributes();
                String ver = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
                if (ver == null) {
                	return _default;
                }

                String rev = attribs.getValue("Implementation-Revision");
                if (rev != null) {
                    ver += "-r" + rev;
                }
                return ver;

            }
        } catch (IOException _ex) {
        }

        return _default;
    }
1130571
public static Metadata fromManifest(InputStream is) {
        try {
            Manifest mf = new Manifest(is);
            return fromManifest(mf);

        } catch (IOException e) {
            // Problems? Too bad!
        }
        return new Metadata();
    }