You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ni...@apache.org on 2009/05/19 08:54:48 UTC

svn commit: r776207 - in /maven/sandbox/trunk/shared/maven-plugin-helper/src: main/java/org/apache/maven/shared/plugin/scanner/ site/apt/ test/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/maven/ test/java/org/apache/maven/share...

Author: nicolas
Date: Tue May 19 06:54:46 2009
New Revision: 776207

URL: http://svn.apache.org/viewvc?rev=776207&view=rev
Log:
builder for DirectoryScanner + test

Added:
    maven/sandbox/trunk/shared/maven-plugin-helper/src/site/apt/directoryScanner.apt
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/maven/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/maven/shared/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/maven/shared/plugin/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/maven/shared/plugin/scanner/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/maven/shared/plugin/scanner/ScannerBuilderTest.java
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/resources/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/resources/scanner/
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/resources/scanner/excluded.xml
    maven/sandbox/trunk/shared/maven-plugin-helper/src/test/resources/scanner/included.xml
Modified:
    maven/sandbox/trunk/shared/maven-plugin-helper/src/main/java/org/apache/maven/shared/plugin/scanner/ScannerBuilder.java

Modified: maven/sandbox/trunk/shared/maven-plugin-helper/src/main/java/org/apache/maven/shared/plugin/scanner/ScannerBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-plugin-helper/src/main/java/org/apache/maven/shared/plugin/scanner/ScannerBuilder.java?rev=776207&r1=776206&r2=776207&view=diff
==============================================================================
--- maven/sandbox/trunk/shared/maven-plugin-helper/src/main/java/org/apache/maven/shared/plugin/scanner/ScannerBuilder.java (original)
+++ maven/sandbox/trunk/shared/maven-plugin-helper/src/main/java/org/apache/maven/shared/plugin/scanner/ScannerBuilder.java Tue May 19 06:54:46 2009
@@ -1,13 +1,5 @@
 package org.apache.maven.shared.plugin.scanner;
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.codehaus.plexus.util.DirectoryScanner;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -27,6 +19,14 @@
  * under the License.
  */
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.codehaus.plexus.util.DirectoryScanner;
+
 /**
  * Use the builder pattern to configure and execute a DirectoryScanner. <code>iterateOn*</code> methods allow to iterate
  * on the scanner result

Added: maven/sandbox/trunk/shared/maven-plugin-helper/src/site/apt/directoryScanner.apt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-plugin-helper/src/site/apt/directoryScanner.apt?rev=776207&view=auto
==============================================================================
--- maven/sandbox/trunk/shared/maven-plugin-helper/src/site/apt/directoryScanner.apt (added)
+++ maven/sandbox/trunk/shared/maven-plugin-helper/src/site/apt/directoryScanner.apt Tue May 19 06:54:46 2009
@@ -0,0 +1,41 @@
+ ------
+ Scanning directory using patterns
+ ------
+ Nicolas De loof
+ ------
+18 May 2009
+ ------
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License.  You may obtain a copy of the License at
+~~
+~~   http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied.  See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+
+Scanning directory using patterns
+
+  Plexus-utils provide a DirectoryScanner to search a folder for files using ant-style includes/excludes patterns.
+  ScannerBuilder uses the builder pattern to make it little easier to setup, and provide iterator methods on result
+  to get <<<java.io.File>>> instead of basedir related path.
+
+
+
+
+
+
+

Added: maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/maven/shared/plugin/scanner/ScannerBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/maven/shared/plugin/scanner/ScannerBuilderTest.java?rev=776207&view=auto
==============================================================================
--- maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/maven/shared/plugin/scanner/ScannerBuilderTest.java (added)
+++ maven/sandbox/trunk/shared/maven-plugin-helper/src/test/java/org/apache/maven/shared/plugin/scanner/ScannerBuilderTest.java Tue May 19 06:54:46 2009
@@ -0,0 +1,49 @@
+package org.apache.maven.shared.plugin.scanner;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+/**
+ * Use the builder pattern to configure and execute a DirectoryScanner. <code>iterateOn*</code> methods allow to iterate
+ * on the scanner result
+ *
+ * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
+ */
+public class ScannerBuilderTest extends TestCase
+{
+    public void testScan()
+    {
+        File basedir = new File( System.getProperty( "basedir", "" ) );
+        File root = new File( basedir.getAbsoluteFile(), "target/test-classes/scanner" );
+
+        Iterator it = new ScannerBuilder( root )
+            .include( "*.xml" )
+            .exclude( "excluded.xml" )
+            .scan()
+            .iterateOnFiles();
+        assertTrue( it.hasNext() );
+        assertEquals( "included.xml", ( (File) it.next() ).getName() );
+        assertFalse( it.hasNext() );
+    }
+}

Added: maven/sandbox/trunk/shared/maven-plugin-helper/src/test/resources/scanner/excluded.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-plugin-helper/src/test/resources/scanner/excluded.xml?rev=776207&view=auto
==============================================================================
    (empty)

Added: maven/sandbox/trunk/shared/maven-plugin-helper/src/test/resources/scanner/included.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-plugin-helper/src/test/resources/scanner/included.xml?rev=776207&view=auto
==============================================================================
    (empty)