You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Julien Stern <ju...@cryptolog.com> on 2004/02/06 12:06:34 UTC

Sharing properties between subprojects

All,

I was wondering whether (and how) it was possible to share properties
between various projects.

I have about 50 subprojects and I would like to be able to setup common
properties for them it a single place. I would also like to be able to
put these properties in CVS and not in my user home dir.

However, it seems to be impossible to specify or import a property file
from another one (or is it?).

And if I use the reactor or the multiproject plugin, some properties
seem to be unsettable at the top level because of path problems.
More specifically, for exemple, I did not manage to set a common
maven.checkstyle.properties for all my subprojects

I tried to put in the top-level project.properties :
1) maven.checkstyle.properties=mycheckstyle.xml 
2) maven.checkstyle.properties=${basedir}/mycheckstyle.xml 

but it failed both with a handmade reactor and the multiproject plugin.
And I cannot put an absolute path because that would require checking out
the CVS in a specific place, or modifying the path after the checkout.


Also, is there any way to share a property file for subprojects on
which maven could be invoked independently?
I did manage to share _some_ properties by putting them in a top-level
property file and invoking a reactor, but then, I cannot invoke maven
directly from a subproject with these properties.

(Using beta-9, 1.0-rc1 and cvs HEAD by the way.)

Thanks,

--
Julien

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing properties between subprojects

Posted by Julien Stern <ju...@cryptolog.com>.
On Sat, Feb 07, 2004 at 09:50:57AM -0600, Jefferson K. French wrote:
> I put this in each subproject's maven.xml:
> 
>   <ant:property file="${basedir}/../project.properties"/>
>   <util:available file="${basedir}/../build.properties">
>     <util:properties file="${basedir}/../build.properties" trim="true" />
>   </util:available>

Jeff,

Thanks a lot. This works great for most properties.

My only minor remaining problem is for properties that define a path
(say maven.checkstyle.properties or maven.javadoc.stylesheet).

Have you found a way to set these properties from a common place ?

The only solution I could think of is to have 2 project.properties files
(with different names). One which defines common properties for all
subprojects and which is included by your method from the subprojects
maven.xml, and the other for the main project.

Actually, a project.properties seem to be needed for every group of
subprojects which share a common top directory, for the paths to be
correct.

So, well, if you have another brillant trick, let me know. Otherwise,
I'll settle with two or three project.properties, which is way better
than 50 ! ;)

Thanks again.

--
Julien

> 
> I'm trying to force this order of precedence (from the subproject's
> viewpoint) when defining properties:
> 
>   1. ../build.properties
>   2. project.properties
>   3. ../project.properties
> 
> >From what I can tell the subproject project.properties gets loaded
> before the subproject maven.xml. I load the master project.properties
> using Ant so as not to override anything defined in the subproject's
> project.properties. I then load the master build.properties using
> Jelly, because I want properties defined there to override properties
> defined elsewhere. You could also load user-specific properties last
> using Jelly to give them the highest priority.
> 
> When Maven supports property inheritence, I don't know if it will do
> so in this order, but it made sense for me.
> 
>   Jeff
> 
> On Fri, 6 Feb 2004, at 12:06:34 [GMT +0100] Julien Stern wrote:
> 
> > All,
> 
> > I was wondering whether (and how) it was possible to share properties
> > between various projects.
> 
> > I have about 50 subprojects and I would like to be able to setup common
> > properties for them it a single place. I would also like to be able to
> > put these properties in CVS and not in my user home dir.
> 
> > However, it seems to be impossible to specify or import a property file
> > from another one (or is it?).
> 
> > And if I use the reactor or the multiproject plugin, some properties
> > seem to be unsettable at the top level because of path problems.
> > More specifically, for exemple, I did not manage to set a common
> > maven.checkstyle.properties for all my subprojects
> 
> > I tried to put in the top-level project.properties :
> > 1) maven.checkstyle.properties=mycheckstyle.xml 
> > 2) maven.checkstyle.properties=${basedir}/mycheckstyle.xml 
> 
> > but it failed both with a handmade reactor and the multiproject plugin.
> > And I cannot put an absolute path because that would require checking out
> > the CVS in a specific place, or modifying the path after the checkout.
> 
> 
> > Also, is there any way to share a property file for subprojects on
> > which maven could be invoked independently?
> > I did manage to share _some_ properties by putting them in a top-level
> > property file and invoking a reactor, but then, I cannot invoke maven
> > directly from a subproject with these properties.
> 
> > (Using beta-9, 1.0-rc1 and cvs HEAD by the way.)
> 
> > Thanks,
> 
> > --
> > Julien
> 
> -- 
> mailto:jeff@frenches.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing properties between subprojects

Posted by "Jefferson K. French" <je...@frenches.org>.
I put this in each subproject's maven.xml:

  <ant:property file="${basedir}/../project.properties"/>
  <util:available file="${basedir}/../build.properties">
    <util:properties file="${basedir}/../build.properties" trim="true" />
  </util:available>

I'm trying to force this order of precedence (from the subproject's
viewpoint) when defining properties:

  1. ../build.properties
  2. project.properties
  3. ../project.properties

>From what I can tell the subproject project.properties gets loaded
before the subproject maven.xml. I load the master project.properties
using Ant so as not to override anything defined in the subproject's
project.properties. I then load the master build.properties using
Jelly, because I want properties defined there to override properties
defined elsewhere. You could also load user-specific properties last
using Jelly to give them the highest priority.

When Maven supports property inheritence, I don't know if it will do
so in this order, but it made sense for me.

  Jeff

On Fri, 6 Feb 2004, at 12:06:34 [GMT +0100] Julien Stern wrote:

> All,

> I was wondering whether (and how) it was possible to share properties
> between various projects.

> I have about 50 subprojects and I would like to be able to setup common
> properties for them it a single place. I would also like to be able to
> put these properties in CVS and not in my user home dir.

> However, it seems to be impossible to specify or import a property file
> from another one (or is it?).

> And if I use the reactor or the multiproject plugin, some properties
> seem to be unsettable at the top level because of path problems.
> More specifically, for exemple, I did not manage to set a common
> maven.checkstyle.properties for all my subprojects

> I tried to put in the top-level project.properties :
> 1) maven.checkstyle.properties=mycheckstyle.xml 
> 2) maven.checkstyle.properties=${basedir}/mycheckstyle.xml 

> but it failed both with a handmade reactor and the multiproject plugin.
> And I cannot put an absolute path because that would require checking out
> the CVS in a specific place, or modifying the path after the checkout.


> Also, is there any way to share a property file for subprojects on
> which maven could be invoked independently?
> I did manage to share _some_ properties by putting them in a top-level
> property file and invoking a reactor, but then, I cannot invoke maven
> directly from a subproject with these properties.

> (Using beta-9, 1.0-rc1 and cvs HEAD by the way.)

> Thanks,

> --
> Julien

-- 
mailto:jeff@frenches.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org