Adding Attribute to JAR's Manifest Via ANT TAS

2019-08-26 01:33发布

问题:

all i am stuck with an issue. I have 14 third party jars.I am signing those jars with comodo code sign certificate successfully via ant task.

Now i want to accomplish that whenever i sign those jars i need to add some attributes to jar's manifest file ,

How can i do that ?

I found some manifest task inside jar task but did not find anything while signing.

all those jars are third party jars and already packed so i think do not need to compile and pack them from the source.

Thanks

回答1:

You'd probably have to do something like this for each jar file:

<unzip src="${jar.file.location}" dest="${manifest.dest.dir}">
    <patternset>
        <include name="**/MANIFEST.MF"/>
    </patternset>
</unzip>

<manifest file="${manifest.dest.dir}/MANIFEST.MF" mode="update">
    <attribute name="${myAttribute}" value="${myAttributeValue}"/>
</manifest>

<jar update="true" destfile="${jar.file.location}" basedir="${manifest.dest.dir}"/>


标签: java ant jar