Skip to content

Commit 1291c70

Browse files
author
TheSnoozer
committed
#531: when the plugin is executed in eclipse the session.getProjectDependencyGraph() 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'.
1 parent a595aac commit 1291c70

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

maven/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,13 @@ public void execute() throws MojoExecutionException {
438438
}
439439

440440
if (runOnlyOnce) {
441-
List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects();
441+
List<MavenProject> sortedProjects =
442+
Optional.ofNullable(session.getProjectDependencyGraph())
443+
.map(graph -> graph.getSortedProjects())
444+
.orElseGet(() -> {
445+
log.warn("Maven's dependency graph is null. Assuming project is the only one executed.");
446+
return Collections.singletonList(session.getCurrentProject());
447+
});
442448
MavenProject firstProject = sortedProjects.stream()
443449
// skipPoms == true => find first project that is not pom project
444450
.filter(p -> {

0 commit comments

Comments
 (0)