You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ryan Wexler <ry...@iridiumsuite.com> on 2012/04/26 20:36:04 UTC

creating a property and filtering the path only once

I have a large library resource that is used during my build that is
accessed from many of my modules.  I have put that resource in the top
level parent basedir /src/main/MySpecialResource.

I want all the modules in my project to have access to the location of this
resource.  So I created a property in that top level parent pom:

    <properties>

<myspecialresource.basedir>${basedir}\src\main\MySpecialResource</myspecialresource.basedir>
    </properties>

The problem I am having is that the ${basedir} property is refiltered every
time the ${myspecialresource.basedir} is referenced.  So every time one of
my modules references this property the basedir is refiltered with that
module's ${basedir} directory rather than containing the top level parent's
basedir.

Is there a way to set a property with a path that is only filtered once,
when it is declared?

thanks
-ryan

Re: creating a property and filtering the path only once

Posted by Ryan Wexler <ry...@iridiumsuite.com>.
I hear you, I just really wanted to avoid that because this is definitely
not an artifact.

On Thu, Apr 26, 2012 at 12:26 PM, Ansgar Konermann <
ansgar.konermann@googlemail.com> wrote:

> From my experience: that's a hard problem. I ended up making the resource
> an artifact, adding a "provided"-scoped dependency and switched off
> deployment using m-deploy-p's skip config parameter.
>
> Works, but is so ugly.
>
> Not sure if the provided dependency would be allowed in Maven Central
> though (artifact not available).
>
> Best regards
>
> Ansgar
> Am 26.04.2012 21:14 schrieb "Ryan Wexler" <ry...@iridiumsuite.com>:
>
> > Well this item isn't an artifact and I don't want to make one out of it.
> >
> > I tried another approach which was to declare the resource w/o the
> basedir
> > reference in my parent pom:
> > <properties>
> >
> >
> >
> <myspecialresource.basedir>\src\main\MySpecialResource</myspecialresource.basedir>
> > </properties>
> >
> > Then I referenced it like so with the ${project.parent.basedir} preceding
> > the resource property reference:
> > ${project.parent.basedir}${myspecialresource.basedir}
> >
> > This works when I build the whole project, but it doesn't work if I just
> > want to build the module.  It seems that maven doesn't properly reference
> > the parent basedir if you don't build from that directory.
> >
> >
> > On Thu, Apr 26, 2012 at 12:06 PM, Ansgar Konermann <
> > ansgar.konermann@googlemail.com> wrote:
> >
> > > Common approach: put your special resource in a jar module. Let the
> > modules
> > > which should have access to the resource define a dependency to that
> jar.
> > >
> > > If this approach does not work, please elaborate.
> > >
> > > Best regards,
> > >
> > > Ansgar
> > > Am 26.04.2012 20:36 schrieb "Ryan Wexler" <ry...@iridiumsuite.com>:
> > >
> > > > I have a large library resource that is used during my build that is
> > > > accessed from many of my modules.  I have put that resource in the
> top
> > > > level parent basedir /src/main/MySpecialResource.
> > > >
> > > > I want all the modules in my project to have access to the location
> of
> > > this
> > > > resource.  So I created a property in that top level parent pom:
> > > >
> > > >    <properties>
> > > >
> > > >
> > > >
> > >
> >
> <myspecialresource.basedir>${basedir}\src\main\MySpecialResource</myspecialresource.basedir>
> > > >    </properties>
> > > >
> > > > The problem I am having is that the ${basedir} property is refiltered
> > > every
> > > > time the ${myspecialresource.basedir} is referenced.  So every time
> one
> > > of
> > > > my modules references this property the basedir is refiltered with
> that
> > > > module's ${basedir} directory rather than containing the top level
> > > parent's
> > > > basedir.
> > > >
> > > > Is there a way to set a property with a path that is only filtered
> > once,
> > > > when it is declared?
> > > >
> > > > thanks
> > > > -ryan
> > > >
> > >
> >
>

Re: creating a property and filtering the path only once

Posted by Ansgar Konermann <an...@googlemail.com>.
>From my experience: that's a hard problem. I ended up making the resource
an artifact, adding a "provided"-scoped dependency and switched off
deployment using m-deploy-p's skip config parameter.

Works, but is so ugly.

Not sure if the provided dependency would be allowed in Maven Central
though (artifact not available).

Best regards

Ansgar
Am 26.04.2012 21:14 schrieb "Ryan Wexler" <ry...@iridiumsuite.com>:

> Well this item isn't an artifact and I don't want to make one out of it.
>
> I tried another approach which was to declare the resource w/o the basedir
> reference in my parent pom:
> <properties>
>
>
> <myspecialresource.basedir>\src\main\MySpecialResource</myspecialresource.basedir>
> </properties>
>
> Then I referenced it like so with the ${project.parent.basedir} preceding
> the resource property reference:
> ${project.parent.basedir}${myspecialresource.basedir}
>
> This works when I build the whole project, but it doesn't work if I just
> want to build the module.  It seems that maven doesn't properly reference
> the parent basedir if you don't build from that directory.
>
>
> On Thu, Apr 26, 2012 at 12:06 PM, Ansgar Konermann <
> ansgar.konermann@googlemail.com> wrote:
>
> > Common approach: put your special resource in a jar module. Let the
> modules
> > which should have access to the resource define a dependency to that jar.
> >
> > If this approach does not work, please elaborate.
> >
> > Best regards,
> >
> > Ansgar
> > Am 26.04.2012 20:36 schrieb "Ryan Wexler" <ry...@iridiumsuite.com>:
> >
> > > I have a large library resource that is used during my build that is
> > > accessed from many of my modules.  I have put that resource in the top
> > > level parent basedir /src/main/MySpecialResource.
> > >
> > > I want all the modules in my project to have access to the location of
> > this
> > > resource.  So I created a property in that top level parent pom:
> > >
> > >    <properties>
> > >
> > >
> > >
> >
> <myspecialresource.basedir>${basedir}\src\main\MySpecialResource</myspecialresource.basedir>
> > >    </properties>
> > >
> > > The problem I am having is that the ${basedir} property is refiltered
> > every
> > > time the ${myspecialresource.basedir} is referenced.  So every time one
> > of
> > > my modules references this property the basedir is refiltered with that
> > > module's ${basedir} directory rather than containing the top level
> > parent's
> > > basedir.
> > >
> > > Is there a way to set a property with a path that is only filtered
> once,
> > > when it is declared?
> > >
> > > thanks
> > > -ryan
> > >
> >
>

Re: creating a property and filtering the path only once

Posted by Ryan Wexler <ry...@iridiumsuite.com>.
Well this item isn't an artifact and I don't want to make one out of it.

I tried another approach which was to declare the resource w/o the basedir
reference in my parent pom:
<properties>

<myspecialresource.basedir>\src\main\MySpecialResource</myspecialresource.basedir>
</properties>

Then I referenced it like so with the ${project.parent.basedir} preceding
the resource property reference:
${project.parent.basedir}${myspecialresource.basedir}

This works when I build the whole project, but it doesn't work if I just
want to build the module.  It seems that maven doesn't properly reference
the parent basedir if you don't build from that directory.


On Thu, Apr 26, 2012 at 12:06 PM, Ansgar Konermann <
ansgar.konermann@googlemail.com> wrote:

> Common approach: put your special resource in a jar module. Let the modules
> which should have access to the resource define a dependency to that jar.
>
> If this approach does not work, please elaborate.
>
> Best regards,
>
> Ansgar
> Am 26.04.2012 20:36 schrieb "Ryan Wexler" <ry...@iridiumsuite.com>:
>
> > I have a large library resource that is used during my build that is
> > accessed from many of my modules.  I have put that resource in the top
> > level parent basedir /src/main/MySpecialResource.
> >
> > I want all the modules in my project to have access to the location of
> this
> > resource.  So I created a property in that top level parent pom:
> >
> >    <properties>
> >
> >
> >
> <myspecialresource.basedir>${basedir}\src\main\MySpecialResource</myspecialresource.basedir>
> >    </properties>
> >
> > The problem I am having is that the ${basedir} property is refiltered
> every
> > time the ${myspecialresource.basedir} is referenced.  So every time one
> of
> > my modules references this property the basedir is refiltered with that
> > module's ${basedir} directory rather than containing the top level
> parent's
> > basedir.
> >
> > Is there a way to set a property with a path that is only filtered once,
> > when it is declared?
> >
> > thanks
> > -ryan
> >
>

Re: creating a property and filtering the path only once

Posted by Ansgar Konermann <an...@googlemail.com>.
Common approach: put your special resource in a jar module. Let the modules
which should have access to the resource define a dependency to that jar.

If this approach does not work, please elaborate.

Best regards,

Ansgar
Am 26.04.2012 20:36 schrieb "Ryan Wexler" <ry...@iridiumsuite.com>:

> I have a large library resource that is used during my build that is
> accessed from many of my modules.  I have put that resource in the top
> level parent basedir /src/main/MySpecialResource.
>
> I want all the modules in my project to have access to the location of this
> resource.  So I created a property in that top level parent pom:
>
>    <properties>
>
>
> <myspecialresource.basedir>${basedir}\src\main\MySpecialResource</myspecialresource.basedir>
>    </properties>
>
> The problem I am having is that the ${basedir} property is refiltered every
> time the ${myspecialresource.basedir} is referenced.  So every time one of
> my modules references this property the basedir is refiltered with that
> module's ${basedir} directory rather than containing the top level parent's
> basedir.
>
> Is there a way to set a property with a path that is only filtered once,
> when it is declared?
>
> thanks
> -ryan
>