1

My application needs me to add some atributes to manifest.mf of different jars without changing the previous version of manifest.mf. In short i want to append some attributes to manifest.mf of JAR. I am using ANT to build my application. In JAVA i can do this while creating the jar with command jar cfm jar-file manifest-addition input-file(s) given here But i want to do this with an ANT Task. Is there any ANT task i can use for this? if not then the only solution left with me is

  1. Unzip the jar
  2. Update the MANIFEST.MF
  3. JAR up the content again

This seems to be a lengthy process.

Please suggest.

gusainhimanshu
  • 157
  • 1
  • 11

2 Answers2

1

You could use the <exec> task to run that command line through Ant.

Jeanne Boyarsky
  • 12,156
  • 2
  • 49
  • 59
  • task is a great option. will try this out and let you know. – gusainhimanshu Jul 04 '13 at 04:03
  • Moreover `` task is for running the CLI commands. but i was searching for an **ANT** task for doing this. Isn't there any ANT task for this? because running the task is complicating my application situation. – gusainhimanshu Jul 04 '13 at 08:41
  • There is not a defined task for this. There is a manifest task but it only does step 2 of your list. You could write your own task, but that's more complex than exec. I'm not sure whey exec is complicating your code. It's not a long task. It's certainly shorter and simpler than unjar/update/jar. – Jeanne Boyarsky Jul 04 '13 at 14:27
  • I agree its very simple task. But it is adding extra build time.I have defined variables for the directory paths and jar name should be ${projectname} and there are many projects.So i have to first copy all my classes to a temporary folder. Then run the CLI command of creating the jar on that temporary folder. After creating the jar i have to copy that jar to `${Projectname}` and delete that temp folder and the temporary jar. These extra tasks may increase the build time. Is there any other option i can try ? – gusainhimanshu Jul 04 '13 at 16:03
  • How much extra time did it take when you timed it? And why do you think an Ant task would be more efficient? The same work would need to go on behind the scenes. – Jeanne Boyarsky Jul 05 '13 at 03:43
  • actually i am comparing this whole process with that unjar/update/jar. – gusainhimanshu Jul 05 '13 at 05:23
0

i know you want to add the content of additional files, but maybe you only need to add simple attributes, this would help

<jar destfile="${web.home}/signapplet.jar" 
     basedir="${build.home}/applet/signer/classes">
    <manifest>
        <attribute name="Permissions" value="all-permissions"/>
    </manifest>
</jar>
chris
  • 1
  • i resolved the problem by updating the manifest by update property of the jar target and adding the manifest attributes. thanks for the reply. – gusainhimanshu May 23 '14 at 07:37