You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/04/20 14:07:15 UTC

cvs commit: avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/model DefaultClasspath.java

mcconnell    2003/04/20 05:07:15

  Modified:    merlin/assembly/src/java/org/apache/avalon/assembly/engine/model
                        DefaultClasspath.java
  Log:
  Updated to move the supply fo the system and home directories from the constructor to the expand operation.
  
  Revision  Changes    Path
  1.4       +17 -41    avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/model/DefaultClasspath.java
  
  Index: DefaultClasspath.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/model/DefaultClasspath.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultClasspath.java	15 Apr 2003 04:43:55 -0000	1.3
  +++ DefaultClasspath.java	20 Apr 2003 12:07:15 -0000	1.4
  @@ -76,58 +76,34 @@
       private final ClasspathDescriptor m_classpath;
   
       /**
  -     * The directory from which classpath entries will be resolved.
  -     */
  -    private final File m_base;
  -
  -    /**
  -     * The directory from which respository references will be resolved.
  -     */
  -    private final File m_system;
  -
  -    /**
        * Create a new Classpath instance.
  -     * @param system the the base directory from which the system repository
  -     *    resource references will be resolved
  -     * @param base the base directory from which classpath fileset directories
  -     *   shall be resolved.
        * @param classpath the classpath descriptor
        */
  -    public DefaultClasspath( File system, File base, ClasspathDescriptor classpath )
  -    {
  -        m_base = base;
  -        m_classpath = classpath;
  -        m_system = system;
  -    }
  -
  -    /**
  -     * Create a new Classpath instance.
  -     * @param a url from which the base directory will be resolved
  -     * @param classpath the classpath descriptor
  -     * @exception IllegalArgumentException if the base directory cannot
  -     * be resolved from the supplied URL
  -     */
  -    public DefaultClasspath( File system, URL url, ClasspathDescriptor classpath )
  +    public DefaultClasspath( ClasspathDescriptor classpath )
               throws IllegalArgumentException
       {
  -        m_system = system;
  -        m_base = getBaseDirectory( url );
           m_classpath = classpath;
       }
   
       /**
        * Expand a classpath to an array of URLS.
  -     * @param home the base directory from which relative classpath entries
  +     * @param system the parent directory of the system repository
  +     * @param base the base directory from which relative classpath entries
        * will be resolved.
        */
  -    public URL[] expand()
  +    public URL[] expand( File system, File base )
       {
  +        if( base == null )
  +        {
  +            throw new NullPointerException( "base" );
  +        }
  +
           List list = new ArrayList();
           FilesetDescriptor[] dirs = m_classpath.getFilesetDescriptors();
           for( int i = 0; i < dirs.length; i++ )
           {
               FilesetDescriptor descriptor = dirs[i];
  -            File anchor = new File( m_base, descriptor.getBaseDirectory() );
  +            File anchor = new File( base, descriptor.getBaseDirectory() );
               if( !anchor.exists() )
               {
                   final String error =
  @@ -154,9 +130,9 @@
               }
           }
   
  -        if( m_system != null )
  +        if( system != null )
           {
  -            expandResources( list );
  +            expandResources( system, list );
           }
   
           return (URL[]) list.toArray( new URL[0] );
  @@ -175,7 +151,7 @@
       /**
        * Expand any resource declarations and add them to the supplied list.
        */
  -    private void expandResources( List list )
  +    private void expandResources( File system, List list )
       {
           ResourceDescriptor[] resources = m_classpath.getResourceDescriptors();
           for( int i = 0; i < resources.length; i++ )
  @@ -185,7 +161,7 @@
               final String name = resource.getName();
               final String version = resource.getVersion();
   
  -            File repository = new File( m_system, "repository" );
  +            File repository = new File( system, "repository" );
               File jars = new File( new File( repository, group ), "jars" );
               File target = new File( jars, name + "-" + version + ".jar" );
   
  @@ -198,13 +174,13 @@
                   } catch( Throwable e )
                   {
                       final String error =
  -                            "Malformed URL error while attempting add resource: " + resource;
  +                      "Malformed URL error while attempting add resource: " + resource;
                       throw new RuntimeException( error );
                   }
               } else
               {
                   final String error =
  -                        "Supplied resource declaration unresolvable: " + resource;
  +                  "Supplied resource declaration unresolvable: " + resource;
                   throw new IllegalArgumentException( error );
               }
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org