Logic detecting whether a file belongs to the current project has been
broken in change I75c8b67af01212a8ac5b832625f9405bb0108455. It works
most of the time with 'mvn clean install', but fails if there is a
generate-sources phase before dependency projects are
packaged/installed. This typically happens when invoked from IDE such as
Eclipse.
Perform correct checks to see if a particular file was injected from
current project.
The correct fix is to use SchemaContextResolver, where we inject local
files, capture their SchemaSourceIdentifiers, then inject any
dependencies. That way we can perform the lookup based on
ModuleIdentifiers and not rely on the particulars what form was used to
get the source.
Change-Id: I2392dc05bfbc94d613ec896d38fac21734a5bc81
Signed-off-by: Robert Varga <rovarga@cisco.com>
- 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()));
}
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);
/**
closeables.addAll(yangsInProject);
/**
Set<Module> parsedAllYangModules = resolveSchemaContext.getModules();
projectYangModules = new HashSet<>();
for (Module module : parsedAllYangModules) {
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;
+ }
+ }