You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Mark Petrovic <ms...@gmail.com> on 2010/08/28 17:23:39 UTC

referring to a jar file outside the project

I have a project consisting of a parent and a child.  The child needs a jar artifact outside its directory space, but within the parent's space.  E.g.

parent
	lib/thejar.jar
	child
		src/main/java
		etc.

I have a working child build, referring to the thejar.jar thusly

compile.with artifact('thegroup:thearti:jar:beta').from(file("../lib/thejar.jar")) 
...

but I don't like the ../lib in the path.

I tried things like project("parent")._("lib/thejar.jar") ... but kept getting circular dependency errors.

What is the Buildr Way to refer to the thejar.jar that is in a well-known location relative to the parent, but not necessarily the child?

Thanks.

--
Mark Petrovic



Re: referring to a jar file outside the project

Posted by Mark Petrovic <ms...@gmail.com>.
Thanks.

Turns out that what I really want to do is a) depend the child on the jar in ../lib, then b) bundle the child classes and ../lib/thejar.jar classes into an uberjar - similar to what the maven shade plugin does.  In this case, it's not strictly necessary for the ../lib/thejar.jar to be wrapped as an artifact and installed in the local repo -- but that's how I originally thought about the problem.


On Aug 28, 2010, at 10:04 AM, Alex Boisvert wrote:

> Just to complement Antoine's answer, it's currently not possible to
> reference the parent project using project(...) since its definition is
> currently not complete at the point when it's evaluated.   (Not saying it
> will be like this forever, just that it's a known limitation).
> 
> Second, artifact(...) is only necessary for files you intend to get/put into
> a repository at some point.  Otherwise, you can just reference the file
> directly.  It's slightly easier.
> 
> Last, another way to achieve what you want would be to write,
> 
> define "parent" do
>  LIBS = _('libs')
>  ...
>  define "child" do
>    compile.with File.join(LIBS, 'foo.jar')
>  end
> end
> 
> alex
> 
> 
> On Sat, Aug 28, 2010 at 9:43 AM, Antoine Toulme <an...@lunar-ocean.com>wrote:
> 
>> I just committed a test (in SVN) to show how to do it.
>> 
>> The secret words are "project.parent".
>> 
>> On Sat, Aug 28, 2010 at 08:23, Mark Petrovic <ms...@gmail.com> wrote:
>> 
>>> I have a project consisting of a parent and a child.  The child needs a
>> jar
>>> artifact outside its directory space, but within the parent's space.
>> E.g.
>>> 
>>> parent
>>>       lib/thejar.jar
>>>       child
>>>               src/main/java
>>>               etc.
>>> 
>>> I have a working child build, referring to the thejar.jar thusly
>>> 
>>> compile.with
>>> artifact('thegroup:thearti:jar:beta').from(file("../lib/thejar.jar"))
>>> ...
>>> 
>>> but I don't like the ../lib in the path.
>>> 
>>> I tried things like project("parent")._("lib/thejar.jar") ... but kept
>>> getting circular dependency errors.
>>> 
>>> What is the Buildr Way to refer to the thejar.jar that is in a well-known
>>> location relative to the parent, but not necessarily the child?
>>> 
>>> Thanks.
>>> 
>>> --
>>> Mark Petrovic
>>> 
>>> 
>>> 
>> 


--
Mark Petrovic



Re: referring to a jar file outside the project

Posted by Alex Boisvert <al...@gmail.com>.
Just to complement Antoine's answer, it's currently not possible to
reference the parent project using project(...) since its definition is
currently not complete at the point when it's evaluated.   (Not saying it
will be like this forever, just that it's a known limitation).

Second, artifact(...) is only necessary for files you intend to get/put into
a repository at some point.  Otherwise, you can just reference the file
directly.  It's slightly easier.

Last, another way to achieve what you want would be to write,

define "parent" do
  LIBS = _('libs')
  ...
  define "child" do
    compile.with File.join(LIBS, 'foo.jar')
  end
end

alex


On Sat, Aug 28, 2010 at 9:43 AM, Antoine Toulme <an...@lunar-ocean.com>wrote:

> I just committed a test (in SVN) to show how to do it.
>
> The secret words are "project.parent".
>
> On Sat, Aug 28, 2010 at 08:23, Mark Petrovic <ms...@gmail.com> wrote:
>
> > I have a project consisting of a parent and a child.  The child needs a
> jar
> > artifact outside its directory space, but within the parent's space.
>  E.g.
> >
> > parent
> >        lib/thejar.jar
> >        child
> >                src/main/java
> >                etc.
> >
> > I have a working child build, referring to the thejar.jar thusly
> >
> > compile.with
> > artifact('thegroup:thearti:jar:beta').from(file("../lib/thejar.jar"))
> > ...
> >
> > but I don't like the ../lib in the path.
> >
> > I tried things like project("parent")._("lib/thejar.jar") ... but kept
> > getting circular dependency errors.
> >
> > What is the Buildr Way to refer to the thejar.jar that is in a well-known
> > location relative to the parent, but not necessarily the child?
> >
> > Thanks.
> >
> > --
> > Mark Petrovic
> >
> >
> >
>

Re: referring to a jar file outside the project

Posted by Mark Petrovic <ms...@gmail.com>.
A related subject, for posterity reading this thread:

https://cwiki.apache.org/confluence/display/BUILDR/How+to+use+local+.jar+files+for+compilation


On Aug 28, 2010, at 9:43 AM, Antoine Toulme wrote:

> I just committed a test (in SVN) to show how to do it.
> 
> The secret words are "project.parent".
> 
> On Sat, Aug 28, 2010 at 08:23, Mark Petrovic <ms...@gmail.com> wrote:
> 
>> I have a project consisting of a parent and a child.  The child needs a jar
>> artifact outside its directory space, but within the parent's space.  E.g.
>> 
>> parent
>>       lib/thejar.jar
>>       child
>>               src/main/java
>>               etc.
>> 
>> I have a working child build, referring to the thejar.jar thusly
>> 
>> compile.with
>> artifact('thegroup:thearti:jar:beta').from(file("../lib/thejar.jar"))
>> ...
>> 
>> but I don't like the ../lib in the path.
>> 
>> I tried things like project("parent")._("lib/thejar.jar") ... but kept
>> getting circular dependency errors.
>> 
>> What is the Buildr Way to refer to the thejar.jar that is in a well-known
>> location relative to the parent, but not necessarily the child?
>> 
>> Thanks.
>> 
>> --
>> Mark Petrovic
>> 
>> 
>> 


--
Mark Petrovic



Re: referring to a jar file outside the project

Posted by Antoine Toulme <an...@lunar-ocean.com>.
I just committed a test (in SVN) to show how to do it.

The secret words are "project.parent".

On Sat, Aug 28, 2010 at 08:23, Mark Petrovic <ms...@gmail.com> wrote:

> I have a project consisting of a parent and a child.  The child needs a jar
> artifact outside its directory space, but within the parent's space.  E.g.
>
> parent
>        lib/thejar.jar
>        child
>                src/main/java
>                etc.
>
> I have a working child build, referring to the thejar.jar thusly
>
> compile.with
> artifact('thegroup:thearti:jar:beta').from(file("../lib/thejar.jar"))
> ...
>
> but I don't like the ../lib in the path.
>
> I tried things like project("parent")._("lib/thejar.jar") ... but kept
> getting circular dependency errors.
>
> What is the Buildr Way to refer to the thejar.jar that is in a well-known
> location relative to the parent, but not necessarily the child?
>
> Thanks.
>
> --
> Mark Petrovic
>
>
>