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/03/26 01:22:42 UTC

cvs commit: maven/src/java/org/apache/maven/plugin PluginManager.java JellyScriptHousing.java

brett       2004/03/25 16:22:42

  Modified:    src/java/org/apache/maven/plugin Tag: MAVEN-1_0-BRANCH
                        PluginManager.java JellyScriptHousing.java
  Log:
  refactoring to store values sooner
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.70.4.27 +3 -40     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.26
  retrieving revision 1.70.4.27
  diff -u -r1.70.4.26 -r1.70.4.27
  --- PluginManager.java	25 Mar 2004 05:13:05 -0000	1.70.4.26
  +++ PluginManager.java	26 Mar 2004 00:22:42 -0000	1.70.4.27
  @@ -94,8 +94,6 @@
   public class PluginManager extends AbstractMavenComponent
   {
       private static final String ROOT_MAVEN_CLASSLOADER = "root.maven";
  -    /** Plug-in default properties name. */
  -    private static final String PLUGIN_PROPERTIES_NAME = "plugin.properties";
   
       /** Logger */
       private static final Log log = LogFactory.getLog( PluginManager.class );
  @@ -574,53 +572,18 @@
               JellyScriptHousing housing = ( JellyScriptHousing ) j.next();
               artifactIdToHousingMap.put( housing.getProject().getArtifactId(), housing );
   
  -            File pluginDirectory = housing.getPluginDirectory();
  -            // TODO [1.0] - integrate into original pluginContext
  -            MavenUtils.integrateMapInContext( getPluginProperties( pluginDirectory ), baseContext );
  +            MavenUtils.integrateMapInContext( housing.getPluginProperties(), baseContext );
   
  -            // TODO [1.0]: necessary to create a new one every time?
  +            // TODO necessary to create a new one every time?
               MavenJellyContext pluginContext = new MavenJellyContext( baseContext );
               housing.getProject().pushContext( pluginContext );
               pluginContext.setInherit( true );
               pluginContext.setVariable( "context", pluginContext );
  -
  -            // TODO [1.0] - integrate into original pluginContext
               pluginContext.setVariable( "plugin", housing.getProject() );
  -            pluginContext.setVariable( "plugin.dir", pluginDirectory );
  -            pluginContext.setVariable( "plugin.resources", new File( pluginDirectory, "plugin-resources" ) );
   
               runScript( housing, pluginContext );
           }
           return pluginSet;
  -    }
  -
  -    /**
  -     * Retrieve the plugin's default properties.
  -     * 
  -     * @param unpackedPluginDir The location of the unpacked plugin.
  -     * @return The default properties file for the plugin, or <code>null</code>
  -     *         if no such plugin.
  -     * @throws IOException If an IO error occurs while attempting to read the
  -     *                     plugin's properties.
  -     */
  -    private Properties getPluginProperties( File unpackedPluginDir ) throws IOException
  -    {
  -        File propsFile = new File( unpackedPluginDir, PLUGIN_PROPERTIES_NAME );
  -
  -        if ( !propsFile.exists() )
  -        {
  -            return null;
  -        }
  -
  -        Properties props = new Properties();
  -
  -        FileInputStream in = new FileInputStream( propsFile );
  -
  -        props.load( in );
  -
  -        in.close();
  -
  -        return props;
       }
   
       /**
  
  
  
  1.3.4.8   +50 -2     maven/src/java/org/apache/maven/plugin/JellyScriptHousing.java
  
  Index: JellyScriptHousing.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/plugin/JellyScriptHousing.java,v
  retrieving revision 1.3.4.7
  retrieving revision 1.3.4.8
  diff -u -r1.3.4.7 -r1.3.4.8
  --- JellyScriptHousing.java	1 Mar 2004 22:36:38 -0000	1.3.4.7
  +++ JellyScriptHousing.java	26 Mar 2004 00:22:42 -0000	1.3.4.8
  @@ -21,6 +21,9 @@
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.util.HashMap;
  +import java.util.Map;
  +import java.util.Properties;
   
   import javax.xml.parsers.ParserConfigurationException;
   import javax.xml.parsers.SAXParser;
  @@ -42,6 +45,12 @@
    */
   public class JellyScriptHousing
   {
  +    /** Plug-in default properties name. */
  +    private static final String PLUGIN_PROPERTIES_NAME = "plugin.properties";
  +
  +    /** Plugin properties. */
  +    private Map pluginProperties = new HashMap();
  +
       /** Plugin Project. */
       private Project project;
   
  @@ -64,12 +73,13 @@
           this.parentContext = null;
       }
       
  -    public JellyScriptHousing( File pluginDir, MavenJellyContext parentContext )
  +    public JellyScriptHousing( File pluginDir, MavenJellyContext parentContext ) throws IOException
       {
           this.pluginDirectory = pluginDir;
           this.name = pluginDir.getName();
           this.source = new File( pluginDir, "plugin.jelly" );
           this.parentContext = parentContext;
  +        this.pluginProperties = loadPluginProperties();
       }
   
       // ----------------------------------------------------------------------
  @@ -154,9 +164,47 @@
       /**
        * @return
        */
  +    public Map getPluginProperties()
  +    {
  +        return pluginProperties;
  +    }
  +
  +    /**
  +     * @return
  +     */
       public File getPluginDirectory()
       {
           return pluginDirectory;
       }
   
  +    /**
  +     * Retrieve the plugin's default properties.
  +     * 
  +     * @param unpackedPluginDir The location of the unpacked plugin.
  +     * @return The default properties file for the plugin, or <code>null</code>
  +     *         if no such plugin.
  +     * @throws IOException If an IO error occurs while attempting to read the
  +     *                     plugin's properties.
  +     */
  +    private Map loadPluginProperties() throws IOException
  +    {
  +        Map map = new HashMap();
  +
  +        File propsFile = new File( pluginDirectory, PLUGIN_PROPERTIES_NAME );
  +
  +        if ( propsFile.exists() )
  +        {
  +            Properties props = new Properties();
  +            FileInputStream in = new FileInputStream( propsFile );
  +            props.load( in );
  +            in.close();
  +            map.putAll( props );
  +        }
  +
  +        map.put( "plugin.dir", pluginDirectory );
  +        map.put( "plugin.resources", new File( pluginDirectory, "plugin-resources" ) );
  +
  +        return map;
  +    }
   }
  +
  
  
  

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