mcconnell 2003/02/16 02:59:34 Modified: assembly/src/java/org/apache/avalon/assembly/engine/model ClasspathDescriptor.java Log: Temproty updates related to classpath expansion. Revision Changes Path 1.4 +45 -1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/model/ClasspathDescriptor.java Index: ClasspathDescriptor.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/model/ClasspathDescriptor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ClasspathDescriptor.java 15 Dec 2002 14:08:56 -0000 1.3 +++ ClasspathDescriptor.java 16 Feb 2003 10:59:33 -0000 1.4 @@ -60,6 +60,7 @@ import java.util.ArrayList; import java.util.List; import java.net.URL; +import java.net.MalformedURLException; /** * <p>A classpath descriptor that describes a scoped set of jar files. @@ -181,4 +182,47 @@ return (URL[]) list.toArray( new URL[0] ); } + /** + * Expand a classpath to an array of URLS. + * @param home the base directory from which relative classpath entries + * will be resolved. + */ + public static URL[] expand( URL home, ClasspathDescriptor classpath ) throws MalformedURLException + { + if( home == null ) + { + throw new NullPointerException( "home" ); + } + + if( classpath == null ) + { + throw new NullPointerException( "classpath" ); + } + + List list = new ArrayList(); + FilesetDescriptor[] dirs = classpath.getFilesetDescriptors(); + for( int i = 0; i < dirs.length; i++ ) + { + FilesetDescriptor descriptor = dirs[ i ]; + URL anchor = new URL( home, descriptor.getBaseDirectory() ); + IncludeDescriptor[] includes = descriptor.getIncludeDescriptors(); + for( int j = 0; j < includes.length; j++ ) + { + String inc = includes[ j ].getFile(); + try + { + URL url = new URL( anchor, anchor.getPath() + "/" + inc ); + list.add( url ); + } + catch( Throwable e ) + { + final String error = + "Error processing a classpath include: " + + inc; + throw new ClasspathRuntimeException( error, e ); + } + } + } + return (URL[]) list.toArray( new URL[0] ); + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]