ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/extensions DefaultExtensionManager.java
Date Thu, 07 Feb 2002 11:49:51 GMT
donaldp     02/02/07 03:49:51

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/extensions
                        DefaultExtensionManager.java
  Log:
  Fake tools.jar as an optional package
  
  Revision  Changes    Path
  1.4       +52 -1     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/extensions/DefaultExtensionManager.java
  
  Index: DefaultExtensionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/extensions/DefaultExtensionManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultExtensionManager.java	23 Dec 2001 06:25:35 -0000	1.3
  +++ DefaultExtensionManager.java	7 Feb 2002 11:49:51 -0000	1.4
  @@ -9,6 +9,10 @@
   
   import java.io.File;
   import org.apache.avalon.excalibur.extension.DefaultPackageRepository;
  +import org.apache.avalon.excalibur.extension.Extension;
  +import org.apache.avalon.excalibur.extension.OptionalPackage;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.excalibur.util.StringUtil;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
  @@ -23,12 +27,17 @@
    * PhoenixPackageRepository
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.3 $ $Date: 2001/12/23 06:25:35 $
  + * @version $Revision: 1.4 $ $Date: 2002/02/07 11:49:51 $
    */
   public class DefaultExtensionManager
       extends DefaultPackageRepository
       implements LogEnabled, Parameterizable, Initializable, Disposable, ExtensionManager
   {
  +    private static final Resources REZ =
  +        ResourceManager.getPackageResources( DefaultExtensionManager.class );
  +
  +    private static final String TOOLS_JAR = File.separator + "lib" + File.separator + "tools.jar";
  +
       private Logger m_logger;
   
       private String m_path;
  @@ -65,6 +74,13 @@
           setPath( dirs );
   
           scanPath();
  +
  +        final Extension extension = createToolsExtension();
  +        final File jar = getToolsJar();
  +        final Extension[] available = new Extension[]{extension};
  +        final Extension[] required = new Extension[ 0 ];
  +        final OptionalPackage toolsPackage = new OptionalPackage( jar, available, required
);
  +        cacheOptionalPackage( toolsPackage );
       }
   
       public void dispose()
  @@ -75,5 +91,40 @@
       protected void debug( final String message )
       {
           m_logger.debug( message );
  +    }
  +
  +    private File getToolsJar()
  +        throws Exception
  +    {
  +        final String javaHome = System.getProperty( "java.home" );
  +        String jdkHome;
  +        if( javaHome.endsWith( "jre" ) )
  +        {
  +            jdkHome = javaHome.substring( 0, javaHome.length() - 4 );
  +        }
  +        else
  +        {
  +            jdkHome = javaHome;
  +        }
  +
  +        final File tools = new File( jdkHome + TOOLS_JAR );
  +        if( !tools.exists() )
  +        {
  +            final String message = REZ.getString( "extension.missing-tools.error" );
  +            throw new Exception( message );
  +        }
  +
  +        return tools;
  +    }
  +
  +    private Extension createToolsExtension()
  +    {
  +        return new Extension( "com.sun.tools",
  +                              "1.0",
  +                              "com.sun",
  +                              "1.0",
  +                              "com.sun",
  +                              "com.sun",
  +                              null );
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message