Scripted update of if statements
[yangtools.git] / yang / yang-maven-plugin / src / main / java / org / opendaylight / yangtools / yang2sources / plugin / YangToSourcesProcessor.java
index 195c7f39ba2c43da6220827b81e3d975a3c24915..4140e01173499df86fe8b6d74df828a236c33113 100644 (file)
@@ -117,7 +117,7 @@ class YangToSourcesProcessor {
             }
 
             if (allFiles.isEmpty()) {
-               LOG.info("{} No input files found", LOG_PREFIX);
+                LOG.info("{} No input files found", LOG_PREFIX);
                 return null;
             }
 
@@ -139,13 +139,14 @@ class YangToSourcesProcessor {
                 return null;
             }
 
-            final List<InputStream> yangsInProject = new ArrayList<>();
+            final List<NamedFileInputStream> yangsInProject = new ArrayList<>();
             for (final File f : yangFilesInProject) {
                 // FIXME: This is hack - normal path should be reported.
                 yangsInProject.add(new NamedFileInputStream(f, META_INF_YANG_STRING + File.separator + f.getName()));
             }
 
-            List<InputStream> all = new ArrayList<>(yangsInProject);
+            List<InputStream> all = new ArrayList<>();
+            all.addAll(yangsInProject);
             closeables.addAll(yangsInProject);
 
             /**
@@ -170,8 +171,17 @@ class YangToSourcesProcessor {
                 Set<Module> parsedAllYangModules = resolveSchemaContext.getModules();
                 projectYangModules = new HashSet<>();
                 for (Module module : parsedAllYangModules) {
-                    if(module.getModuleSourcePath()!=null) {
-                        projectYangModules.add(module);
+                    final String path = module.getModuleSourcePath();
+                    if (path != null) {
+                        LOG.debug("Looking for source {}", path);
+                        for (NamedFileInputStream is : yangsInProject) {
+                            LOG.debug("In project destination {}", is.getFileDestination());
+                            if (path.equals(is.getFileDestination())) {
+                                LOG.debug("Module {} belongs to current project", module);
+                                projectYangModules.add(module);
+                                break;
+                            }
+                        }
                     }
                 }
             } finally {
@@ -225,7 +235,7 @@ class YangToSourcesProcessor {
 
             File actualGeneratedYangDir = new File(project.getBuild().getDirectory(),
                     CodeGeneratorArg.YANG_GENERATED_DIR.replace("target" + File.separator, ""));
-            if(!actualGeneratedYangDir.equals(generatedYangDir)) {
+            if (!actualGeneratedYangDir.equals(generatedYangDir)) {
                 addYangsToMetaInf(project, yangFilesRootDir, excludedFiles, actualGeneratedYangDir);
             }
         }