Skip to content

Commit b7a5a5e

Browse files
ky0nslawekjaranowski
authored andcommitted
#208 improve fail the build behavior
1 parent becb596 commit b7a5a5e

File tree

2 files changed

+248
-229
lines changed

2 files changed

+248
-229
lines changed

src/main/java/org/codehaus/mojo/build/CreateMojo.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.Map;
3535
import java.util.Map.Entry;
3636
import java.util.Properties;
37+
import java.util.TimeZone;
3738

3839
import org.apache.maven.execution.MavenSession;
3940
import org.apache.maven.plugin.MojoExecutionException;
@@ -610,18 +611,22 @@ public String getRevision() throws MojoExecutionException {
610611
try {
611612
return this.getScmRevision();
612613
} catch (ScmException e) {
614+
String warnMessage = "Cannot get the revision information from the scm repository";
613615
if (!StringUtils.isEmpty(revisionOnScmFailure)) {
614-
getLog().warn("Cannot get the revision information from the scm repository, proceeding with "
615-
+ "revision of " + revisionOnScmFailure + " : \n" + e.getLocalizedMessage());
616+
getLog().warn(warnMessage + ", proceeding with " + "revision of " + revisionOnScmFailure + " : \n"
617+
+ e.getLocalizedMessage());
616618

617619
setDoCheck(false);
618620
setDoUpdate(false);
619621

620622
return revisionOnScmFailure;
621623
}
624+
if (!failTheBuild) {
625+
getLog().warn(warnMessage, e);
626+
return "";
627+
}
622628

623-
throw new MojoExecutionException(
624-
"Cannot get the revision information from the scm repository : \n" + e.getLocalizedMessage(), e);
629+
throw new MojoExecutionException(warnMessage + " : \n" + e.getLocalizedMessage(), e);
625630
}
626631
}
627632

@@ -687,4 +692,8 @@ public void setRevisionOnScmFailure(String revisionOnScmFailure) {
687692
public void setShortRevisionLength(int shortRevision) {
688693
this.shortRevisionLength = shortRevision;
689694
}
695+
696+
public void setFailTheBuild(boolean failTheBuild) {
697+
this.failTheBuild = failTheBuild;
698+
}
690699
}

0 commit comments

Comments
 (0)