You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Cyril Sagan <cy...@unx.sas.com> on 2006/01/26 22:36:24 UTC

: add arbitrary set of properties?

In our current java build process, we'd like to be able to allow users
to add arbitrary items to the jar manifest.

But, 1) we won't know the attribute names, and 2) some builds will
have these "extra" manifest, some won't.

In the ideal solution, the build.xml would look something like this:
    <jar ... >
        <manifest>
            <attribute name="Specification-Vendor" value="ABC Vendor" />
            <attribute name="Implementation-Vendor" value="ABC Vendor" />
            <attribute name="Implementation-Vendor-Id" value="com.abc"/>
            <!-- for each property named manifest.* add here -->
        </manifest>
    </jar>
    

... and the user would be able to invoke ant like this:
    $ ant -Dmanifest.Foo=bar -Dmanifest.Color=green

The build.xml should find every property with the "manifest." prefix,
then add to the manifest.  The resulting manifest would then look like
this:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.5
    Created-By: 1.4.2_08-b03 (Sun Microsystems Inc.)
    Specification-Vendor: ABC Vendor
    Implementation-Vendor: ABC Vendor
    Implementation-Vendor-Id: com.abc
    Foo: Bar
    Color: Green

The only thing I can think of is to use a property set like this:
    <propertyset id="manifest-properties">
        <propertyref prefix="manifest.">
    </propertyset>

... and extend Manifest.java to take a propertyref id.

Does anyone have any better ideas/suggestions??  Thanks.

--Cyril

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: : add arbitrary set of properties?

Posted by Jeffrey E Care <ca...@us.ibm.com>.
Dominique Devienne <dd...@gmail.com> wrote on 01/27/2006 10:15:24 AM:

> I never needed something like this, but why not... Note though that I
> feel you might be better served by creating a new file (a .properties
> for example) in META-INF, using a conventional name, that's very easy
> to load as a resource. Maybe you are "abusing" the manifest by wanting
> to add your own meta-data no?

Depending on the application this may or may not be possible. I've noticed 
lately that frameworks (Eclipse/OSGi Bundles are one example that springs 
to mind) are using the manifest to store additional metadata about the 
archive, so I can definitely see the need for a more generalized way of 
getting entries into the manifest.

-- 
Jeffrey E. Care (carej@us.ibm.com)
WAS Pyxis Lead Release Engineer

Re: : add arbitrary set of properties?

Posted by Dominique Devienne <dd...@gmail.com>.
> ... and the user would be able to invoke ant like this:
>    $ ant -Dmanifest.Foo=bar -Dmanifest.Color=green
>
> The build.xml should find every property with the "manifest." prefix,
> ...
>    Foo: Bar
>    Color: Green
>
> The only thing I can think of is to use a property set like this:
>    <propertyset id="manifest-properties">
>        <propertyref prefix="manifest.">
>    </propertyset>
>
> ... and extend Manifest.java to take a propertyref id.
>
> Does anyone have any better ideas/suggestions??  Thanks.

I never needed something like this, but why not... Note though that I
feel you might be better served by creating a new file (a .properties
for example) in META-INF, using a conventional name, that's very easy
to load as a resource. Maybe you are "abusing" the manifest by wanting
to add your own meta-data no?

If you persist in the manifest route, then taking a <propertyset> is a
good idea. The problem with <manifest> is that there are 2 of them.
The stand-alone one, and the one nested in <jar>. If I recall
correctly, you'd need to modify both to have a consistent behavior.
--DD

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: : add arbitrary set of properties?

Posted by Jeffrey E Care <ca...@us.ibm.com>.
> The only thing I can think of is to use a property set like this:
>     <propertyset id="manifest-properties">
>         <propertyref prefix="manifest.">
>     </propertyset>
> 
> ... and extend Manifest.java to take a propertyref id.

I think this is an excellent suggestion! You'd also have to make this work 
with sections, but this is a really great idea.

If you submit a patch for this I have a good feeling that the committers 
would accept it.

JEC
-- 
Jeffrey E. Care (carej@us.ibm.com)
WAS Pyxis Lead Release Engineer