Return-Path: Mailing-List: contact turbine-maven-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list turbine-maven-dev@jakarta.apache.org Received: (qmail 3485 invoked by uid 97); 12 Dec 2002 11:38:22 -0000 Received: (qmail 3480 invoked by uid 98); 12 Dec 2002 11:38:22 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Received: (qmail 3461 invoked from network); 12 Dec 2002 11:38:20 -0000 Received: from daedalus.apache.org (HELO apache.org) (63.251.56.142) by nagoya.betaversion.org with SMTP; 12 Dec 2002 11:38:20 -0000 Received: (qmail 86106 invoked by uid 500); 12 Dec 2002 11:37:12 -0000 Received: (qmail 86099 invoked from network); 12 Dec 2002 11:37:11 -0000 Received: from icarus.apache.org (63.251.56.143) by daedalus.apache.org with SMTP; 12 Dec 2002 11:37:11 -0000 Received: (qmail 98511 invoked by uid 1162); 12 Dec 2002 11:37:11 -0000 Date: 12 Dec 2002 11:37:11 -0000 Message-ID: <20021212113711.98510.qmail@icarus.apache.org> From: jvanzyl@apache.org To: jakarta-turbine-maven-cvs@apache.org Subject: cvs commit: jakarta-turbine-maven/src/java/org/apache/maven MavenUtils.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N jvanzyl 2002/12/12 03:37:11 Modified: src/java/org/apache/maven MavenUtils.java Log: o Adding excludes capabilities. Revision Changes Path 1.77 +37 -13 jakarta-turbine-maven/src/java/org/apache/maven/MavenUtils.java Index: MavenUtils.java =================================================================== RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/MavenUtils.java,v retrieving revision 1.76 retrieving revision 1.77 diff -u -r1.76 -r1.77 --- MavenUtils.java 11 Dec 2002 22:30:07 -0000 1.76 +++ MavenUtils.java 12 Dec 2002 11:37:11 -0000 1.77 @@ -342,32 +342,41 @@ /** * Get a set of files from a specifed directory with a set of includes. * - * @param directory Directory to scan - * @param includes Comma separated list of includes + * @param directory Directory to scan. + * @param includes Comma separated list of includes. * @return files */ - public static String[] getFiles( String directory, String includes ) + public static String[] getFiles( File directory, String includes ) { - return getFiles( new File( directory ), includes ); + return getFiles( directory, includes, null ); } /** * Get a set of files from a specifed directory with a set of includes. * - * @param directory Directory to scan - * @param includes Comma separated list of includes + * @param directory Directory to scan. + * @param includes Comma separated list of includes. + * @param excludes Comma separated list of excludes. * @return files */ - public static String[] getFiles( File directory, String includes ) + public static String[] getFiles( File directory, String includes, String excludes ) { String[] includePatterns = null; if ( includes != null ) { includePatterns = StringUtils.split( includes, "," ); } + + String[] excludePatterns = null; + if ( excludes != null ) + { + excludePatterns = StringUtils.split( excludes, "," ); + } + DirectoryScanner directoryScanner = new DirectoryScanner(); directoryScanner.setBasedir( directory ); directoryScanner.setIncludes( includePatterns ); + directoryScanner.setExcludes( excludePatterns ); directoryScanner.scan(); String[] files = directoryScanner.getIncludedFiles(); @@ -390,7 +399,22 @@ public static List getProjects( File directory, String includes ) throws Exception { - String[] files = getFiles( directory, includes ); + return getProjects( directory, includes, null ); + } + + /** + * This is currently used for the reactor but may be generally useful. + * + * @param directory the directory to scan for maven projects + * @param includes Patterns to include. + * @param excludes Patterns to exclude. + * @return a {link List} of {@link Project}s + * @throws Exception when anything goes wrong. FIXME this is bad + */ + public static List getProjects( File directory, String includes, String excludes ) + throws Exception + { + String[] files = getFiles( directory, includes, excludes ); List projects = new ArrayList(); @@ -824,7 +848,7 @@ /** Resource bundle with user messages. */ private static ResourceBundle messages; - + /** * Load Maven user messages from a resource bundle given the * user's locale. @@ -832,12 +856,12 @@ */ private static void loadMessages() { - try + try { // Look for the message bundle corresponding to the user's locale. messages = ResourceBundle.getBundle( "org/apache/maven/messages/messages" ); - } - catch( MissingResourceException e ) + } + catch( MissingResourceException e ) { // If we can't find the appropriate message bundle for the locale then // we will fall back to English.