X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-maven-plugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang2sources%2Fplugin%2FYangToSourcesProcessor.java;h=4140e01173499df86fe8b6d74df828a236c33113;hb=82af449e4ef07d80490e79484d0402b81009541e;hp=ccbbc3c4d7c843803263525d7496bdb82c627931;hpb=eea9d976abfcdc466fc1c99c81f05cdb482cd7ad;p=yangtools.git diff --git a/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java b/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java index ccbbc3c4d7..4140e01173 100644 --- a/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java +++ b/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java @@ -11,6 +11,7 @@ import java.util.HashSet; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Throwables; import com.google.common.collect.Maps; import java.io.Closeable; import java.io.File; @@ -116,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; } @@ -138,13 +139,14 @@ class YangToSourcesProcessor { return null; } - final List yangsInProject = new ArrayList<>(); + final List 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 all = new ArrayList<>(yangsInProject); + List all = new ArrayList<>(); + all.addAll(yangsInProject); closeables.addAll(yangsInProject); /** @@ -169,8 +171,17 @@ class YangToSourcesProcessor { Set 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 { @@ -185,8 +196,9 @@ class YangToSourcesProcessor { // MojoExecutionException is thrown since execution cannot continue } catch (Exception e) { LOG.error("{} Unable to parse {} files from {}", LOG_PREFIX, Util.YANG_SUFFIX, yangFilesRootDir, e); + Throwable rootCause = Throwables.getRootCause(e); throw new MojoExecutionException(LOG_PREFIX + " Unable to parse " + Util.YANG_SUFFIX + " files from " + - yangFilesRootDir, e); + yangFilesRootDir, rootCause); } } @@ -223,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); } }