brett       2003/12/10 15:08:45

  Modified:    src/java/org/apache/maven Tag: MAVEN-1_0-BRANCH
                        MavenUtils.java
               src/java/org/apache/maven/jelly/tags/maven Tag:
                        MAVEN-1_0-BRANCH PluginVarTag.java
               src/java/org/apache/maven/plugin Tag: MAVEN-1_0-BRANCH
                        PluginManager.java
               src/java/org/apache/maven/project Tag: MAVEN-1_0-BRANCH
                        Project.java
  Added:       src/java/org/apache/maven/plugin Tag: MAVEN-1_0-BRANCH
                        UnknownPluginException.java
  Log:
  Fix bug with werkz, better handling of plugins not being found, fix bug when no 
project.xml present
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.107.4.3 +7 -1      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.2
  retrieving revision 1.107.4.3
  diff -u -r1.107.4.2 -r1.107.4.3
  --- MavenUtils.java   2 Dec 2003 04:09:25 -0000       1.107.4.2
  +++ MavenUtils.java   10 Dec 2003 23:08:44 -0000      1.107.4.3
  @@ -225,6 +225,12 @@
                   parent = (Project) getProjectBeanReader().parse( parentPom );
                   parent.setFile( parentPom );
                   parentPoms.put( parentPom.getCanonicalPath(), parent );
  +// TODO [RC2] - check -vvv-
  +        MavenJellyContext pContext = MavenUtils.createContext( 
projectDescriptor.getParentFile(),
  +                                                              parentContext );
  +parent.setContext(pContext);
  +context.setParent(pContext);
  +// TODO [RC2] - check -^^^-
               }
   
               Properties properties = loadProjectBuildProperties( 
parentPom.getParentFile() );
  
  
  
  No                   revision
  No                   revision
  1.1.4.1   +17 -7     
maven/src/java/org/apache/maven/jelly/tags/maven/PluginVarTag.java
  
  Index: PluginVarTag.java
  ===================================================================
  RCS file: 
/home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/PluginVarTag.java,v
  retrieving revision 1.1
  retrieving revision 1.1.4.1
  diff -u -r1.1 -r1.1.4.1
  --- PluginVarTag.java 28 Oct 2003 18:08:46 -0000      1.1
  +++ PluginVarTag.java 10 Dec 2003 23:08:44 -0000      1.1.4.1
  @@ -62,6 +62,7 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.maven.jelly.MavenJellyContext;
   import org.apache.maven.jelly.tags.BaseTagSupport;
  +import org.apache.maven.plugin.UnknownPluginException;
   import org.apache.maven.project.Project;
   
   /**
  @@ -90,16 +91,25 @@
           checkAttribute(plugin, "plugin");
           checkAttribute(property, "property");
           Project project = getMavenContext().getProject();
  -        MavenJellyContext context = project.getPluginContext(plugin);
  -        if (context != null)
  +        try 
           {
  -            Object value = context.getVariable(property);
  -            getContext().setVariable(var, value);
  +            MavenJellyContext context = project.getPluginContext(plugin);
  +            if (context != null)
  +            {
  +                Object value = context.getVariable(property);
  +                getContext().setVariable(var, value);
  +            }
  +            else
  +            {
  +                log.error( "context for plugin '" + plugin + "' in project '" + 
  +                           project + "' is null" );
  +            }
           }
  -        else
  +        catch ( UnknownPluginException e )
           {
  -            log.debug("context for plugin '" + plugin + "' in project '" + project
  -                + "' is null");
  +// TODO [RC2] - restore
  + //           throw new JellyTagException( "Couldn't find the given plugin", e );
  +log.error("error", e );
           }
       }
   
  
  
  
  No                   revision
  No                   revision
  1.70.4.6  +25 -13    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.5
  retrieving revision 1.70.4.6
  diff -u -r1.70.4.5 -r1.70.4.6
  --- PluginManager.java        9 Dec 2003 23:41:16 -0000       1.70.4.5
  +++ PluginManager.java        10 Dec 2003 23:08:44 -0000      1.70.4.6
  @@ -543,8 +543,6 @@
           // add the global session to the pluginContext so that it can be used by 
tags
           baseContext.setVariable( GLOBAL_SESSION_KEY, session );
   
  -        WerkzProject werkzProject = buildWerkzProject( baseContext );
  -
           GoalToJellyScriptHousingMapper transientMapper = new 
GoalToJellyScriptHousingMapper();
   
           // Execution of the Jelly scripts:
  @@ -563,6 +561,8 @@
           // may wish to override so we guarantee precedence of the goals by running 
the jelly scripts
           // in the above mentioned order.
   
  +        List projectHousings = new ArrayList();
  +
           // driver.jelly
           InputStream driver = getClass().getResourceAsStream( "/driver.jelly" );
           JellyScriptHousing driverHousing = createJellyScriptHousing( project, null, 
driver );
  @@ -573,7 +573,8 @@
           transientMapper.parse( driver, driverHousing );
           driver.close();
           // TODO [RC2] remove - otherwise it gets run twice
  -        runJellyScriptHousing( driverHousing, baseContext );
  +        //runJellyScriptHousing( driverHousing, baseContext );
  +        projectHousings.add( driverHousing );
   
           Project p = project;
   
  @@ -586,7 +587,8 @@
               // TODO [RC2] stop reading all scripts 2 times
               transientMapper.parse( new FileInputStream( mavenXml ), 
jellyScriptHousing );
               // TODO [RC2] remove - otherwise it gets run twice
  -            runJellyScriptHousing( jellyScriptHousing, baseContext );
  +            //runJellyScriptHousing( jellyScriptHousing, baseContext );
  +            projectHousings.add( jellyScriptHousing );
   
               p = p.getParent();
           }
  @@ -609,12 +611,12 @@
           {
               String goalName = (String) i.next();
   
  -            WerkzProject attainWerkzProject = buildWerkzProject( baseContext );
  -            for ( Iterator j = werkzProject.getGoals().iterator(); j.hasNext(); ) {
  -                Goal goal = ( Goal ) j.next();
  -                attainWerkzProject.addGoal( goal );
  +            WerkzProject werkzProject = buildWerkzProject( baseContext );
  +            for ( Iterator j = projectHousings.iterator(); j.hasNext(); )
  +            {
  +                JellyScriptHousing housing = ( JellyScriptHousing ) j.next();
  +                runJellyScriptHousing( housing, baseContext );
               }
  -
               // Now at this point we should be able to use the name of a goal to 
lookup all
               // the plugins (that are stored in the plugin housings) that need to be 
executed
               // in order to satisfy all the required preconditions for successful 
goal attainment.
  @@ -625,6 +627,11 @@
               {
                   JellyScriptHousing housing = ( JellyScriptHousing ) j.next();
   
  +                if ( projectHousings.contains( housing ) )
  +                {
  +                    continue;
  +                }
  +
                   // FIXME: this is a bit nasty
                   File pluginDirectory = 
housing.getProject().getFile().getParentFile();
                   // TODO [RC2] - integrate into original pluginContext
  @@ -648,10 +655,10 @@
                   runJellyScriptHousing( housing, pluginContext );
               }
   
  -            Goal goal = attainWerkzProject.getGoal( goalName );
  +            Goal goal = werkzProject.getGoal( goalName );
               if ( goal == null )
               {
  -                // TODO [RC2] - how can we even get this far? resolve isn't working 
properly
  +                // TODO [RC2] - shouldn't even get this far, but resolve is being 
faked
                   throw new NoSuchGoalException( goalName );
               }
               goal.attain( session );
  @@ -820,8 +827,13 @@
           }
       }
   
  -    public Project getPluginProject( String id ) {
  +    public Project getPluginProject( String id ) throws UnknownPluginException 
  +    {
           JellyPlugin plugin = (JellyPlugin) plugins.get( id );
  +        if ( plugin == null ) 
  +        {
  +            throw new UnknownPluginException( id );
  +        }
           return plugin.getProject();
       }
   
  
  
  
  No                   revision
  
  Index: PluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/plugin/PluginManager.java,v
  retrieving revision 1.70.4.5
  retrieving revision 1.70.4.6
  diff -u -r1.70.4.5 -r1.70.4.6
  --- PluginManager.java        9 Dec 2003 23:41:16 -0000       1.70.4.5
  +++ PluginManager.java        10 Dec 2003 23:08:44 -0000      1.70.4.6
  @@ -543,8 +543,6 @@
           // add the global session to the pluginContext so that it can be used by 
tags
           baseContext.setVariable( GLOBAL_SESSION_KEY, session );
   
  -        WerkzProject werkzProject = buildWerkzProject( baseContext );
  -
           GoalToJellyScriptHousingMapper transientMapper = new 
GoalToJellyScriptHousingMapper();
   
           // Execution of the Jelly scripts:
  @@ -563,6 +561,8 @@
           // may wish to override so we guarantee precedence of the goals by running 
the jelly scripts
           // in the above mentioned order.
   
  +        List projectHousings = new ArrayList();
  +
           // driver.jelly
           InputStream driver = getClass().getResourceAsStream( "/driver.jelly" );
           JellyScriptHousing driverHousing = createJellyScriptHousing( project, null, 
driver );
  @@ -573,7 +573,8 @@
           transientMapper.parse( driver, driverHousing );
           driver.close();
           // TODO [RC2] remove - otherwise it gets run twice
  -        runJellyScriptHousing( driverHousing, baseContext );
  +        //runJellyScriptHousing( driverHousing, baseContext );
  +        projectHousings.add( driverHousing );
   
           Project p = project;
   
  @@ -586,7 +587,8 @@
               // TODO [RC2] stop reading all scripts 2 times
               transientMapper.parse( new FileInputStream( mavenXml ), 
jellyScriptHousing );
               // TODO [RC2] remove - otherwise it gets run twice
  -            runJellyScriptHousing( jellyScriptHousing, baseContext );
  +            //runJellyScriptHousing( jellyScriptHousing, baseContext );
  +            projectHousings.add( jellyScriptHousing );
   
               p = p.getParent();
           }
  @@ -609,12 +611,12 @@
           {
               String goalName = (String) i.next();
   
  -            WerkzProject attainWerkzProject = buildWerkzProject( baseContext );
  -            for ( Iterator j = werkzProject.getGoals().iterator(); j.hasNext(); ) {
  -                Goal goal = ( Goal ) j.next();
  -                attainWerkzProject.addGoal( goal );
  +            WerkzProject werkzProject = buildWerkzProject( baseContext );
  +            for ( Iterator j = projectHousings.iterator(); j.hasNext(); )
  +            {
  +                JellyScriptHousing housing = ( JellyScriptHousing ) j.next();
  +                runJellyScriptHousing( housing, baseContext );
               }
  -
               // Now at this point we should be able to use the name of a goal to 
lookup all
               // the plugins (that are stored in the plugin housings) that need to be 
executed
               // in order to satisfy all the required preconditions for successful 
goal attainment.
  @@ -625,6 +627,11 @@
               {
                   JellyScriptHousing housing = ( JellyScriptHousing ) j.next();
   
  +                if ( projectHousings.contains( housing ) )
  +                {
  +                    continue;
  +                }
  +
                   // FIXME: this is a bit nasty
                   File pluginDirectory = 
housing.getProject().getFile().getParentFile();
                   // TODO [RC2] - integrate into original pluginContext
  @@ -648,10 +655,10 @@
                   runJellyScriptHousing( housing, pluginContext );
               }
   
  -            Goal goal = attainWerkzProject.getGoal( goalName );
  +            Goal goal = werkzProject.getGoal( goalName );
               if ( goal == null )
               {
  -                // TODO [RC2] - how can we even get this far? resolve isn't working 
properly
  +                // TODO [RC2] - shouldn't even get this far, but resolve is being 
faked
                   throw new NoSuchGoalException( goalName );
               }
               goal.attain( session );
  @@ -820,8 +827,13 @@
           }
       }
   
  -    public Project getPluginProject( String id ) {
  +    public Project getPluginProject( String id ) throws UnknownPluginException 
  +    {
           JellyPlugin plugin = (JellyPlugin) plugins.get( id );
  +        if ( plugin == null ) 
  +        {
  +            throw new UnknownPluginException( id );
  +        }
           return plugin.getProject();
       }
   
  
  
  
  No                   revision
  
  Index: PluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/plugin/PluginManager.java,v
  retrieving revision 1.70.4.5
  retrieving revision 1.70.4.6
  diff -u -r1.70.4.5 -r1.70.4.6
  --- PluginManager.java        9 Dec 2003 23:41:16 -0000       1.70.4.5
  +++ PluginManager.java        10 Dec 2003 23:08:44 -0000      1.70.4.6
  @@ -543,8 +543,6 @@
           // add the global session to the pluginContext so that it can be used by 
tags
           baseContext.setVariable( GLOBAL_SESSION_KEY, session );
   
  -        WerkzProject werkzProject = buildWerkzProject( baseContext );
  -
           GoalToJellyScriptHousingMapper transientMapper = new 
GoalToJellyScriptHousingMapper();
   
           // Execution of the Jelly scripts:
  @@ -563,6 +561,8 @@
           // may wish to override so we guarantee precedence of the goals by running 
the jelly scripts
           // in the above mentioned order.
   
  +        List projectHousings = new ArrayList();
  +
           // driver.jelly
           InputStream driver = getClass().getResourceAsStream( "/driver.jelly" );
           JellyScriptHousing driverHousing = createJellyScriptHousing( project, null, 
driver );
  @@ -573,7 +573,8 @@
           transientMapper.parse( driver, driverHousing );
           driver.close();
           // TODO [RC2] remove - otherwise it gets run twice
  -        runJellyScriptHousing( driverHousing, baseContext );
  +        //runJellyScriptHousing( driverHousing, baseContext );
  +        projectHousings.add( driverHousing );
   
           Project p = project;
   
  @@ -586,7 +587,8 @@
               // TODO [RC2] stop reading all scripts 2 times
               transientMapper.parse( new FileInputStream( mavenXml ), 
jellyScriptHousing );
               // TODO [RC2] remove - otherwise it gets run twice
  -            runJellyScriptHousing( jellyScriptHousing, baseContext );
  +            //runJellyScriptHousing( jellyScriptHousing, baseContext );
  +            projectHousings.add( jellyScriptHousing );
   
               p = p.getParent();
           }
  @@ -609,12 +611,12 @@
           {
               String goalName = (String) i.next();
   
  -            WerkzProject attainWerkzProject = buildWerkzProject( baseContext );
  -            for ( Iterator j = werkzProject.getGoals().iterator(); j.hasNext(); ) {
  -                Goal goal = ( Goal ) j.next();
  -                attainWerkzProject.addGoal( goal );
  +            WerkzProject werkzProject = buildWerkzProject( baseContext );
  +            for ( Iterator j = projectHousings.iterator(); j.hasNext(); )
  +            {
  +                JellyScriptHousing housing = ( JellyScriptHousing ) j.next();
  +                runJellyScriptHousing( housing, baseContext );
               }
  -
               // Now at this point we should be able to use the name of a goal to 
lookup all
               // the plugins (that are stored in the plugin housings) that need to be 
executed
               // in order to satisfy all the required preconditions for successful 
goal attainment.
  @@ -625,6 +627,11 @@
               {
                   JellyScriptHousing housing = ( JellyScriptHousing ) j.next();
   
  +                if ( projectHousings.contains( housing ) )
  +                {
  +                    continue;
  +                }
  +
                   // FIXME: this is a bit nasty
                   File pluginDirectory = 
housing.getProject().getFile().getParentFile();
                   // TODO [RC2] - integrate into original pluginContext
  @@ -648,10 +655,10 @@
                   runJellyScriptHousing( housing, pluginContext );
               }
   
  -            Goal goal = attainWerkzProject.getGoal( goalName );
  +            Goal goal = werkzProject.getGoal( goalName );
               if ( goal == null )
               {
  -                // TODO [RC2] - how can we even get this far? resolve isn't working 
properly
  +                // TODO [RC2] - shouldn't even get this far, but resolve is being 
faked
                   throw new NoSuchGoalException( goalName );
               }
               goal.attain( session );
  @@ -820,8 +827,13 @@
           }
       }
   
  -    public Project getPluginProject( String id ) {
  +    public Project getPluginProject( String id ) throws UnknownPluginException 
  +    {
           JellyPlugin plugin = (JellyPlugin) plugins.get( id );
  +        if ( plugin == null ) 
  +        {
  +            throw new UnknownPluginException( id );
  +        }
           return plugin.getProject();
       }
   
  
  
  
  1.1.2.1   +90 -0     
maven/src/java/org/apache/maven/plugin/Attic/UnknownPluginException.java
  
  
  
  
  No                   revision
  No                   revision
  1.91.4.3  +5 -3      maven/src/java/org/apache/maven/project/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/project/Project.java,v
  retrieving revision 1.91.4.2
  retrieving revision 1.91.4.3
  diff -u -r1.91.4.2 -r1.91.4.3
  --- Project.java      9 Dec 2003 23:34:50 -0000       1.91.4.2
  +++ Project.java      10 Dec 2003 23:08:45 -0000      1.91.4.3
  @@ -66,6 +66,7 @@
   import org.apache.maven.MavenUtils;
   import org.apache.maven.jelly.MavenJellyContext;
   import org.apache.maven.plugin.PluginManager;
  +import org.apache.maven.plugin.UnknownPluginException;
   import org.apache.maven.repository.Artifact;
   import org.apache.maven.util.StringTool;
   import org.apache.maven.verifier.ChecksumVerificationException;
  @@ -360,8 +361,9 @@
        * @todo [1.0] - when we are caching plugins, this should load on demand
        * @return The plugin context create for the named plugin when it was loaded for
        *         this project.
  +     * @throws UnknownPluginException if the plugin could not be found
        */
  -    public MavenJellyContext getPluginContext( String pluginId )
  +    public MavenJellyContext getPluginContext( String pluginId ) throws 
UnknownPluginException
       {
           PluginManager pluginManager = 
getContext().getMavenSession().getPluginManager();
           Project plugin = pluginManager.getPluginProject( pluginId );
  @@ -1364,7 +1366,7 @@
           ChecksumVerificationException
       {
           // Only attempt to verify the dependencies if a project.xml file exists.
  -        if ( getFile() != null )
  +        if ( getFile() != null && getFile().exists() )
           {
               getDependencyVerifier().verify();
           }
  
  
  

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

Reply via email to