brett       2004/07/05 14:01:49

  Modified:    src/java/org/apache/maven/plugin Tag: MAVEN-1_0-BRANCH
                        PluginManager.java
               src/test/touchstone-build Tag: MAVEN-1_0-BRANCH maven.xml
               xdocs    Tag: MAVEN-1_0-BRANCH changes.xml
  Log:
  <maven:get/> and <maven:set/> initialise a plugin if it hasn't been already
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.70.4.51 +46 -19    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.50
  retrieving revision 1.70.4.51
  diff -u -r1.70.4.50 -r1.70.4.51
  --- PluginManager.java        2 Jul 2004 10:55:19 -0000       1.70.4.50
  +++ PluginManager.java        5 Jul 2004 21:01:48 -0000       1.70.4.51
  @@ -85,10 +85,11 @@
   */
   
   /**
  - * Plugin manager for MavenSession. <p>
  + * Plugin manager for MavenSession.
    * <p/>
    * The <code>PluginManager</code> deals with all aspects of a plugins lifecycle.
  - * </p>
  + * <p/>
  + * This is <b>not</b> thread safe.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">bob mcwhirter</a>
  @@ -143,6 +144,9 @@
       /** Plugins to be popped afterwards. */
       private Set delayedPops = new HashSet();
   
  +    /** The current goal attainment base context. */
  +    private MavenJellyContext baseContext;
  +
       /**
        * Default constructor.
        *
  @@ -491,7 +495,8 @@
        */
       public void attainGoals( Project project, List goals ) throws Exception
       {
  -        MavenJellyContext baseContext = new MavenJellyContext( 
mavenSession.getRootContext() );
  +        MavenJellyContext prevBaseContext = baseContext;
  +        baseContext = new MavenJellyContext( mavenSession.getRootContext() );
           baseContext.setInherit( true );
           JellyUtils.populateVariables( baseContext, project.getContext() );
           project.pushContext( baseContext );
  @@ -639,6 +644,7 @@
               cleanupAttainGoal( pluginSet );
               delayedPops = oldDelayedPops;
               project.popContext();
  +            baseContext = prevBaseContext;
           }
       }
   
  @@ -676,23 +682,30 @@
           for ( Iterator j = pluginSet.iterator(); j.hasNext();)
           {
               JellyScriptHousing housing = ( JellyScriptHousing ) j.next();
  -            Project project = housing.getProject();
  +            initialiseHousingPluginContext( housing, baseContext );
  +        }
  +        return pluginSet;
  +    }
   
  -            MavenUtils.integrateMapInContext( housing.getPluginProperties(), 
baseContext );
  +    private MavenJellyContext initialiseHousingPluginContext( JellyScriptHousing 
housing, MavenJellyContext baseContext ) throws Exception
  +    {
  +        Project project = housing.getProject();
   
  -            // TODO necessary to create a new one every time?
  -            MavenJellyContext pluginContext = new MavenJellyContext( baseContext );
  -            project.pushContext( pluginContext );
  -            pluginContext.setInherit( true );
  -            pluginContext.setVariable( "context", pluginContext );
  -            pluginContext.setVariable( "plugin", project );
  -            pluginContext.setVariable( "plugin.dir", housing.getPluginDirectory() );
  -            pluginContext.setVariable( "plugin.resources", new File( 
housing.getPluginDirectory(), "plugin-resources" ) );
  +        MavenUtils.integrateMapInContext( housing.getPluginProperties(), 
baseContext );
   
  -            log.debug( "initialising plugin housing: " + project );
  -            runScript( housing, pluginContext );
  -        }
  -        return pluginSet;
  +        // TODO necessary to create a new one every time?
  +        MavenJellyContext pluginContext = new MavenJellyContext( baseContext );
  +        project.pushContext( pluginContext );
  +        pluginContext.setInherit( true );
  +        pluginContext.setVariable( "context", pluginContext );
  +        pluginContext.setVariable( "plugin", project );
  +        pluginContext.setVariable( "plugin.dir", housing.getPluginDirectory() );
  +        pluginContext.setVariable( "plugin.resources", new File( 
housing.getPluginDirectory(), "plugin-resources" ) );
  +
  +        log.debug( "initialising plugin housing: " + project );
  +        runScript( housing, pluginContext );
  +
  +        return pluginContext;
       }
   
       /**
  @@ -875,7 +888,21 @@
           if ( housing != null )
           {
               Project project = housing.getProject();
  -            return project.getContext();
  +            if ( baseContext != project.getContext().getParent() )
  +            {
  +                log.debug("Plugin context for " + id + " not initialised for this 
base context: initialising inside getPluginContext");
  +                try {
  +                    return initialiseHousingPluginContext( housing, baseContext );
  +                }
  +                catch (Exception e) {
  +                    throw new MavenException("Error initialising plugin context", 
e);
  +                }
  +            }
  +            else
  +            {
  +                log.debug("Plugin context for " + id + " already initialised for 
this base context");
  +                return project.getContext();
  +            }
           }
           throw new UnknownPluginException( id );
       }
  
  
  
  No                   revision
  No                   revision
  1.43.4.18 +19 -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.17
  retrieving revision 1.43.4.18
  diff -u -r1.43.4.17 -r1.43.4.18
  --- maven.xml 13 May 2004 10:15:55 -0000      1.43.4.17
  +++ maven.xml 5 Jul 2004 21:01:49 -0000       1.43.4.18
  @@ -17,6 +17,7 @@
    -->
   
   <project
  +  xmlns:multiproject="multiproject"
     default="jar:jar"
     xmlns:j="jelly:core"
     xmlns:ant="jelly:ant"
  @@ -68,6 +69,8 @@
      -->
   
     <goal name="touchstone-tests">
  +    <attainGoal name="test-plugin-loading" />
  +
       <attainGoal name="touchstone-goal-A"/>
       <maven:pluginVar var="checkValue" plugin="maven-touchstone-plugin" 
property="touchstone_goal_A_from_plugin"/>
       <j:if test="${checkValue == 'true'}">
  @@ -838,6 +841,22 @@
       <maven:get var="checkValue" plugin="maven-touchstone-plugin" 
property="touchstone_goal_B_from_plugin"/>
       <j:if test="${checkValue != 'blah'}">
         <fail message=""> maven:set failed </fail>
  +    </j:if>
  +  </goal>
  +
  +  <goal name="test-plugin-loading" prereqs="xdoc:init">
  +    <maven:get plugin="maven-xdoc-plugin" property="maven.xdoc.theme" var="d" />
  +    <j:if test="${d != 'theme'}">
  +      <fail>maven.xdoc.theme in xdoc plugin is not 'theme', is '${d}'</fail>
  +    </j:if>
  +    <multiproject:dependency-handle />
  +    <maven:get plugin="maven-multiproject-plugin" 
property="maven.multiproject.includes" var="d" />
  +    <j:if test="${d != '*/project.xml'}">
  +      <fail>maven.multiproject.includes in multiproject plugin is not 
'*/project.xml', is '${d}'</fail>
  +    </j:if>
  +    <maven:get plugin="maven-dist-plugin" property="maven.dist.tar.executable" 
var="d" />
  +    <j:if test="${d != 'tar'}">
  +      <fail>maven.dist.tar.executable in dist plugin is not 'tar', is '${d}'</fail>
       </j:if>
     </goal>
   </project>
  
  
  
  No                   revision
  No                   revision
  1.14.4.29 +1 -0      maven/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven/xdocs/changes.xml,v
  retrieving revision 1.14.4.28
  retrieving revision 1.14.4.29
  diff -u -r1.14.4.28 -r1.14.4.29
  --- changes.xml       1 Jul 2004 14:03:00 -0000       1.14.4.28
  +++ changes.xml       5 Jul 2004 21:01:49 -0000       1.14.4.29
  @@ -25,6 +25,7 @@
     </properties>
     <body>
       <release version="1.0-final-SNAPSHOT" date="in CVS">
  +      <action dev="brett" type="fix">&lt;maven:get/&gt; now initialises the plugin 
if it has not already been loaded, removing the need for dependency handles</action>
         <action dev="brett" type="fix" issue="MAVEN-1188">Check last modified 
timestamp as well as conditional GET in case the server time is behind the local 
time</action>
         <action dev="brett" type="fix" issue="MAVEN-1343">Bugfixes for new httpclient 
based downloading (incorrect timestamps)</action>
         <action dev="brett" type="fix" issue="MAVEN-1353">Handle cross site 
redirects</action>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to