Skip to content

Commit

Permalink
#531: when the plugin is executed in eclipse the session.getProjectDe…
Browse files Browse the repository at this point in the history
…pendencyGraph() might be null. Although the plugin is executed with maven's plugin prefix resolution ('pl.project13.maven:git-commit-id-plugin:4.0.1:revision:basepom.default:initialize') this seems to make it impossible to find out if this plugin was executed before. As a result it this patch might defeat the point of 'runOnlyOnce'.
  • Loading branch information
TheSnoozer committed Nov 28, 2020
1 parent 42a1ee7 commit a213edd
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,13 @@ public void execute() throws MojoExecutionException {
}

if (runOnlyOnce) {
List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects();
List<MavenProject> sortedProjects =
Optional.ofNullable(session.getProjectDependencyGraph())
.map(graph -> graph.getSortedProjects())
.orElseGet(() -> {
log.warn("Maven's dependency graph is null. Assuming project is the only one executed.");
return Collections.singletonList(session.getCurrentProject());
});
MavenProject firstProject = sortedProjects.stream()
// skipPoms == true => find first project that is not pom project
.filter(p -> {
Expand Down

0 comments on commit a213edd

Please sign in to comment.