Merge "Use profile in binding-parent to not break without src/main/yang"
authorJan Medved <jmedved@cisco.com>
Mon, 5 Jan 2015 16:44:03 +0000 (16:44 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 5 Jan 2015 16:44:03 +0000 (16:44 +0000)
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
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.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);
index d3de2502a121179c927c2b29ffb4c1a04f0c8a4e..c6c0badda738bebedccbce0340a91ece03b56cbc 100644 (file)
@@ -206,7 +206,7 @@ class YangToSourcesProcessor {
             withMetaInf.mkdirs();
 
             try {
-                Collection<File> files = Util.listFiles(yangFilesRootDir, excludedFiles, null);
+                Collection<File> files = Util.listFiles(yangFilesRootDir, excludedFiles, log);
                 for (File file : files) {
                     org.apache.commons.io.FileUtils.copyFile(file, new File(withMetaInf, file.getName()));
                 }