You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2004/04/25 01:11:23 UTC

cvs commit: maven/src/test/touchstone-build/src/reactor-build/inheritence/subproject/subproject2 maven.xml

brett       2004/04/24 16:11:23

  Modified:    src/java/org/apache/maven Tag: MAVEN-1_0-BRANCH
                        MavenUtils.java
               src/java/org/apache/maven/plugin Tag: MAVEN-1_0-BRANCH
                        PluginManager.java
               src/java/org/apache/maven/jelly Tag: MAVEN-1_0-BRANCH
                        JellyUtils.java
               src/test/touchstone-build Tag: MAVEN-1_0-BRANCH maven.xml
               src/test/touchstone-build/src/reactor-build/inheritence Tag:
                        MAVEN-1_0-BRANCH maven.xml
               src/test/touchstone-build/src/reactor-build/inheritence/subproject
                        Tag: MAVEN-1_0-BRANCH maven.xml
               src/test/touchstone-build/src/reactor-build/inheritence/subproject/subproject2
                        Tag: MAVEN-1_0-BRANCH maven.xml
  Log:
  improve inheritence tests, fix parent property inheritence.
  setVariables( context.getVariables() ) will obviously not pass in properties from a parent
  context of context, so these were replaced with an iterating function to fold them in to the
  new context (which has an alternative parent context tree).
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.107.4.20 +2 -2      maven/src/java/org/apache/maven/MavenUtils.java
  
  Index: MavenUtils.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/MavenUtils.java,v
  retrieving revision 1.107.4.19
  retrieving revision 1.107.4.20
  diff -u -r1.107.4.19 -r1.107.4.20
  --- MavenUtils.java	23 Apr 2004 03:19:28 -0000	1.107.4.19
  +++ MavenUtils.java	24 Apr 2004 23:11:23 -0000	1.107.4.20
  @@ -337,7 +337,7 @@
           // can change this but I think we would like to avoid general Jelly
           // idiom in the POM anyway.
           JellyContext context = new JellyContext();
  -        context.setVariables( originalContext.getVariables() );
  +        JellyUtils.populateVariables( context, originalContext );
   
           // We don't want the context or the parent being written out into the XML which
           // is the interpolated POM.
  
  
  
  No                   revision
  No                   revision
  1.70.4.41 +2 -3      maven/src/java/org/apache/maven/plugin/PluginManager.java
  
  Index: PluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/plugin/PluginManager.java,v
  retrieving revision 1.70.4.40
  retrieving revision 1.70.4.41
  diff -u -r1.70.4.40 -r1.70.4.41
  --- PluginManager.java	23 Apr 2004 03:19:28 -0000	1.70.4.40
  +++ PluginManager.java	24 Apr 2004 23:11:23 -0000	1.70.4.41
  @@ -471,8 +471,7 @@
       {
           MavenJellyContext baseContext = new MavenJellyContext( mavenSession.getRootContext() );
           baseContext.setInherit( true );
  -        baseContext.setVariables( project.getContext().getVariables() );
  -        baseContext.setVariable( "context", baseContext );
  +        JellyUtils.populateVariables( baseContext, project.getContext() );
           project.pushContext( baseContext );
           baseContext.setProject( project );
   
  
  
  
  No                   revision
  No                   revision
  1.16.4.8  +17 -1     maven/src/java/org/apache/maven/jelly/JellyUtils.java
  
  Index: JellyUtils.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/jelly/JellyUtils.java,v
  retrieving revision 1.16.4.7
  retrieving revision 1.16.4.8
  diff -u -r1.16.4.7 -r1.16.4.8
  --- JellyUtils.java	2 Apr 2004 23:43:09 -0000	1.16.4.7
  +++ JellyUtils.java	24 Apr 2004 23:11:23 -0000	1.16.4.8
  @@ -236,4 +236,20 @@
           System.out.println( "======== comparison  done ========" );
       }
   
  +    /**
  +     * Populate a context with variables, including parent variables if inheritence is enabled.
  +     *
  +     * @param destContext the destination context
  +     * @param srcContext the source context
  +     */
  +    public static void populateVariables( JellyContext destContext, JellyContext sourceContext )
  +    {
  +        if ( sourceContext != null )
  +        {
  +            populateVariables( destContext, sourceContext.isInherit() ? sourceContext.getParent() : null );
  +            destContext.getVariables().putAll( sourceContext.getVariables() );
  +        }
  +        destContext.setVariable( "context", destContext );
  +    }
   }
  +
  
  
  
  No                   revision
  No                   revision
  1.43.4.13 +16 -0     maven/src/test/touchstone-build/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/test/touchstone-build/maven.xml,v
  retrieving revision 1.43.4.12
  retrieving revision 1.43.4.13
  diff -u -r1.43.4.12 -r1.43.4.13
  --- maven.xml	4 Apr 2004 02:50:45 -0000	1.43.4.12
  +++ maven.xml	24 Apr 2004 23:11:23 -0000	1.43.4.13
  @@ -212,6 +212,7 @@
       <attainGoal name="test-reactor-run-twice" />
       <attainGoal name="test-context-switch" />
       <attainGoal name="test-defaults" />
  +    <attainGoal name="test-inheritence" />
   
   <!-- TODO - this is still broken (as in RC1)
       <attainGoal name="test-reactor-maven-username" />
  @@ -750,6 +751,21 @@
       <maven:maven
         descriptor="${basedir}/src/reactor-build/run_twice/project.xml"
         goals="run_twice"
  +      ignoreFailures="false"
  +    />
  +  </goal>
  +
  +  <goal name="test-inheritence">
  +    <ant:echo>Testing 1 level</ant:echo>
  +    <maven:maven
  +      descriptor="${basedir}/src/reactor-build/inheritence/subproject/project.xml"
  +      goals="runTest"
  +      ignoreFailures="false"
  +    />
  +    <ant:echo>Testing 2 levels</ant:echo>
  +    <maven:maven
  +      descriptor="${basedir}/src/reactor-build/inheritence/subproject/subproject2/project.xml"
  +      goals="runTest"
         ignoreFailures="false"
       />
     </goal>
  
  
  
  No                   revision
  No                   revision
  1.1.4.3   +15 -8     maven/src/test/touchstone-build/src/reactor-build/inheritence/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/test/touchstone-build/src/reactor-build/inheritence/maven.xml,v
  retrieving revision 1.1.4.2
  retrieving revision 1.1.4.3
  diff -u -r1.1.4.2 -r1.1.4.3
  --- maven.xml	4 Mar 2004 17:47:01 -0000	1.1.4.2
  +++ maven.xml	24 Apr 2004 23:11:23 -0000	1.1.4.3
  @@ -16,11 +16,18 @@
    * limitations under the License.
    */
    -->
  -
  -<project xmlns:j="jelly:core" xmlns:ant="jelly:ant">
  -
  -    <goal name="parent-goal">
  -      <ant:property name="parentVar" value="parentVar" />
  -    </goal>
  -
  -</project>
  +
  +<project xmlns:j="jelly:core" xmlns:ant="jelly:ant">
  +
  +    <goal name="parent-goal">
  +      <ant:property name="parentVar" value="parentVar" />
  +    </goal>
  +
  +    <goal name="parent-goal-override-1">
  +      <ant:property name="parentVarOverride1" value="parentVar" />
  +    </goal>
  +
  +    <goal name="parent-goal-override-2">
  +      <ant:property name="parentVarOverride2" value="parentVar" />
  +    </goal>
  +</project>
  
  
  
  No                   revision
  No                   revision
  1.1.4.3   +40 -28    maven/src/test/touchstone-build/src/reactor-build/inheritence/subproject/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/test/touchstone-build/src/reactor-build/inheritence/subproject/maven.xml,v
  retrieving revision 1.1.4.2
  retrieving revision 1.1.4.3
  diff -u -r1.1.4.2 -r1.1.4.3
  --- maven.xml	4 Mar 2004 17:47:01 -0000	1.1.4.2
  +++ maven.xml	24 Apr 2004 23:11:23 -0000	1.1.4.3
  @@ -16,31 +16,43 @@
    * limitations under the License.
    */
    -->
  -
  -<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" default="runTest">
  -
  -    <goal name="runTest">
  -      <attainGoal name="parent-goal" />
  -      <j:if test="${parentVar != 'parentVar'}">
  -        <ant:fail>Sorry, but parentVar = '${parentVar}', not inherited</ant:fail>
  -      </j:if>
  -
  -      <j:set var="value" value="${parent.project.property}" />
  -      <j:if test="${value != 'okiedokie'}">
  -        <ant:fail>Sorry, but parent.project.property = '${value}', not inherited</ant:fail>
  -      </j:if>
  -      <j:set var="value" value="${parent.build.property}" />
  -      <j:if test="${value != 'okiedokie'}">
  -        <ant:fail>Sorry, but parent.build.property = '${value}', not inherited</ant:fail>
  -      </j:if>
  -      <j:set var="value" value="${parent.project.property.override}" />
  -      <j:if test="${value != 'overridden'}">
  -        <ant:fail>Sorry, but parent.project.property.override = '${value}', inherited incorrectly</ant:fail>
  -      </j:if>
  -      <j:set var="value" value="${parent.build.property.override}" />
  -      <j:if test="${value != 'overridden'}">
  -        <ant:fail>Sorry, but parent.build.property.override = '${value}', inherited incorrectly</ant:fail>
  -      </j:if>
  -    </goal>
  -
  -</project>
  +
  +<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" default="runTest">
  +
  +    <goal name="runTest">
  +      <ant:echo>inherited goal test</ant:echo>
  +      <attainGoal name="parent-goal" />
  +      <j:if test="${parentVar != 'parentVar'}">
  +        <ant:fail>Sorry, but parentVar = '${parentVar}', not inherited</ant:fail>
  +      </j:if>
  +      <ant:echo>test goal overridden</ant:echo>
  +      <attainGoal name="parent-goal-override-1" />
  +      <j:if test="${parentVarOverride1 == 'parentVar'}">
  +        <ant:fail>Sorry, but parentVarOverride1 = '${parentVar}', inherited in subproject by mistake</ant:fail>
  +      </j:if>
  +      <ant:echo>inherited project property test</ant:echo>
  +      <j:set var="value" value="${parent.project.property}" />
  +      <j:if test="${value != 'okiedokie'}">
  +        <ant:fail>Sorry, but parent.project.property = '${value}', not inherited</ant:fail>
  +      </j:if>
  +      <ant:echo>inherited build property test</ant:echo>
  +      <j:set var="value" value="${parent.build.property}" />
  +      <j:if test="${value != 'okiedokie'}">
  +        <ant:fail>Sorry, but parent.build.property = '${value}', not inherited</ant:fail>
  +      </j:if>
  +      <ant:echo>inherited project property override test</ant:echo>
  +      <j:set var="value" value="${parent.project.property.override}" />
  +      <j:if test="${value != 'overridden'}">
  +        <ant:fail>Sorry, but parent.project.property.override = '${value}', inherited incorrectly</ant:fail>
  +      </j:if>
  +      <ant:echo>inherited build property override test</ant:echo>
  +      <j:set var="value" value="${parent.build.property.override}" />
  +      <j:if test="${value != 'overridden'}">
  +        <ant:fail>Sorry, but parent.build.property.override = '${value}', inherited incorrectly</ant:fail>
  +      </j:if>
  +    </goal>
  +
  +    <goal name="parent-goal-override-1">
  +      <ant:echo>Inside overridden goal</ant:echo>
  +    </goal>
  +</project>
  
  
  
  No                   revision
  No                   revision
  1.1.4.3   +52 -38    maven/src/test/touchstone-build/src/reactor-build/inheritence/subproject/subproject2/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/test/touchstone-build/src/reactor-build/inheritence/subproject/subproject2/maven.xml,v
  retrieving revision 1.1.4.2
  retrieving revision 1.1.4.3
  diff -u -r1.1.4.2 -r1.1.4.3
  --- maven.xml	4 Mar 2004 17:47:01 -0000	1.1.4.2
  +++ maven.xml	24 Apr 2004 23:11:23 -0000	1.1.4.3
  @@ -16,41 +16,55 @@
    * limitations under the License.
    */
    -->
  -
  -<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" default="runTest">
  -
  -    <goal name="runTest">
  -<!--
  -      <attainGoal name="parent-goal" />
  --->
  -      <j:if test="${parentVar != 'parentVar'}">
  -        <ant:fail>Sorry, but parentVar = '${parentVar}', not inherited in 2nd subproject</ant:fail>
  -      </j:if>
  -
  -      <j:set var="value" value="${subproject.project.property}" />
  -      <j:if test="${value != 'okiedokie'}">
  -        <ant:fail>Sorry, but subproject.project.property = '${value}', not inherited in 2nd subproject</ant:fail>
  -      </j:if>
  -      <j:set var="value" value="${subproject.build.property}" />
  -      <j:if test="${value != 'okiedokie'}">
  -        <ant:fail>Sorry, but subproject.build.property = '${value}', not inherited in 2nd subproject</ant:fail>
  -      </j:if>
  -      <j:set var="value" value="${parent.project.property}" />
  -      <j:if test="${value != 'okiedokie'}">
  -        <ant:fail>Sorry, but parent.project.property = '${value}', not inherited in 2nd subproject</ant:fail>
  -      </j:if>
  -      <j:set var="value" value="${parent.build.property}" />
  -      <j:if test="${value != 'okiedokie'}">
  -        <ant:fail>Sorry, but parent.build.property = '${value}', not inherited in 2nd subproject</ant:fail>
  -      </j:if>
  -      <j:set var="value" value="${parent.project.property.override}" />
  -      <j:if test="${value != 'overridden'}">
  -        <ant:fail>Sorry, but parent.project.property.override = '${value}', inherited incorrectly in 2nd subproject</ant:fail>
  -      </j:if>
  -      <j:set var="value" value="${parent.build.property.override}" />
  -      <j:if test="${value != 'overridden'}">
  -        <ant:fail>Sorry, but parent.build.property.override = '${value}', inherited incorrectly in 2nd subproject</ant:fail>
  -      </j:if>
  -    </goal>
  -
  -</project>
  +
  +<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" default="runTest">
  +
  +    <goal name="runTest">
  +      <ant:echo>test goal presence two deep</ant:echo>
  +      <attainGoal name="parent-goal" />
  +      <j:if test="${parentVar != 'parentVar'}">
  +        <ant:fail>Sorry, but parentVar = '${parentVar}', not inherited in 2nd subproject</ant:fail>
  +      </j:if>
  +
  +      <ant:echo>test goal overridden two deep</ant:echo>
  +      <attainGoal name="parent-goal-override-2" />
  +      <j:if test="${parentVarOverride2 == 'parentVar'}">
  +        <ant:fail>Sorry, but parentVarOverride2 = '${parentVar}', inherited in 2nd subproject by mistake</ant:fail>
  +      </j:if>
  +
  +      <ant:echo>test project property one deep</ant:echo>
  +      <j:set var="value" value="${subproject.project.property}" />
  +      <j:if test="${value != 'okiedokie'}">
  +        <ant:fail>Sorry, but subproject.project.property = '${value}', not inherited in 2nd subproject</ant:fail>
  +      </j:if>
  +      <ant:echo>test build property one deep</ant:echo>
  +      <j:set var="value" value="${subproject.build.property}" />
  +      <j:if test="${value != 'okiedokie'}">
  +        <ant:fail>Sorry, but subproject.build.property = '${value}', not inherited in 2nd subproject</ant:fail>
  +      </j:if>
  +      <ant:echo>test project property two deep</ant:echo>
  +      <j:set var="value" value="${parent.project.property}" />
  +      <j:if test="${value != 'okiedokie'}">
  +        <ant:fail>Sorry, but parent.project.property = '${value}', not inherited in 2nd subproject</ant:fail>
  +      </j:if>
  +      <ant:echo>test build property two deep</ant:echo>
  +      <j:set var="value" value="${parent.build.property}" />
  +      <j:if test="${value != 'okiedokie'}">
  +        <ant:fail>Sorry, but parent.build.property = '${value}', not inherited in 2nd subproject</ant:fail>
  +      </j:if>
  +      <ant:echo>test project property override two deep</ant:echo>
  +      <j:set var="value" value="${parent.project.property.override}" />
  +      <j:if test="${value != 'overridden2'}">
  +        <ant:fail>Sorry, but parent.project.property.override = '${value}', inherited incorrectly in 2nd subproject</ant:fail>
  +      </j:if>
  +      <ant:echo>test build property override two deep</ant:echo>
  +      <j:set var="value" value="${parent.build.property.override}" />
  +      <j:if test="${value != 'overridden2'}">
  +        <ant:fail>Sorry, but parent.build.property.override = '${value}', inherited incorrectly in 2nd subproject</ant:fail>
  +      </j:if>
  +    </goal>
  +
  +    <goal name="parent-goal-override-2">
  +      <ant:echo>Inside overridden goal</ant:echo>
  +    </goal>
  +</project>
  
  
  

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