Bug 2531: Fix build breakage in absense of src/main/yang directory 01/13801/5
authorEd Warnicke <eaw@cisco.com>
Sun, 21 Dec 2014 16:59:35 +0000 (10:59 -0600)
committerEd Warnicke <eaw@cisco.com>
Fri, 2 Jan 2015 18:22:07 +0000 (12:22 -0600)
Change-Id: Ic5600dc950b048bc48c64a0a976709c6a93ab964
Signed-off-by: Ed Warnicke <eaw@cisco.com>
yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/Util.java

index 381274a098c72740672a40ece39870d42439c393..e2d889e78e58c5090c24151096279294621a7b70 100644 (file)
@@ -31,19 +31,9 @@ public class YangToSourcesPluginTestIT {
     // TODO Test yang files in transitive dependencies
 
     @Test
-    public void testYangRootNotExist() throws URISyntaxException {
-        try {
-            setUp("test-parent/YangRootNotExist/", false);
-        } catch (VerificationException e) {
-            assertVerificationException(e,
-                    "[ERROR] yang-to-sources: Unable to parse yang files from ");
-            assertVerificationException(
-                    e,
-                    "Caused by: org.apache.maven.plugin.MojoExecutionException: yang-to-sources: Unable to parse yang files from ");
-            return;
-        }
-
-        fail("Verification exception should have been thrown");
+    public void testYangRootNotExist() throws Exception {
+        Verifier v = setUp("test-parent/YangRootNotExist/", false);
+        v.verifyTextInLog("[WARNING] yang-to-sources: YANG source directory");
     }
 
     @Test
index c577602ad9427f4942ff9c3e0e4af18b8f414147..b9287185b3ba47d9d27adb1d9201f13eadc3d1c0 100644 (file)
@@ -16,6 +16,7 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
@@ -82,7 +83,10 @@ final class Util {
 
     static Collection<File> listFiles(File root, File[] excludedFiles, Log log) throws FileNotFoundException {
         if (!root.exists()) {
-            throw new FileNotFoundException(root.toString());
+            if (log != null) {
+                log.warn(Util.message("YANG source directory %s not found. No code will be generated.", YangToSourcesProcessor.LOG_PREFIX, root.toString()));
+            }
+            return Collections.emptyList();
         }
         Collection<File> result = new ArrayList<>();
         Collection<File> yangFiles = FileUtils.listFiles(root, new String[] { YANG_SUFFIX }, true);