From d8f267df1b8ee2ba7f6d3337631c57fa8c034507 Mon Sep 17 00:00:00 2001 From: Jean-Christophe GAY Date: Sat, 15 Mar 2014 10:25:33 +0100 Subject: [PATCH] Short message notification when project contains only one module. Automatically use short message description because with full message build time information is duplicated. --- .../jcgay/maven/notifier/AbstractCustomEventSpy.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/jcgay/maven/notifier/AbstractCustomEventSpy.java b/src/main/java/com/github/jcgay/maven/notifier/AbstractCustomEventSpy.java index 77caeba..527c546 100644 --- a/src/main/java/com/github/jcgay/maven/notifier/AbstractCustomEventSpy.java +++ b/src/main/java/com/github/jcgay/maven/notifier/AbstractCustomEventSpy.java @@ -58,12 +58,20 @@ protected Status getBuildStatus(MavenExecutionResult result) { } protected String buildNotificationMessage(MavenExecutionResult result) { - if (configuration.isShortDescription()) { + if (shouldBuildShortDescription(result)) { return buildShortDescription(result); } return buildFullDescription(result); } + private boolean shouldBuildShortDescription(MavenExecutionResult result) { + return configuration.isShortDescription() || hasOnlyOneModule(result); + } + + private boolean hasOnlyOneModule(MavenExecutionResult result) { + return result.getTopologicallySortedProjects().size() == 1; + } + protected String buildShortDescription(MavenExecutionResult result) { if (getBuildStatus(result) == Status.SUCCESS) { StringBuilder builder = new StringBuilder("Built in: "); @@ -95,7 +103,7 @@ private String buildFullDescription(MavenExecutionResult result) { protected String buildTitle(MavenExecutionResult result) { StringBuilder builder = new StringBuilder().append(result.getProject().getName()); - if (!configuration.isShortDescription()) { + if (!shouldBuildShortDescription(result)) { builder.append(" [") .append(stopwatch.elapsedTime(TimeUnit.SECONDS)) .append("s]");