maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristopher Brown" <>
Subject Passing properties into subprojects using the reactor
Date Mon, 06 Dec 2004 11:54:56 GMT


I'm trying to pass properties into subprojects using the reactor, and
I've provided an example of the script used at the end.

I'm not 100% certain, but I've had a good look through the reactor tag
code, and followed that through to PluginManager#attainGoals(Project,
List) which sets up the new context and creates it with the Root
Context.  I'm presuming that if I invoke "maven example:goal-mp" from my
example in ProjectA and it reacts across ProjectX and ProjectY, then the
following context graphs are made (roughly speaking)

ProjectA: Root <- ProjectA
ProjectX: Root <- ProjectX
ProjectY: Root <- Projecty

Rather than, 
ProjectA: Root <- ProjectA
ProjectX: Root <- ProjectA <- ProjectX
ProjectY: Root <- ProjectA <- ProjectY

Presuming the behaviour is intentional, I was wondering if it might be
worthwhile adding a mechanism to the maven:maven and maven:reactor tags
allowing the user to pass through some properties or perhaps allowing
the context of the calling project (i.e. Project A) to be added to the
context graph.

Incidentally, if I provided the property on the command line (i.e.
"maven example:goal-mp -DexampleProp=test") it works, so I guess the
system properties are loaded into the root context.

I also did a search of the mailing lists to check that its not something
mentioned recently, and found the following:
Interesting Response:

The response states that you can get around the issue by forcing the
property into the root context using something like:
<j:set var="maven.test.failure.ignore" scope="parent" value="true"/>

I'm using the interaction tag, so that's not immediately useful (i.e. it
doesn't have a scope property), although I could modify a few lines and
have it working.  It just seems wrong to me that I have to push them
into the root context.  I tried it too and it didn't work (I guess I've
got the wrong name for the context?).

So, in summary my questions are:
1) Am I missing something obvious such as an additional property that
can help me out?
2) Is my understanding of contexts correct?
3) Is setting values on the parent context good or bad practice?
4) Would it be worth while adding properties to the reactor/maven tag to
pass through the current context or some properties.

Thanks in advance

  <goal name="example:ensure-properties">
    <j:if test="${empty(exampleProp)}">
      <i:ask question="Please enter some text for exampleProp?" 
    <maven:param-check value="${exampleProp}" fail="true"
message="'exampleProp' must be specified"/>

  <goal name="example:goal" 
    <attainGoal name="example:goal-current-project"/>

  <goal name="example:goal-mp"
        description="Goal for the multiproject set">
    <maven:pluginVar var="multiprojectIncludes"
    <maven:pluginVar var="multiprojectExcludes"
    <maven:pluginVar var="multiprojectBasedir"

    <maven:reactor basedir="${multiprojectBasedir}"
                   banner="Running example for:"

  <goal name="example:goal-current-project"
        description="Calls the goal for current project, use
example:goal or example:goal-mp rather than this goal directly">
    <maven:param-check value="${exampleProp}" fail="true"
message="'exampleProp' must be specified"/>
    <ant:echo>exampleProp is ${exampleProp}</ant:echo>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message