git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272207 13f79535-47bb-0310-9956-ffa450edef68master
@@ -0,0 +1,89 @@ | |||
/* | |||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||
* | |||
* This software is published under the terms of the Apache Software License | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE.txt file. | |||
*/ | |||
package org.apache.antlib.extensions; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.myrmidon.api.TaskException; | |||
/** | |||
* Simple holder for extra attributes in main section of manifest. | |||
* | |||
* @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||
* @version $Revision$ $Date$ | |||
* @todo Refactor this and all the other parameter, sysproperty, | |||
* property etc into a single class in framework | |||
*/ | |||
public class ExtraAttribute | |||
{ | |||
private static final Resources REZ = | |||
ResourceManager.getPackageResources( ExtraAttribute.class ); | |||
private String m_name; | |||
private String m_value; | |||
/** | |||
* Set the name of the parameter. | |||
* | |||
* @param name the name of parameter | |||
*/ | |||
public void setName( final String name ) | |||
{ | |||
m_name = name; | |||
} | |||
/** | |||
* Set the value of the parameter. | |||
* | |||
* @param value the parameter value | |||
*/ | |||
public void setValue( final String value ) | |||
{ | |||
m_value = value; | |||
} | |||
/** | |||
* Retrieve name of parameter. | |||
* | |||
* @return the name of parameter. | |||
*/ | |||
String getName() | |||
{ | |||
return m_name; | |||
} | |||
/** | |||
* Retrieve the value of parameter. | |||
* | |||
* @return the value of parameter. | |||
*/ | |||
String getValue() | |||
{ | |||
return m_value; | |||
} | |||
/** | |||
* Make sure that neither the name or the value | |||
* is null. | |||
*/ | |||
public void validate() | |||
throws TaskException | |||
{ | |||
if( null == m_name ) | |||
{ | |||
final String message = REZ.getString( "param.noname.error" ); | |||
throw new TaskException( message ); | |||
} | |||
else if( null == m_value ) | |||
{ | |||
final String message = | |||
REZ.getString( "param.novalue.error", m_name ); | |||
throw new TaskException( message ); | |||
} | |||
} | |||
} |
@@ -113,6 +113,12 @@ public class JarLibManifestTask | |||
*/ | |||
private String m_implementationURL; | |||
/** | |||
* Extra attributes the user specifies for main section | |||
* in manifest. | |||
*/ | |||
private final ArrayList m_extraAttributes = new ArrayList(); | |||
/** | |||
* Set the name of extension in generated manifest. | |||
* | |||
@@ -213,6 +219,16 @@ public class JarLibManifestTask | |||
m_optionals.addElement( fileSet ); | |||
} | |||
/** | |||
* Adds an attribute that is to be put in main section of manifest. | |||
* | |||
* @param attribute an attribute that is to be put in main section of manifest. | |||
*/ | |||
public void addAttribute( final ExtraAttribute attribute ) | |||
{ | |||
m_extraAttributes.add( attribute ); | |||
} | |||
public void execute() | |||
throws TaskException | |||
{ | |||
@@ -224,6 +240,8 @@ public class JarLibManifestTask | |||
attributes.put( Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION ); | |||
attributes.putValue( "Created-By", Constants.BUILD_DESCRIPTION ); | |||
appendExtraAttributes( attributes ); | |||
appendExtensionData( attributes ); | |||
final String extensionKey = Extension.EXTENSION_LIST.toString(); | |||
@@ -269,6 +287,24 @@ public class JarLibManifestTask | |||
} | |||
} | |||
/** | |||
* Add any extra attributes to the manifest. | |||
* | |||
* @param attributes the manifest section to write | |||
* attributes to | |||
*/ | |||
private void appendExtraAttributes( final Attributes attributes ) | |||
{ | |||
final Iterator iterator = m_extraAttributes.iterator(); | |||
while( iterator.hasNext() ) | |||
{ | |||
final ExtraAttribute attribute = | |||
(ExtraAttribute)iterator.next(); | |||
attributes.putValue( attribute.getName(), | |||
attribute.getValue() ); | |||
} | |||
} | |||
/** | |||
* Write out manifest to destfile. | |||
* | |||
@@ -4,4 +4,7 @@ extension.bad-file.error="{0}" is not a file. | |||
manifest.missing-file.error=Destfile attribute not specified. | |||
manifest.bad-file.error="{0}" is not a file. | |||
manifest.file.notice=Generating manifest {0}. | |||
manifest.file.notice=Generating manifest {0}. | |||
param.noname.error=Missing name from parameter. | |||
param.novalue.error=Missing value from parameter "{0}". |
@@ -341,8 +341,9 @@ Legal: | |||
destfile="../../generated-manifest.txt" | |||
extension-name="org.realityforge.dve" | |||
specification-version="1.0" | |||
specification-vendor="Peter Donald" | |||
> | |||
specification-vendor="Peter Donald" > | |||
<attribute name="Main-class" | |||
value="org.realityforg.dve.WorldGen"/> | |||
<depends dir="../../"> | |||
<include name="src/ant1compat/jar/*.jar"/> | |||
</depends> | |||