You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Nagaraj <na...@beehyv.com> on 2008/10/10 18:29:47 UTC
Manifest
Hi,
While creating a jar file, I am adding manifest.mf using
package(:jar).with :manifest=>_("META-INF/MANIFEST.MF")
Now I want to dynamically set the value of Bundle-Version in manifest.mf.
I tried the following in the buildfile
package(:jar).with
:manifest=>manifest.replace('Bundle-Version'=>VERSION_NUMBER)
But it is not working. Is there any way I can achieve this? I am new to Ruby
and Buildr.
Thanks in advance
Nagaraj
_____
Visit us for next <http://www.aatmani.com/Aatmani/adclick?adprintid=610>
generation innovative solutions
Re: Manifest
Posted by "Ittay Dror (Freiman)" <it...@gmail.com>.
On Mon, Oct 13, 2008 at 6:10 PM, Ittay Dror <it...@gmail.com> wrote:
> The reason is that the block in Buildfile runs after the block in JarTask
> (actually WithManifest) and therefore the manifest is already processed.
>
>
> You have several options:
>
> 1. create a file task that processes the manifest and writes it to a file.
> assign this task to jar.manifest (outside of a code block)
>
> 2. use 'send(:prepare)' instead of 'enhance' so that your code is executed
> first
>
> 3. create a task with the code block and make the jar task depend on it
>
This might also work
jar = package(:jar)
jar.manifest = nil
block = proc do |zip|
manifest = Buildr::Packaging::Java::Manifest.new('META-INF/MANIFEST.MF')
manifest.main['Bundle-Version'] = VERSION_NUMBER
zip << manifest.to_s
end
jar.path('META-INF').include(block, :as => 'MANIFEST.MF')
> ittay
>
> Nagaraj wrote:
>
> Thanks for the response.
> Please find beehyv_sample.zip file which contains buildfile as well as
> MANIFEST.MF file
>
>
> please send your manifest file and i'll see if i can have a look.
>
>
> Thanks
>
> Nagaraj
>
>
>
> _____
>
> Aatmani - Providing <http://www.aatmani.com/Aatmani/adclick?adprintid=619> <http://www.aatmani.com/Aatmani/adclick?adprintid=619>
> incentivized, targeted, content Advertisements
>
>
>
>
> --
> --
> Ittay Dror <it...@gmail.com> <it...@gmail.com>
>
>
Re: Manifest
Posted by Ittay Dror <it...@gmail.com>.
The reason is that the block in Buildfile runs after the block in
JarTask (actually WithManifest) and therefore the manifest is already
processed.
You have several options:
1. create a file task that processes the manifest and writes it to a
file. assign this task to jar.manifest (outside of a code block)
2. use 'send(:prepare)' instead of 'enhance' so that your code is
executed first
3. create a task with the code block and make the jar task depend on it
ittay
Nagaraj wrote:
> Thanks for the response.
> Please find beehyv_sample.zip file which contains buildfile as well as
> MANIFEST.MF file
>
>> please send your manifest file and i'll see if i can have a look.
>>
>
> Thanks
>
> Nagaraj
>
>
>
> _____
>
> Aatmani - Providing <http://www.aatmani.com/Aatmani/adclick?adprintid=619>
> incentivized, targeted, content Advertisements
>
>
--
--
Ittay Dror <it...@gmail.com>
RE: Manifest
Posted by Nagaraj <na...@beehyv.com>.
Thanks for the response.
Please find beehyv_sample.zip file which contains buildfile as well as
MANIFEST.MF file
> please send your manifest file and i'll see if i can have a look.
Thanks
Nagaraj
_____
Aatmani - Providing <http://www.aatmani.com/Aatmani/adclick?adprintid=619>
incentivized, targeted, content Advertisements
Re: Manifest
Posted by Ittay Dror <it...@gmail.com>.
Nagaraj wrote:
> Thanks for the response Ittay
>
> We used 'enhance' instead of 'prepare'. We are getting no errors. But it is
> deleting old entries which are there in MANIFEST.MF file and updating
> 'Bundle-Version' with VERSION_NUMBER. We want to preserve old entries in the
> MANIFEST.MF file and update only 'Bundle-Version' with VERSION_NUMBER.
>
please send your manifest file and i'll see if i can have a look.
ittay
> Thanks
>
> Nagaraj
>
>
>
>> When we tried this option we are getting following error in the command
>> prompt
>>
>> rake aborted!
>> protected method `prepare' called for
>> #<Buildr::Packaging::Java::JarTask:0x39413f0>
>>
>>
> I think you can use 'enhance' instead of prepare.
>
> Ittay
>
>> Thanks
>>
>> Nagaraj
>>
>>
>>
>> _____
>>
>>
>> Aatmani <http://www.aatmani.com/Aatmani/adclick?adprintid=615> Logo
>>
>>
>>
>>
>>
>>
>
> --
> --
> Ittay Dror <it...@gmail.com>
>
>
>
> _____
>
>
> Reward / <http://www.aatmani.com/Aatmani/adclick?adprintid=618> Incentivize
> your employees to drive their performance....
>
>
>
>
>
--
--
Ittay Dror <it...@gmail.com>
RE: Manifest
Posted by Nagaraj <na...@beehyv.com>.
Thanks for the response Ittay
We used 'enhance' instead of 'prepare'. We are getting no errors. But it is
deleting old entries which are there in MANIFEST.MF file and updating
'Bundle-Version' with VERSION_NUMBER. We want to preserve old entries in the
MANIFEST.MF file and update only 'Bundle-Version' with VERSION_NUMBER.
Thanks
Nagaraj
> When we tried this option we are getting following error in the command
> prompt
>
> rake aborted!
> protected method `prepare' called for
> #<Buildr::Packaging::Java::JarTask:0x39413f0>
>
I think you can use 'enhance' instead of prepare.
Ittay
> Thanks
>
> Nagaraj
>
>
>
> _____
>
>
> Aatmani <http://www.aatmani.com/Aatmani/adclick?adprintid=615> Logo
>
>
>
>
>
--
--
Ittay Dror <it...@gmail.com>
_____
Reward / <http://www.aatmani.com/Aatmani/adclick?adprintid=618> Incentivize
your employees to drive their performance....
Re: Manifest
Posted by Ittay Dror <it...@gmail.com>.
Nagaraj wrote:
> Thanks for the response Ittay.
>
>
>> Maybe try this? (didn't test it)
>> package(:jar).prepare do |jar|
>> jar.manifest =
>> Buildr::Packaging::Java::Manifest.new('META-INF/MANIFEST.mf')
>> jar.manifest.main['Bundle-Version'] = VERSION_NUMBER
>> end
>>
>
>
> When we tried this option we are getting following error in the command
> prompt
>
> rake aborted!
> protected method `prepare' called for
> #<Buildr::Packaging::Java::JarTask:0x39413f0>
>
I think you can use 'enhance' instead of prepare.
Ittay
> Thanks
>
> Nagaraj
>
>
>
> _____
>
>
> Aatmani <http://www.aatmani.com/Aatmani/adclick?adprintid=615> Logo
>
>
>
>
>
--
--
Ittay Dror <it...@gmail.com>
RE: Manifest
Posted by Nagaraj <na...@beehyv.com>.
Thanks for the response Ittay.
> Maybe try this? (didn't test it)
> package(:jar).prepare do |jar|
> jar.manifest =
> Buildr::Packaging::Java::Manifest.new('META-INF/MANIFEST.mf')
> jar.manifest.main['Bundle-Version'] = VERSION_NUMBER
> end
When we tried this option we are getting following error in the command
prompt
rake aborted!
protected method `prepare' called for
#<Buildr::Packaging::Java::JarTask:0x39413f0>
Thanks
Nagaraj
_____
Aatmani <http://www.aatmani.com/Aatmani/adclick?adprintid=615> Logo
Re: Manifest
Posted by Ittay Dror <it...@gmail.com>.
Nagaraj wrote:
> Hi,
>
>
>
> While creating a jar file, I am adding manifest.mf using
>
>
>
> package(:jar).with :manifest=>_("META-INF/MANIFEST.MF")
>
>
>
> Now I want to dynamically set the value of Bundle-Version in manifest.mf.
>
>
>
> I tried the following in the buildfile
>
>
>
> package(:jar).with
> :manifest=>manifest.replace('Bundle-Version'=>VERSION_NUMBER)
>
>
>
>
>
> But it is not working. Is there any way I can achieve this? I am new to Ruby
> and Buildr.
>
>
>
>
Maybe try this? (didn't test it)
package(:jar).prepare do |jar|
jar.manifest =
Buildr::Packaging::Java::Manifest.new('META-INF/MANIFEST.mf')
jar.manifest.main['Bundle-Version'] = VERSION_NUMBER
end
Ittay
> Thanks in advance
>
>
>
> Nagaraj
>
>
>
>
>
> _____
>
> Visit us for next <http://www.aatmani.com/Aatmani/adclick?adprintid=610>
> generation innovative solutions
>
>
>
--
--
Ittay Dror <it...@gmail.com>
Re: Manifest
Posted by Assaf Arkin <ar...@intalio.com>.
On Mon, Oct 13, 2008 at 1:03 PM, Ittay Dror <it...@gmail.com> wrote:
>
>
> Assaf Arkin wrote:
>
>> Start by reading and parsing the manifest file:
>>
>> man =
>> Packaging::Java::Manifest.parse(File.read(_('META-INF/MANIFEST.MF')))
>>
>> Change the Bundle-Version in the main section:
>>
>> man.main['Bundle-Version'] = VERSION_NUMBER
>>
>> And package with that manifest:
>>
>> package(:jar).with :manifest=>man
>>
>> If your manifest has just one section, you can just use the main section
>> so:
>>
>> package(:jar).with :manifest=>Packaging::Java::Manifest.parse(
>> File.read(_('META-INF/MANIFEST.MF'))).main.update('Bundle-Version'=>
>> VERSION_NUMBER)
>>
>
> Just to mention that my approach so far was to delay the work to when the
> project's package task is actually called. With the solution above, the work
> (reading the file and parsing it) is done regardless. Obviously it is not
> that much work.
Just wrap it with a lambda, so it gets evaluated lazily:
package(:jar).with :manifest=> lambda {
man = Packaging::Java::Manifest.parse(File.read(_('META-INF/MANIFEST.MF')))
man.main['Bundle-Version'] = VERSION_NUMBER
man
}
Assaf
>>
>> Assaf
>>
>> On Fri, Oct 10, 2008 at 9:29 AM, Nagaraj <na...@beehyv.com> wrote:
>>
>>>
>>> Hi,
>>>
>>>
>>>
>>> While creating a jar file, I am adding manifest.mf using
>>>
>>>
>>>
>>> package(:jar).with :manifest=>_("META-INF/MANIFEST.MF")
>>>
>>>
>>>
>>> Now I want to dynamically set the value of Bundle-Version in manifest.mf.
>>>
>>>
>>>
>>> I tried the following in the buildfile
>>>
>>>
>>>
>>> package(:jar).with
>>> :manifest=>manifest.replace('Bundle-Version'=>VERSION_NUMBER)
>>>
>>>
>>>
>>>
>>>
>>> But it is not working. Is there any way I can achieve this? I am new to
>>> Ruby
>>> and Buildr.
>>>
>>>
>>>
>>> Thanks in advance
>>>
>>>
>>>
>>> Nagaraj
>>>
>>>
>>>
>>>
>>>
>>> _____
>>>
>>> Visit us for next <http://www.aatmani.com/Aatmani/adclick?adprintid=610>
>>> generation innovative solutions
>>>
>>>
>>>
>
> --
> --
> Ittay Dror <it...@gmail.com>
>
>
>
Re: Manifest
Posted by Ittay Dror <it...@gmail.com>.
Assaf Arkin wrote:
> Start by reading and parsing the manifest file:
>
> man = Packaging::Java::Manifest.parse(File.read(_('META-INF/MANIFEST.MF')))
>
> Change the Bundle-Version in the main section:
>
> man.main['Bundle-Version'] = VERSION_NUMBER
>
> And package with that manifest:
>
> package(:jar).with :manifest=>man
>
> If your manifest has just one section, you can just use the main section so:
>
> package(:jar).with :manifest=>Packaging::Java::Manifest.parse(
> File.read(_('META-INF/MANIFEST.MF'))).main.update('Bundle-Version'=>
> VERSION_NUMBER)
>
Just to mention that my approach so far was to delay the work to when
the project's package task is actually called. With the solution above,
the work (reading the file and parsing it) is done regardless. Obviously
it is not that much work.
> Assaf
>
> On Fri, Oct 10, 2008 at 9:29 AM, Nagaraj <na...@beehyv.com> wrote:
>
>> Hi,
>>
>>
>>
>> While creating a jar file, I am adding manifest.mf using
>>
>>
>>
>> package(:jar).with :manifest=>_("META-INF/MANIFEST.MF")
>>
>>
>>
>> Now I want to dynamically set the value of Bundle-Version in manifest.mf.
>>
>>
>>
>> I tried the following in the buildfile
>>
>>
>>
>> package(:jar).with
>> :manifest=>manifest.replace('Bundle-Version'=>VERSION_NUMBER)
>>
>>
>>
>>
>>
>> But it is not working. Is there any way I can achieve this? I am new to Ruby
>> and Buildr.
>>
>>
>>
>> Thanks in advance
>>
>>
>>
>> Nagaraj
>>
>>
>>
>>
>>
>> _____
>>
>> Visit us for next <http://www.aatmani.com/Aatmani/adclick?adprintid=610>
>> generation innovative solutions
>>
>>
>>
--
--
Ittay Dror <it...@gmail.com>
RE: Manifest
Posted by Nagaraj <na...@beehyv.com>.
Thank you Assaf. It is working now.
Regards
Nagaraj
> Start by reading and parsing the manifest file:
> man =
Packaging::Java::Manifest.parse(File.read(_('META-INF/MANIFEST.MF')))
>Change the Bundle-Version in the main section:
> man.main['Bundle-Version'] = VERSION_NUMBER
>And package with that manifest:
> package(:jar).with :manifest=>man
_____
Reward / <http://www.aatmani.com/Aatmani/adclick?adprintid=620> Incentivize
your employees to drive their performance....
Re: Manifest
Posted by Assaf Arkin <ar...@intalio.com>.
Start by reading and parsing the manifest file:
man = Packaging::Java::Manifest.parse(File.read(_('META-INF/MANIFEST.MF')))
Change the Bundle-Version in the main section:
man.main['Bundle-Version'] = VERSION_NUMBER
And package with that manifest:
package(:jar).with :manifest=>man
If your manifest has just one section, you can just use the main section so:
package(:jar).with :manifest=>Packaging::Java::Manifest.parse(
File.read(_('META-INF/MANIFEST.MF'))).main.update('Bundle-Version'=>
VERSION_NUMBER)
Assaf
On Fri, Oct 10, 2008 at 9:29 AM, Nagaraj <na...@beehyv.com> wrote:
> Hi,
>
>
>
> While creating a jar file, I am adding manifest.mf using
>
>
>
> package(:jar).with :manifest=>_("META-INF/MANIFEST.MF")
>
>
>
> Now I want to dynamically set the value of Bundle-Version in manifest.mf.
>
>
>
> I tried the following in the buildfile
>
>
>
> package(:jar).with
> :manifest=>manifest.replace('Bundle-Version'=>VERSION_NUMBER)
>
>
>
>
>
> But it is not working. Is there any way I can achieve this? I am new to Ruby
> and Buildr.
>
>
>
> Thanks in advance
>
>
>
> Nagaraj
>
>
>
>
>
> _____
>
> Visit us for next <http://www.aatmani.com/Aatmani/adclick?adprintid=610>
> generation innovative solutions
>
>
RE: Manifest
Posted by Nagaraj <na...@beehyv.com>.
Thanks for the response Lacton.
-----Original Message-----
From: antoine.contal@gmail.com [mailto:antoine.contal@gmail.com] On Behalf
Of lacton
On Fri, Oct 10, 2008 at 6:29 PM, Nagaraj <na...@beehyv.com> wrote:
>
> Now I want to dynamically set the value of Bundle-Version in manifest.mf.
>
> I can think of two ways to achieve this.
> One way would be to get rid of the file and use only a hash or the
> project manifest properties.
We would like to use this if there is no other simpler solution.
> Another way would be to use a filter on your source file.
This works with Buildr, but is creating problems in eclipse --
The specified version does not have the correct format
(major.minor.micro.qualifier) or contains invalid characters
Because of Bundle-Version: ${version} in META-INF/MANIFEST.MF
Thanks
Nagaraj
_____
Reward / <http://www.aatmani.com/Aatmani/adclick?adprintid=614> Incentivize
your employees to drive their performance....
Re: Manifest
Posted by lacton <la...@users.sourceforge.net>.
On Fri, Oct 10, 2008 at 6:29 PM, Nagaraj <na...@beehyv.com> wrote:
> Hi,
>
>
>
> While creating a jar file, I am adding manifest.mf using
>
>
>
> package(:jar).with :manifest=>_("META-INF/MANIFEST.MF")
>
>
>
> Now I want to dynamically set the value of Bundle-Version in manifest.mf.
>
>
>
> I tried the following in the buildfile
>
>
>
> package(:jar).with
> :manifest=>manifest.replace('Bundle-Version'=>VERSION_NUMBER)
>
>
>
>
>
> But it is not working. Is there any way I can achieve this? I am new to Ruby
> and Buildr.
I can think of two ways to achieve this.
One way would be to get rid of the file and use only a hash or the
project manifest properties.
E.g.,
package(:jar).with :manifest=>{ 'Implementation-Title'=>'foo',
'Bundle-Version'=>VERSION_NUMBER }
OR
manifest['Implementation-Title'] = 'foo'
manifest['Bundle-Version'] = VERSION_NUMBER
package(:jar)
Another way would be to use a filter on your source file.
E.g.,
Your file src/main/resources/META-INF/MANIFEST.MF contains
Implementation-Title: foo
Bundle-Version: ${version}
Your buildfile contains
resources.filter.using 'version'=>VERSION_NUMBER
package(:jar).with :manifest=>_('target/resources/META-INF/MANIFEST.MF')
Cheers.
Lacton