Java 类org.apache.tools.ant.taskdefs.Manifest 实例源码

项目:nbm-maven    文件:NetBeansManifestUpdateMojo.java   
String conditionallyAddAttribute( Manifest.Section section, String key, String value )
{
    Manifest.Attribute attr = section.getAttribute( key );
    if ( attr == null )
    {
        attr = new Manifest.Attribute();
        attr.setName( key );
        attr.setValue( value != null ? value.replaceAll("\\s+", " ").trim() : "<undefined>" );
        try
        {
            section.addConfiguredAttribute( attr );
        }
        catch ( ManifestException ex )
        {
            getLog().error( "Cannot update manifest (key=" + key + ")" );
            ex.printStackTrace();
        }
    }
    return attr.getValue();
}
项目:japp-maven-plugin    文件:JAppJavaWorker.java   
void createManifest() {
    this.manifestFile = new File(scratchDir(), "MANIFEST.MF");

    Manifest.Attribute mainClass = new Manifest.Attribute();
    mainClass.setName("Main-Class");
    mainClass.setValue(parent.getMainClass());

    ManifestTask manifest = createTask(ManifestTask.class);
    manifest.setFile(manifestFile);
    try {
        manifest.addConfiguredAttribute(mainClass);
    } catch (ManifestException e) {
        throw new BuildException("Manifest error", e);
    }

    manifest.execute();
}
项目:incubator-netbeans    文件:CslJar.java   
@Override
public void addConfiguredManifest(Manifest newManifest) throws ManifestException {
    super.addConfiguredManifest(newManifest);
    this.mf = newManifest;

    layer = mf.getMainSection().getAttributeValue("OpenIDE-Module-Layer"); // NOI18N
}
项目:incubator-netbeans    文件:CopyLibs.java   
private static boolean isSigned(final Manifest manifest) {
    Section section = manifest.getSection(MANIFEST);
    if (section != null) {
        final Enumeration<String> sectionKeys = (Enumeration<String>) section.getAttributeKeys();
        while (sectionKeys.hasMoreElements()) {
            if (sectionKeys.nextElement().endsWith("-Digest")) {    //NOI18N
                return true;
            }
        }
    }
    return false;
}
项目:jetty-console    文件:DefaultCreator.java   
private Manifest createManifest() throws ManifestException {
    Manifest manifest = new Manifest();
    manifest.addConfiguredAttribute(new Manifest.Attribute("Main-Class", MAIN_CLASS));

    for (Map.Entry<String, String> entry : manifestEntries.entrySet())
        manifest.addConfiguredAttribute(new Manifest.Attribute(entry.getKey(), entry.getValue()));

    return manifest;
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addAttributesToAnt(Manifest antManifest) {
    for (Map.Entry<String, Object> entry : attributes.entrySet()) {
        try {
            antManifest.addConfiguredAttribute(new Attribute(entry.getKey(), entry.getValue().toString()));
        } catch (ManifestException e) {
            throw new org.gradle.api.java.archives.ManifestException(e.getMessage(), e);
        }
    }
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addSectionAttributesToAnt(Manifest antManifest) {
    for (Map.Entry<String, Attributes> entry : sections.entrySet()) {
        Section section = new Section();
        section.setName(entry.getKey());
        try {
            antManifest.addConfiguredSection(section);
            for (Map.Entry<String, Object> attributeEntry : entry.getValue().entrySet()) {
                section.addConfiguredAttribute(new Attribute(attributeEntry.getKey(), attributeEntry.getValue().toString()));
            }
        } catch (ManifestException e) {
            throw new org.gradle.api.java.archives.ManifestException(e.getMessage(), e);
        }
    }
}
项目:Pushjet-Android    文件:DefaultManifest.java   
public org.gradle.api.java.archives.Manifest writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            writeTo(writer);
        }
    });
    return this;
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addAntManifestToAttributes(Manifest antManifest) {
    Enumeration<String> attributeKeys = antManifest.getMainSection().getAttributeKeys();
    while (attributeKeys.hasMoreElements()) {
        String key = attributeKeys.nextElement();
        String attributeKey = antManifest.getMainSection().getAttribute(key).getName();
        attributes.put(attributeKey, antManifest.getMainSection().getAttributeValue(key));
    }
    attributes.put("Manifest-Version", antManifest.getManifestVersion());
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addAntManifestToSections(Manifest antManifest) {
    Enumeration<String> sectionNames = antManifest.getSectionNames();
    while (sectionNames.hasMoreElements()) {
        String sectionName = sectionNames.nextElement();
        addAntManifestToSection(antManifest, sectionName);
    }
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addAntManifestToSection(Manifest antManifest, String sectionName) {
    DefaultAttributes attributes = new DefaultAttributes();
    sections.put(sectionName, attributes);
    Enumeration<String> attributeKeys = antManifest.getSection(sectionName).getAttributeKeys();
    while (attributeKeys.hasMoreElements()) {
        String key = attributeKeys.nextElement();
        String attributeKey = antManifest.getSection(sectionName).getAttribute(key).getName();
        attributes.put(attributeKey, antManifest.getSection(sectionName).getAttributeValue(key));
    }
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addAttributesToAnt(Manifest antManifest) {
    for (Map.Entry<String, Object> entry : attributes.entrySet()) {
        try {
            antManifest.addConfiguredAttribute(new Attribute(entry.getKey().toString(), entry.getValue().toString()));
        } catch (ManifestException e) {
            throw new org.gradle.api.java.archives.ManifestException(e.getMessage(), e);
        }
    }
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addSectionAttributesToAnt(Manifest antManifest) {
    for (Map.Entry<String, Attributes> entry : sections.entrySet()) {
        Section section = new Section();
        section.setName(entry.getKey());
        try {
            antManifest.addConfiguredSection(section);
            for (Map.Entry<String, Object> attributeEntry : entry.getValue().entrySet()) {
                section.addConfiguredAttribute(new Attribute(attributeEntry.getKey().toString(), attributeEntry.getValue().toString()));
            }
        } catch (ManifestException e) {
            throw new org.gradle.api.java.archives.ManifestException(e.getMessage(), e);
        }
    }
}
项目:Pushjet-Android    文件:DefaultManifest.java   
public org.gradle.api.java.archives.Manifest writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            writeTo(writer);
        }
    });
    return this;
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addAntManifestToAttributes(Manifest antManifest) {
    Enumeration attributeKeys = antManifest.getMainSection().getAttributeKeys();
    while (attributeKeys.hasMoreElements()) {
        String key = (String) attributeKeys.nextElement();
        String attributeKey = antManifest.getMainSection().getAttribute(key).getName();
        attributes.put(attributeKey, antManifest.getMainSection().getAttributeValue(key));
    }
    attributes.put("Manifest-Version", antManifest.getManifestVersion());
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addAntManifestToSections(Manifest antManifest) {
    Enumeration sectionNames = antManifest.getSectionNames();
    while (sectionNames.hasMoreElements()) {
        String sectionName = (String) sectionNames.nextElement();
        addAntManifestToSection(antManifest, sectionName);
    }
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private void addAntManifestToSection(Manifest antManifest, String sectionName) {
    DefaultAttributes attributes = new DefaultAttributes();
    sections.put(sectionName, attributes);
    Enumeration attributeKeys = antManifest.getSection(sectionName).getAttributeKeys();
    while (attributeKeys.hasMoreElements()) {
        String key = (String) attributeKeys.nextElement();
        String attributeKey = antManifest.getSection(sectionName).getAttribute(key).getName();
        attributes.put(attributeKey, antManifest.getSection(sectionName).getAttributeValue(key));
    }
}
项目:gephi-maven-plugin    文件:ManifestUtils.java   
/**
 * Check that the given project has the <em>AutoUpdate-Show-In-Client</em>
 * entry set to <em>false</em> in its manifest.
 *
 * @param proj project
 * @throws MojoExecutionException if an error occurs
 */
protected void checkManifestShowClientFalse(MavenProject proj) throws MojoExecutionException {
    Manifest manifest = getManifest(proj);

    Manifest.Section mainSection = manifest.getMainSection();
    String showInClient = mainSection.getAttributeValue("AutoUpdate-Show-In-Client");
    if (showInClient == null || showInClient.isEmpty() || !showInClient.equals("false")) {
        throw new MojoExecutionException("The manifest.mf file for project '" + proj.getName() + "' should contain a 'AutoUpdate-Show-In-Client' entry set at 'false'");
    }
}
项目:nbm-maven    文件:NetBeansManifestUpdateMojoTest.java   
public void testNewlines()
    throws Exception
{
    Manifest m = new Manifest();
    Manifest.Section s = m.getMainSection();
    new NetBeansManifestUpdateMojo().conditionallyAddAttribute( s, "Desc", "Something.\n   Else.\n" );
    assertEquals( "Something. Else.", s.getAttributeValue( "Desc" ));
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private Manifest generateAntManifest() {
    Manifest antManifest = new Manifest();
    addAttributesToAnt(antManifest);
    addSectionAttributesToAnt(antManifest);
    return antManifest;
}
项目:Pushjet-Android    文件:DefaultManifest.java   
private Manifest generateAntManifest() {
    Manifest antManifest = new Manifest();
    addAttributesToAnt(antManifest);
    addSectionAttributesToAnt(antManifest);
    return antManifest;
}
项目:gephi-maven-plugin    文件:ManifestUtils.java   
protected void readManifestMetadata(MavenProject proj, PluginMetadata metadata) throws MojoExecutionException {
    Manifest manifest = getManifest(proj);

    // Read branding attributes
    Manifest.Section mainSection = manifest.getMainSection();
    String brandingName = mainSection.getAttributeValue("OpenIDE-Module-Name");
    String brandingShortDescription = mainSection.getAttributeValue("OpenIDE-Module-Short-Description");
    String brandingLongDescrption = mainSection.getAttributeValue("OpenIDE-Module-Long-Description");
    String brandingDisplayCategory = mainSection.getAttributeValue("OpenIDE-Module-Display-Category");

    //Read localized
    if (mainSection.getAttribute("OpenIDE-Module-Localizing-Bundle") != null) {
        File folder = proj.getBasedir();
        String path = mainSection.getAttributeValue("OpenIDE-Module-Localizing-Bundle");
        File bundlerFile = new File(folder, "src" + File.separator + "main" + File.separator + "resources");
        if (!bundlerFile.exists()) {
            throw new MojoExecutionException("The 'src/main/resources' folder can't be found in '" + folder.getAbsolutePath() + "'");
        }
        bundlerFile = new File(bundlerFile, path.replace('/', File.separatorChar));
        if (!bundlerFile.exists()) {
            throw new MojoExecutionException("The '" + path + "' file can't be found");
        }
        Properties prop = new Properties();
        FileReader bundleReader = null;
        try {
            bundleReader = new FileReader(bundlerFile);
            prop.load(bundleReader);
            brandingName = prop.getProperty("OpenIDE-Module-Name", brandingName);
            brandingDisplayCategory = prop.getProperty("OpenIDE-Module-Display-Category", brandingDisplayCategory);
            brandingShortDescription = prop.getProperty("OpenIDE-Module-Short-Description", brandingShortDescription);
            brandingLongDescrption = prop.getProperty("OpenIDE-Module-Long-Description", brandingLongDescrption);
        } catch (IOException e) {
            throw new MojoExecutionException("Error while reading '" + bundlerFile.getAbsolutePath() + "'", e);
        } finally {
            if (bundleReader != null) {
                try {
                    bundleReader.close();
                } catch (IOException ex) {
                }
            }
        }
    }

    if (brandingName == null || brandingName.isEmpty()) {
        throw new MojoExecutionException("The manifest.mf file for project '" + proj.getName() + "' should contain a 'OpenIDE-Module-Name' entry");
    }
    if (brandingShortDescription == null || brandingShortDescription.isEmpty()) {
        throw new MojoExecutionException("The manifest.mf file for project '" + proj.getName() + "' should contain a 'OpenIDE-Module-Short-Description' entry");
    }
    if (brandingLongDescrption == null || brandingLongDescrption.isEmpty()) {
        throw new MojoExecutionException("The manifest.mf file for project '" + proj.getName() + "' should contain a 'OpenIDE-Module-Long-Description' entry");
    }
    if (brandingDisplayCategory == null || brandingDisplayCategory.isEmpty()) {
        throw new MojoExecutionException("The manifest.mf file for project '" + proj.getName() + "' should contain a 'OpenIDE-Module-Display-Category' entry");
    }

    if (!validateCategory(brandingDisplayCategory)) {
        throw new MojoExecutionException("The manifest entry 'OpenIDE-Module-Display-Category' is '"+brandingDisplayCategory+"' but should be one of the following values: " + Arrays.toString(CATEGORIES).replace("[", "").replace("]", ""));
    }

    metadata.name = brandingName;
    metadata.short_description = brandingShortDescription;
    metadata.long_description = brandingLongDescrption;
    metadata.category = brandingDisplayCategory;
}
项目:birt    文件:PackTask.java   
public void addManifest( Manifest manifest )
{
    this.manifest = manifest;
}