You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Jason Hoogland <ho...@gmail.com> on 2013/04/13 16:19:34 UTC

stand-alone jar

I;ve seen
http://stackoverflow.com/questions/1279419/buildr-package-dependencies-into-a-single-jar/1285293#1285293but
I'd prefer a buildr-only solution and it I can't find any good info
regarding inserting the Class-Path in the MANIFEST.MF

I have

DEPS =
[
  ARGS4J,
  JASYPT,
  WEB,
  ORIENTDB,
  '/path/to/local.jar'
]

repositories.remote << 'http://repo1.maven.org/maven2'

define 'My Project' do

  project.version = VERSION_NUMBER
  project.group = 'myGroup'
  compile.options.target = '1.7'

  desc 'Bountius Server'
  define 'deps' do
    package(:jar).merge(DEPS)
  end

  manifest['Main-Class'] = 'com.myProject.control.Start'

  desc 'iMyProject Server'
  define 'server' do
    compile.with DEPS
    package(:jar).merge(DEPS)
  end
end

The server jar created just throws the kitchen sink in, apparently
overwriting the META-ING/MANIFEST.MF with the final artifact MANIFEST.MF
rather than using my manifest settings.

I'm trying to do what my old ant build.xml does, namely:
1. compile my src code into classes
2. packages them into a jar
3. adds the dependency jars to this jar
4. includes "Main-Class" and "Class-Path" attributes to
META-INF/MANIFEST.MF, the latter properly formatted, e.g.:

Class-Path: args4j-2.0.18.jar gson-2.2.2.jar jasypt-1.9.0.jar orient-c
 ommons-1.3.0.jar orientdb-client-1.3.0.jar orientdb-core-1.3.0.jar or
 ientdb-enterprise-1.3.0.jar orientdb-server-1.3.0.jar prodigitum.util
 .jar commons-exec-1.1.jar commons-logging-1.1.1.jar guava-14.0.jar ht
 tpclient-4.2.1.jar httpcore-4.2.1.jar json-20080701.jar selenium-java
 -2.31.0.jar

The resulting jar can be run stand-alone.

I'm open to a better or equivalent way in buildr if someone could possibly
help

Cheers
hoogs

Re: Real world build files and stand-alone jar

Posted by "Jesus M. Rodriguez" <jm...@gmail.com>.
here's ours :)

https://github.com/candlepin/candlepin/blob/master/buildfile

sincerely,
jesus rodriguez
On Apr 14, 2013 11:33 AM, "Alex Boisvert" <al...@gmail.com> wrote:

> On Sun, Apr 14, 2013 at 3:53 AM, Peter Donald <peter@realityforge.org
> >wrote:
>
> > > A collection of real world build files would help a lot, especially
> when
> > > one is new to buildr.
> > >
> >
> > At one stage there was a git repository somewhere that included a
> > collection of buildfiles.  Not sure where it was exactly ...
> >
>
> https://github.com/phoet/buildr-examples
>

Re: Real world build files and stand-alone jar

Posted by Alex Boisvert <al...@gmail.com>.
On Sun, Apr 14, 2013 at 3:53 AM, Peter Donald <pe...@realityforge.org>wrote:

> > A collection of real world build files would help a lot, especially when
> > one is new to buildr.
> >
>
> At one stage there was a git repository somewhere that included a
> collection of buildfiles.  Not sure where it was exactly ...
>

https://github.com/phoet/buildr-examples

Re: Real world build files and stand-alone jar

Posted by Peter Donald <pe...@realityforge.org>.
Hi,

On Sun, Apr 14, 2013 at 6:16 PM, Magnus Melander <ma...@huggtand.com>wrote:

> I think the question about where to find real world examples of build
> files is a really valid question.
> I find the buildr documentation great except for that part.
>

That's true.


> A collection of real world build files would help a lot, especially when
> one is new to buildr.
>

At one stage there was a git repository somewhere that included a
collection of buildfiles.  Not sure where it was exactly ...


>
> Btw, since I started to use buildr, I have never looked back.
>

Me too ;)

-- 
Cheers,

Peter Donald

Real world build files and stand-alone jar

Posted by Magnus Melander <ma...@huggtand.com>.
Hi All!
I think the question about where to find real world examples of build files is a really valid question.
I find the buildr documentation great except for that part.
A collection of real world build files would help a lot, especially when one is new to buildr.

Btw, since I started to use buildr, I have never looked back.

Regards,
Magnus

El 14 apr 2013, a las 09.36, Jason Hoogland escribió:

> Peter,
> 
> Awesome, thank you SO much, looks like the trick. How do you find all these
> buildfiles?
> 
> I think i love buildr, bye bye ant, xml!
> 
> hoogs
> On Apr 14, 2013 3:02 PM, "Peter Donald" <pe...@realityforge.org> wrote:
> 
>> Hi,
>> 
>> Now I understand. An example for this is at
>> 
>> https://gist.github.com/realityforge/5381737
>> 
>> On Sun, Apr 14, 2013 at 2:00 PM, Jason Hoogland <ho...@gmail.com>
>> wrote:
>> 
>>> To break this down to simpler questions:
>>> 
>>> 1. How to access a subset of the jar files buildr remotely downloaded?
>>> 2. How to include this subset as jars, without modification, within a new
>>> jar package?
>>> 3. How to create a Class-Path string, properly formatted, that includes
>>> this subset of jars, for use in the final package manifest? (Ruby newbie)
>>> 
>>> hoogs
>>> On Apr 14, 2013 10:17 AM, "Jason Hoogland" <ho...@gmail.com> wrote:
>>> 
>>>> Thanks Peter,
>>>> 
>>>> I am having trouble finding useful buildfile examples so will check
>> this
>>>> out.
>>>> 
>>>> I am trying to do the former, nesting the dep jars inside the final
>> jar.
>>>> Then I have only one manifest file to worry about. I find it a lot
>>> cleaner.
>>>> Currently my buildfile is doing what you do, just mash all the dep
>> files
>>>> together into the jar, the problem i've got there is that the
>> MANIFEST.MF
>>>> files seem to overwrite each other, but maybe that link will help.
>>>> 
>>>> hoogs
>>>> On Apr 14, 2013 9:59 AM, "Peter Donald" <pe...@realityforge.org>
>> wrote:
>>>> 
>>>>> On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <ho...@gmail.com>
>>>>> wrote:
>>>>> 
>>>>>> I'm trying to do what my old ant build.xml does, namely:
>>>>>> 1. compile my src code into classes
>>>>>> 2. packages them into a jar
>>>>>> 3. adds the dependency jars to this jar
>>>>>> 4. includes "Main-Class" and "Class-Path" attributes to
>>>>>> META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
>>>>>> 
>>>>> 
>>>>> I am not sure I exactly follow. Do you want to include the jars as
>>> nested
>>>>> jars or just include the files form the jar in the final jar?
>>>>> 
>>>>> I usually attempt the second option and use code that looks similar to
>>>>> 
>>>>> https://github.com/realityforge/spydle/blob/master/buildfile#L19
>>>>> 
>>>>> to achieve this goal.
>>>>> 
>>>>> HTH (And sorry if I am missing what you are trying to do),
>>>>> 
>>>>> Peter Donald
>>>>> 
>>>> 
>>> 
>> 
>> 
>> 
>> --
>> Cheers,
>> 
>> Peter Donald
>> 


Re: stand-alone jar

Posted by Jason Hoogland <ho...@gmail.com>.
Peter,

Works marvellously, and doing it this way is substantially faster to
package with builder, from 20-30s on my machine down to 1.5s.

You've got an unmatched [, and the Class-Path only works for me if the
comma join is replaced by a space.

hoogs


On Sun, Apr 14, 2013 at 6:47 PM, Peter Donald <pe...@realityforge.org>wrote:

> On Sun, Apr 14, 2013 at 8:31 PM, Jason Hoogland <ho...@gmail.com>
> wrote:
>
> > One more question: if the remote artifacts are specified in an array, how
> > would the "jar.include" change? I expect I'll be ok with figuring out
> > building the Class-Path string in a loop but if you have a suggestion for
> > that, it would be great.
> >
>
> Updated the example at
>
> https://gist.github.com/realityforge/5381737
>
> HTH
>
>
> > hoogs
> > On Apr 14, 2013 3:36 PM, "Jason Hoogland" <ho...@gmail.com> wrote:
> >
> > > Peter,
> > >
> > > Awesome, thank you SO much, looks like the trick. How do you find all
> > > these buildfiles?
> > >
> > > I think i love buildr, bye bye ant, xml!
> > >
> > > hoogs
> > > On Apr 14, 2013 3:02 PM, "Peter Donald" <pe...@realityforge.org>
> wrote:
> > >
> > >> Hi,
> > >>
> > >> Now I understand. An example for this is at
> > >>
> > >> https://gist.github.com/realityforge/5381737
> > >>
> > >> On Sun, Apr 14, 2013 at 2:00 PM, Jason Hoogland <ho...@gmail.com>
> > >> wrote:
> > >>
> > >> > To break this down to simpler questions:
> > >> >
> > >> > 1. How to access a subset of the jar files buildr remotely
> downloaded?
> > >> > 2. How to include this subset as jars, without modification, within
> a
> > >> new
> > >> > jar package?
> > >> > 3. How to create a Class-Path string, properly formatted, that
> > includes
> > >> > this subset of jars, for use in the final package manifest? (Ruby
> > >> newbie)
> > >> >
> > >> > hoogs
> > >> > On Apr 14, 2013 10:17 AM, "Jason Hoogland" <ho...@gmail.com>
> > wrote:
> > >> >
> > >> > > Thanks Peter,
> > >> > >
> > >> > > I am having trouble finding useful buildfile examples so will
> check
> > >> this
> > >> > > out.
> > >> > >
> > >> > > I am trying to do the former, nesting the dep jars inside the
> final
> > >> jar.
> > >> > > Then I have only one manifest file to worry about. I find it a lot
> > >> > cleaner.
> > >> > > Currently my buildfile is doing what you do, just mash all the dep
> > >> files
> > >> > > together into the jar, the problem i've got there is that the
> > >> MANIFEST.MF
> > >> > > files seem to overwrite each other, but maybe that link will help.
> > >> > >
> > >> > > hoogs
> > >> > > On Apr 14, 2013 9:59 AM, "Peter Donald" <pe...@realityforge.org>
> > >> wrote:
> > >> > >
> > >> > >> On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <
> > hoogland@gmail.com
> > >> >
> > >> > >> wrote:
> > >> > >>
> > >> > >> > I'm trying to do what my old ant build.xml does, namely:
> > >> > >> > 1. compile my src code into classes
> > >> > >> > 2. packages them into a jar
> > >> > >> > 3. adds the dependency jars to this jar
> > >> > >> > 4. includes "Main-Class" and "Class-Path" attributes to
> > >> > >> > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
> > >> > >> >
> > >> > >>
> > >> > >> I am not sure I exactly follow. Do you want to include the jars
> as
> > >> > nested
> > >> > >> jars or just include the files form the jar in the final jar?
> > >> > >>
> > >> > >> I usually attempt the second option and use code that looks
> similar
> > >> to
> > >> > >>
> > >> > >> https://github.com/realityforge/spydle/blob/master/buildfile#L19
> > >> > >>
> > >> > >> to achieve this goal.
> > >> > >>
> > >> > >>  HTH (And sorry if I am missing what you are trying to do),
> > >> > >>
> > >> > >> Peter Donald
> > >> > >>
> > >> > >
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> Cheers,
> > >>
> > >> Peter Donald
> > >>
> > >
> >
>
>
>
> --
> Cheers,
>
> Peter Donald
>

Re: stand-alone jar

Posted by Peter Donald <pe...@realityforge.org>.
On Sun, Apr 14, 2013 at 8:31 PM, Jason Hoogland <ho...@gmail.com> wrote:

> One more question: if the remote artifacts are specified in an array, how
> would the "jar.include" change? I expect I'll be ok with figuring out
> building the Class-Path string in a loop but if you have a suggestion for
> that, it would be great.
>

Updated the example at

https://gist.github.com/realityforge/5381737

HTH


> hoogs
> On Apr 14, 2013 3:36 PM, "Jason Hoogland" <ho...@gmail.com> wrote:
>
> > Peter,
> >
> > Awesome, thank you SO much, looks like the trick. How do you find all
> > these buildfiles?
> >
> > I think i love buildr, bye bye ant, xml!
> >
> > hoogs
> > On Apr 14, 2013 3:02 PM, "Peter Donald" <pe...@realityforge.org> wrote:
> >
> >> Hi,
> >>
> >> Now I understand. An example for this is at
> >>
> >> https://gist.github.com/realityforge/5381737
> >>
> >> On Sun, Apr 14, 2013 at 2:00 PM, Jason Hoogland <ho...@gmail.com>
> >> wrote:
> >>
> >> > To break this down to simpler questions:
> >> >
> >> > 1. How to access a subset of the jar files buildr remotely downloaded?
> >> > 2. How to include this subset as jars, without modification, within a
> >> new
> >> > jar package?
> >> > 3. How to create a Class-Path string, properly formatted, that
> includes
> >> > this subset of jars, for use in the final package manifest? (Ruby
> >> newbie)
> >> >
> >> > hoogs
> >> > On Apr 14, 2013 10:17 AM, "Jason Hoogland" <ho...@gmail.com>
> wrote:
> >> >
> >> > > Thanks Peter,
> >> > >
> >> > > I am having trouble finding useful buildfile examples so will check
> >> this
> >> > > out.
> >> > >
> >> > > I am trying to do the former, nesting the dep jars inside the final
> >> jar.
> >> > > Then I have only one manifest file to worry about. I find it a lot
> >> > cleaner.
> >> > > Currently my buildfile is doing what you do, just mash all the dep
> >> files
> >> > > together into the jar, the problem i've got there is that the
> >> MANIFEST.MF
> >> > > files seem to overwrite each other, but maybe that link will help.
> >> > >
> >> > > hoogs
> >> > > On Apr 14, 2013 9:59 AM, "Peter Donald" <pe...@realityforge.org>
> >> wrote:
> >> > >
> >> > >> On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <
> hoogland@gmail.com
> >> >
> >> > >> wrote:
> >> > >>
> >> > >> > I'm trying to do what my old ant build.xml does, namely:
> >> > >> > 1. compile my src code into classes
> >> > >> > 2. packages them into a jar
> >> > >> > 3. adds the dependency jars to this jar
> >> > >> > 4. includes "Main-Class" and "Class-Path" attributes to
> >> > >> > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
> >> > >> >
> >> > >>
> >> > >> I am not sure I exactly follow. Do you want to include the jars as
> >> > nested
> >> > >> jars or just include the files form the jar in the final jar?
> >> > >>
> >> > >> I usually attempt the second option and use code that looks similar
> >> to
> >> > >>
> >> > >> https://github.com/realityforge/spydle/blob/master/buildfile#L19
> >> > >>
> >> > >> to achieve this goal.
> >> > >>
> >> > >>  HTH (And sorry if I am missing what you are trying to do),
> >> > >>
> >> > >> Peter Donald
> >> > >>
> >> > >
> >> >
> >>
> >>
> >>
> >> --
> >> Cheers,
> >>
> >> Peter Donald
> >>
> >
>



-- 
Cheers,

Peter Donald

Re: stand-alone jar

Posted by Jason Hoogland <ho...@gmail.com>.
One more question: if the remote artifacts are specified in an array, how
would the "jar.include" change? I expect I'll be ok with figuring out
building the Class-Path string in a loop but if you have a suggestion for
that, it would be great.
hoogs
On Apr 14, 2013 3:36 PM, "Jason Hoogland" <ho...@gmail.com> wrote:

> Peter,
>
> Awesome, thank you SO much, looks like the trick. How do you find all
> these buildfiles?
>
> I think i love buildr, bye bye ant, xml!
>
> hoogs
> On Apr 14, 2013 3:02 PM, "Peter Donald" <pe...@realityforge.org> wrote:
>
>> Hi,
>>
>> Now I understand. An example for this is at
>>
>> https://gist.github.com/realityforge/5381737
>>
>> On Sun, Apr 14, 2013 at 2:00 PM, Jason Hoogland <ho...@gmail.com>
>> wrote:
>>
>> > To break this down to simpler questions:
>> >
>> > 1. How to access a subset of the jar files buildr remotely downloaded?
>> > 2. How to include this subset as jars, without modification, within a
>> new
>> > jar package?
>> > 3. How to create a Class-Path string, properly formatted, that includes
>> > this subset of jars, for use in the final package manifest? (Ruby
>> newbie)
>> >
>> > hoogs
>> > On Apr 14, 2013 10:17 AM, "Jason Hoogland" <ho...@gmail.com> wrote:
>> >
>> > > Thanks Peter,
>> > >
>> > > I am having trouble finding useful buildfile examples so will check
>> this
>> > > out.
>> > >
>> > > I am trying to do the former, nesting the dep jars inside the final
>> jar.
>> > > Then I have only one manifest file to worry about. I find it a lot
>> > cleaner.
>> > > Currently my buildfile is doing what you do, just mash all the dep
>> files
>> > > together into the jar, the problem i've got there is that the
>> MANIFEST.MF
>> > > files seem to overwrite each other, but maybe that link will help.
>> > >
>> > > hoogs
>> > > On Apr 14, 2013 9:59 AM, "Peter Donald" <pe...@realityforge.org>
>> wrote:
>> > >
>> > >> On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <hoogland@gmail.com
>> >
>> > >> wrote:
>> > >>
>> > >> > I'm trying to do what my old ant build.xml does, namely:
>> > >> > 1. compile my src code into classes
>> > >> > 2. packages them into a jar
>> > >> > 3. adds the dependency jars to this jar
>> > >> > 4. includes "Main-Class" and "Class-Path" attributes to
>> > >> > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
>> > >> >
>> > >>
>> > >> I am not sure I exactly follow. Do you want to include the jars as
>> > nested
>> > >> jars or just include the files form the jar in the final jar?
>> > >>
>> > >> I usually attempt the second option and use code that looks similar
>> to
>> > >>
>> > >> https://github.com/realityforge/spydle/blob/master/buildfile#L19
>> > >>
>> > >> to achieve this goal.
>> > >>
>> > >>  HTH (And sorry if I am missing what you are trying to do),
>> > >>
>> > >> Peter Donald
>> > >>
>> > >
>> >
>>
>>
>>
>> --
>> Cheers,
>>
>> Peter Donald
>>
>

Re: stand-alone jar

Posted by Jason Hoogland <ho...@gmail.com>.
Peter,

Awesome, thank you SO much, looks like the trick. How do you find all these
buildfiles?

I think i love buildr, bye bye ant, xml!

hoogs
On Apr 14, 2013 3:02 PM, "Peter Donald" <pe...@realityforge.org> wrote:

> Hi,
>
> Now I understand. An example for this is at
>
> https://gist.github.com/realityforge/5381737
>
> On Sun, Apr 14, 2013 at 2:00 PM, Jason Hoogland <ho...@gmail.com>
> wrote:
>
> > To break this down to simpler questions:
> >
> > 1. How to access a subset of the jar files buildr remotely downloaded?
> > 2. How to include this subset as jars, without modification, within a new
> > jar package?
> > 3. How to create a Class-Path string, properly formatted, that includes
> > this subset of jars, for use in the final package manifest? (Ruby newbie)
> >
> > hoogs
> > On Apr 14, 2013 10:17 AM, "Jason Hoogland" <ho...@gmail.com> wrote:
> >
> > > Thanks Peter,
> > >
> > > I am having trouble finding useful buildfile examples so will check
> this
> > > out.
> > >
> > > I am trying to do the former, nesting the dep jars inside the final
> jar.
> > > Then I have only one manifest file to worry about. I find it a lot
> > cleaner.
> > > Currently my buildfile is doing what you do, just mash all the dep
> files
> > > together into the jar, the problem i've got there is that the
> MANIFEST.MF
> > > files seem to overwrite each other, but maybe that link will help.
> > >
> > > hoogs
> > > On Apr 14, 2013 9:59 AM, "Peter Donald" <pe...@realityforge.org>
> wrote:
> > >
> > >> On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <ho...@gmail.com>
> > >> wrote:
> > >>
> > >> > I'm trying to do what my old ant build.xml does, namely:
> > >> > 1. compile my src code into classes
> > >> > 2. packages them into a jar
> > >> > 3. adds the dependency jars to this jar
> > >> > 4. includes "Main-Class" and "Class-Path" attributes to
> > >> > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
> > >> >
> > >>
> > >> I am not sure I exactly follow. Do you want to include the jars as
> > nested
> > >> jars or just include the files form the jar in the final jar?
> > >>
> > >> I usually attempt the second option and use code that looks similar to
> > >>
> > >> https://github.com/realityforge/spydle/blob/master/buildfile#L19
> > >>
> > >> to achieve this goal.
> > >>
> > >>  HTH (And sorry if I am missing what you are trying to do),
> > >>
> > >> Peter Donald
> > >>
> > >
> >
>
>
>
> --
> Cheers,
>
> Peter Donald
>

Re: stand-alone jar

Posted by Peter Donald <pe...@realityforge.org>.
Hi,

Now I understand. An example for this is at

https://gist.github.com/realityforge/5381737

On Sun, Apr 14, 2013 at 2:00 PM, Jason Hoogland <ho...@gmail.com> wrote:

> To break this down to simpler questions:
>
> 1. How to access a subset of the jar files buildr remotely downloaded?
> 2. How to include this subset as jars, without modification, within a new
> jar package?
> 3. How to create a Class-Path string, properly formatted, that includes
> this subset of jars, for use in the final package manifest? (Ruby newbie)
>
> hoogs
> On Apr 14, 2013 10:17 AM, "Jason Hoogland" <ho...@gmail.com> wrote:
>
> > Thanks Peter,
> >
> > I am having trouble finding useful buildfile examples so will check this
> > out.
> >
> > I am trying to do the former, nesting the dep jars inside the final jar.
> > Then I have only one manifest file to worry about. I find it a lot
> cleaner.
> > Currently my buildfile is doing what you do, just mash all the dep files
> > together into the jar, the problem i've got there is that the MANIFEST.MF
> > files seem to overwrite each other, but maybe that link will help.
> >
> > hoogs
> > On Apr 14, 2013 9:59 AM, "Peter Donald" <pe...@realityforge.org> wrote:
> >
> >> On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <ho...@gmail.com>
> >> wrote:
> >>
> >> > I'm trying to do what my old ant build.xml does, namely:
> >> > 1. compile my src code into classes
> >> > 2. packages them into a jar
> >> > 3. adds the dependency jars to this jar
> >> > 4. includes "Main-Class" and "Class-Path" attributes to
> >> > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
> >> >
> >>
> >> I am not sure I exactly follow. Do you want to include the jars as
> nested
> >> jars or just include the files form the jar in the final jar?
> >>
> >> I usually attempt the second option and use code that looks similar to
> >>
> >> https://github.com/realityforge/spydle/blob/master/buildfile#L19
> >>
> >> to achieve this goal.
> >>
> >>  HTH (And sorry if I am missing what you are trying to do),
> >>
> >> Peter Donald
> >>
> >
>



-- 
Cheers,

Peter Donald

Re: stand-alone jar

Posted by Jason Hoogland <ho...@gmail.com>.
To break this down to simpler questions:

1. How to access a subset of the jar files buildr remotely downloaded?
2. How to include this subset as jars, without modification, within a new
jar package?
3. How to create a Class-Path string, properly formatted, that includes
this subset of jars, for use in the final package manifest? (Ruby newbie)

hoogs
On Apr 14, 2013 10:17 AM, "Jason Hoogland" <ho...@gmail.com> wrote:

> Thanks Peter,
>
> I am having trouble finding useful buildfile examples so will check this
> out.
>
> I am trying to do the former, nesting the dep jars inside the final jar.
> Then I have only one manifest file to worry about. I find it a lot cleaner.
> Currently my buildfile is doing what you do, just mash all the dep files
> together into the jar, the problem i've got there is that the MANIFEST.MF
> files seem to overwrite each other, but maybe that link will help.
>
> hoogs
> On Apr 14, 2013 9:59 AM, "Peter Donald" <pe...@realityforge.org> wrote:
>
>> On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <ho...@gmail.com>
>> wrote:
>>
>> > I'm trying to do what my old ant build.xml does, namely:
>> > 1. compile my src code into classes
>> > 2. packages them into a jar
>> > 3. adds the dependency jars to this jar
>> > 4. includes "Main-Class" and "Class-Path" attributes to
>> > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
>> >
>>
>> I am not sure I exactly follow. Do you want to include the jars as nested
>> jars or just include the files form the jar in the final jar?
>>
>> I usually attempt the second option and use code that looks similar to
>>
>> https://github.com/realityforge/spydle/blob/master/buildfile#L19
>>
>> to achieve this goal.
>>
>>  HTH (And sorry if I am missing what you are trying to do),
>>
>> Peter Donald
>>
>

Re: stand-alone jar

Posted by Jason Hoogland <ho...@gmail.com>.
Thanks Peter,

I am having trouble finding useful buildfile examples so will check this
out.

I am trying to do the former, nesting the dep jars inside the final jar.
Then I have only one manifest file to worry about. I find it a lot cleaner.
Currently my buildfile is doing what you do, just mash all the dep files
together into the jar, the problem i've got there is that the MANIFEST.MF
files seem to overwrite each other, but maybe that link will help.

hoogs
On Apr 14, 2013 9:59 AM, "Peter Donald" <pe...@realityforge.org> wrote:

> On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <ho...@gmail.com>
> wrote:
>
> > I'm trying to do what my old ant build.xml does, namely:
> > 1. compile my src code into classes
> > 2. packages them into a jar
> > 3. adds the dependency jars to this jar
> > 4. includes "Main-Class" and "Class-Path" attributes to
> > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
> >
>
> I am not sure I exactly follow. Do you want to include the jars as nested
> jars or just include the files form the jar in the final jar?
>
> I usually attempt the second option and use code that looks similar to
>
> https://github.com/realityforge/spydle/blob/master/buildfile#L19
>
> to achieve this goal.
>
>  HTH (And sorry if I am missing what you are trying to do),
>
> Peter Donald
>

Re: stand-alone jar

Posted by Jason Hoogland <ho...@gmail.com>.
Thanks Kevin,

The final solution I came up with uses OneJar.  There is a modest startup
delay of the order of 1s, but no significant runtime penalty.  Packaging
takes about 1.5s versus about 30s for flattening the jars out into
classes.  I'm not sure why that is, but its vastly better for the code dev
cycle.

MYJAR = '/path/to/myjar.jar'
ONEJAR = 'lib/one-jar-boot-0.97.jar'

DEPS =
[
  ARGS4J,
  JASYPT,
  WEB,
  ORIENTDB
].flatten

repositories.remote << 'http://repo1.maven.org/maven2'

define 'MyProject' do

  project.version = VERSION_NUMBER
  project.group = 'mygroup'
  compile.options.target = '1.7'

  define 'server' do
    compile.with DEPS, MYJAR
    package(:jar)
  end

  package(:jar).path("lib").tap do |p|
    p.include DEPS.each {|d| p.include artifact(d).to_s}
    p.include MYJAR
  end
  package(:jar).path("main").tap do |p|
    p.include project('server').package(:jar)
  end
  package(:jar).merge(ONEJAR)
  package(:jar).with :manifest=>manifest.merge(
    'One-Jar-Main-Class'=>'com.myproject.control.Start',
    'Main-Class'=>'com.simontuffs.onejar.Boot'
  )

end

Thanks everyone for your help.  Can I just make a comment about the Buildr
API documentation, which I'm guessing is a generic Ruby doc format?  I just
don't get it at all, I've relied totally on the Quick Start on the webpage,
and these few examples.  I have no Ruby background, but know Python (and
the C languages).  For example, if I want to know what methods are
associated with "package" I just can't figure that out.  Maybe its me.
hoogs


On Mon, Apr 15, 2013 at 9:19 PM, Kevin Smith <ke...@qualitycode.com>wrote:

> On 04/15/2013 06:49 AM, Jason Hoogland wrote:
>
>> Sorry, and any ideas on dealing with manifest.mf overwrite?
>>
>
> Here is a fragment from our buildr script:
>
>    p.with :manifest=>{'Main-Class'=>'**org.martus.client.swingui.**
> Martus'}
>      p.include(File.join(_('source'**, 'test', 'java'), '**/*.mlp'))
> p.merge(project('martus-jar-**verifier').package(:jar)).**
> exclude('META-INF/MANIFEST.MF'**)
>
> It merges in a jar build by a different sub-script, omitting that other
> manifest.
>
> Kevin
>
>

Re: stand-alone jar

Posted by Kevin Smith <ke...@qualitycode.com>.
On 04/15/2013 06:49 AM, Jason Hoogland wrote:
> Sorry, and any ideas on dealing with manifest.mf overwrite?

Here is a fragment from our buildr script:

    p.with :manifest=>{'Main-Class'=>'org.martus.client.swingui.Martus'}
      p.include(File.join(_('source', 'test', 'java'), '**/*.mlp'))
p.merge(project('martus-jar-verifier').package(:jar)).exclude('META-INF/MANIFEST.MF')

It merges in a jar build by a different sub-script, omitting that other 
manifest.

Kevin


Re: stand-alone jar

Posted by Jason Hoogland <ho...@gmail.com>.
Sorry, and any ideas on dealing with manifest.mf overwrite?
On Apr 15, 2013 6:27 PM, "Peter Donald" <pe...@realityforge.org> wrote:

> On Mon, Apr 15, 2013 at 6:41 PM, Jason Hoogland <ho...@gmail.com>
> wrote:
>
> > Peter,
> >
> > Going back to your original suggestion (the second option) e.g.
> > https://github.com/realityforge/spydle/blob/master/buildfile#L19, how
> > would
> > you merge the contents of a local jar file?
> >
>
> Add a line such as
>
> jar.merge('../some/local/library.jar')
>
>
> >
> > hoogs
> >
> >
> > On Sun, Apr 14, 2013 at 9:58 AM, Peter Donald <peter@realityforge.org
> > >wrote:
> >
> > > On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <ho...@gmail.com>
> > > wrote:
> > >
> > > > I'm trying to do what my old ant build.xml does, namely:
> > > > 1. compile my src code into classes
> > > > 2. packages them into a jar
> > > > 3. adds the dependency jars to this jar
> > > > 4. includes "Main-Class" and "Class-Path" attributes to
> > > > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
> > > >
> > >
> > > I am not sure I exactly follow. Do you want to include the jars as
> nested
> > > jars or just include the files form the jar in the final jar?
> > >
> > > I usually attempt the second option and use code that looks similar to
> > >
> > > https://github.com/realityforge/spydle/blob/master/buildfile#L19
> > >
> > > to achieve this goal.
> > >
> > >  HTH (And sorry if I am missing what you are trying to do),
> > >
> > > Peter Donald
> > >
> >
>
>
>
> --
> Cheers,
>
> Peter Donald
>

Re: stand-alone jar

Posted by Peter Donald <pe...@realityforge.org>.
On Mon, Apr 15, 2013 at 6:41 PM, Jason Hoogland <ho...@gmail.com> wrote:

> Peter,
>
> Going back to your original suggestion (the second option) e.g.
> https://github.com/realityforge/spydle/blob/master/buildfile#L19, how
> would
> you merge the contents of a local jar file?
>

Add a line such as

jar.merge('../some/local/library.jar')


>
> hoogs
>
>
> On Sun, Apr 14, 2013 at 9:58 AM, Peter Donald <peter@realityforge.org
> >wrote:
>
> > On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <ho...@gmail.com>
> > wrote:
> >
> > > I'm trying to do what my old ant build.xml does, namely:
> > > 1. compile my src code into classes
> > > 2. packages them into a jar
> > > 3. adds the dependency jars to this jar
> > > 4. includes "Main-Class" and "Class-Path" attributes to
> > > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
> > >
> >
> > I am not sure I exactly follow. Do you want to include the jars as nested
> > jars or just include the files form the jar in the final jar?
> >
> > I usually attempt the second option and use code that looks similar to
> >
> > https://github.com/realityforge/spydle/blob/master/buildfile#L19
> >
> > to achieve this goal.
> >
> >  HTH (And sorry if I am missing what you are trying to do),
> >
> > Peter Donald
> >
>



-- 
Cheers,

Peter Donald

Re: stand-alone jar

Posted by Jason Hoogland <ho...@gmail.com>.
Peter,

Going back to your original suggestion (the second option) e.g.
https://github.com/realityforge/spydle/blob/master/buildfile#L19, how would
you merge the contents of a local jar file?

hoogs


On Sun, Apr 14, 2013 at 9:58 AM, Peter Donald <pe...@realityforge.org>wrote:

> On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <ho...@gmail.com>
> wrote:
>
> > I'm trying to do what my old ant build.xml does, namely:
> > 1. compile my src code into classes
> > 2. packages them into a jar
> > 3. adds the dependency jars to this jar
> > 4. includes "Main-Class" and "Class-Path" attributes to
> > META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
> >
>
> I am not sure I exactly follow. Do you want to include the jars as nested
> jars or just include the files form the jar in the final jar?
>
> I usually attempt the second option and use code that looks similar to
>
> https://github.com/realityforge/spydle/blob/master/buildfile#L19
>
> to achieve this goal.
>
>  HTH (And sorry if I am missing what you are trying to do),
>
> Peter Donald
>

Re: stand-alone jar

Posted by Peter Donald <pe...@realityforge.org>.
On Sun, Apr 14, 2013 at 12:19 AM, Jason Hoogland <ho...@gmail.com> wrote:

> I'm trying to do what my old ant build.xml does, namely:
> 1. compile my src code into classes
> 2. packages them into a jar
> 3. adds the dependency jars to this jar
> 4. includes "Main-Class" and "Class-Path" attributes to
> META-INF/MANIFEST.MF, the latter properly formatted, e.g.:
>

I am not sure I exactly follow. Do you want to include the jars as nested
jars or just include the files form the jar in the final jar?

I usually attempt the second option and use code that looks similar to

https://github.com/realityforge/spydle/blob/master/buildfile#L19

to achieve this goal.

 HTH (And sorry if I am missing what you are trying to do),

Peter Donald