Java Code Examples for org.apache.tools.ant.taskdefs.Manifest#addConfiguredAttribute()

The following examples show how to use org.apache.tools.ant.taskdefs.Manifest#addConfiguredAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
        }
    }
}
 
Example 2
Source File: DefaultManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
        }
    }
}
 
Example 3
Source File: BundleManifestTask.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * If <code>attributePropertyPrefix</code> is set then iterate over
 * all properties and add attributes to the main section of
 * the given manifest for those properties that starts with the prefix.
 *
 * The name of the attribute will be the property name without the
 * prefix and the value will be the property value.
 *
 * @param mf The manifest to add the property based attributes to.
 */
private void addAttributesFromProperties(Manifest mf)
{
  if (null!=attributePropertyPrefix) {
    final int       prefixLength = attributePropertyPrefix.length();
    final Project   project      = getProject();
    final Manifest.Section mainS = mf.getMainSection();
    @SuppressWarnings("unchecked")
    final Hashtable<String,?> properties   = project.getProperties();
    for (final Enumeration<String> pe = properties.keys(); pe.hasMoreElements();) {
      final String key = pe.nextElement();
      if (key.startsWith(attributePropertyPrefix)) {
        final String attrName  = key.substring(prefixLength);
        final String attrValue = (String) properties.get(key);
        if(!BUNDLE_EMPTY_STRING.equals(attrValue)) {
          Manifest.Attribute attr = mainS.getAttribute(attrName);
          if (null!=attr) {
            throw new BuildException
              ( "Can not add main section attribute for property '"
                +key+"' with value '"+attrValue+"' since a "
                +"main section attribute with that name exists: '"
                +attr.getName() +": "+attr.getValue() +"'.",
                getLocation());
          }
          try {
            attr = new Manifest.Attribute(attrName, attrValue);
            mf.addConfiguredAttribute(attr);
            log("from propety '" +attrName +": "+attrValue+"'.",
                Project.MSG_VERBOSE);
          } catch (final ManifestException me) {
            throw new BuildException
              ( "Failed to add main section attribute for property '"
                +key+"' with value '"+attrValue+"'.\n"+me.getMessage(),
                me, getLocation());
          }
        }
      }
    }
  }
}
 
Example 4
Source File: DefaultManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
        }
    }
}
 
Example 5
Source File: DefaultManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
        }
    }
}