maven-dev mailing list archives

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

Hi,

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:
Search:
http://marc.theaimsgroup.com/?l=turbine-maven-user&w=2&r=1&s=reactor+pas
sing+values&q=b
Interesting Response:
http://marc.theaimsgroup.com/?l=turbine-maven-user&m=109724500600171&w=2

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
Kris.




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

  <goal name="example:goal" 
        prereqs="example:ensure-properties"
        description="Goal">
    <attainGoal name="example:goal-current-project"/>
  </goal>

  <goal name="example:goal-mp"
        prereqs="example:ensure-properties"
        description="Goal for the multiproject set">
    <maven:pluginVar var="multiprojectIncludes"
plugin="maven-multiproject-plugin"
property="maven.multiproject.includes"/>
    <maven:pluginVar var="multiprojectExcludes"
plugin="maven-multiproject-plugin"
property="maven.multiproject.excludes"/>
    <maven:pluginVar var="multiprojectBasedir"
plugin="maven-multiproject-plugin"
property="maven.multiproject.basedir"/>

    <maven:reactor basedir="${multiprojectBasedir}"
                   banner="Running example for:"
                   postProcessing="true" 
                   goals="example:goal-current-project"
                   includes="${multiprojectIncludes}"
                   excludes="${multiprojectExcludes}"
                   ignoreFailures="false"/>
  </goal>

  <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>
  </goal>






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


Mime
View raw message