Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip modules with no pom.xml during workspace discovery logging a warning #24094

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -22,16 +23,25 @@
import org.apache.maven.model.resolution.ModelResolver;
import org.apache.maven.model.resolution.UnresolvableModelException;
import org.apache.maven.model.resolution.WorkspaceModelResolver;
import org.jboss.logging.Logger;

public class WorkspaceLoader implements WorkspaceModelResolver {

private static final Logger log = Logger.getLogger(WorkspaceLoader.class);

private static final String POM_XML = "pom.xml";

static final Model readModel(Path pom) throws BootstrapMavenException {
try {
final Model model = ModelUtils.readModel(pom);
model.setPomFile(pom.toFile());
return model;
} catch (NoSuchFileException e) {
// some projects may be missing pom.xml relying on Maven extensions (e.g. tycho-maven-plugin) to build them,
// which we don't support in this workspace loader
log.warn("Module(s) under " + pom.getParent() + " will be handled as thirdparty dependencies because " + pom
+ " does not exist");
return null;
} catch (IOException e) {
throw new BootstrapMavenException("Failed to read " + pom, e);
}
Expand Down Expand Up @@ -122,8 +132,14 @@ private LocalProject loadAndCacheProject(Path pomFile) throws BootstrapMavenExce
} catch (Exception e) {
throw new BootstrapMavenException("Failed to resolve the effective model for " + pomFile, e);
}
} else if (cachedRawModel != null) {
project = new LocalProject(cachedRawModel, workspace);
} else {
project = new LocalProject(cachedRawModel == null ? readModel(pomFile) : cachedRawModel, workspace);
Model model = readModel(pomFile);
if (model == null) {
return null;
}
project = new LocalProject(model, workspace);
}
projectCache.put(pomFile.getParent(), project);
return project;
Expand Down Expand Up @@ -152,6 +168,9 @@ private LocalProject loadProject(final Path projectPom, String skipModule) throw
: loadProject(parentPom, parentPom.getParent().relativize(projectPom.getParent()).toString());

final LocalProject project = project(projectPom);
if (project == null) {
return null;
}
if (parentProject != null) {
parentProject.modules.add(project);
}
Expand Down Expand Up @@ -186,7 +205,9 @@ private LocalProject loadProjectModules(LocalProject project, String skipModule)
continue;
}
final LocalProject childProject = project(project.getDir().resolve(module).resolve(POM_XML));
project.modules.add(loadProjectModules(childProject, null));
if (childProject != null) {
project.modules.add(loadProjectModules(childProject, null));
}
}
}
return project;
Expand Down