You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
packagecom.sf.kafka;
importjava.util.regex.Matcher;
importjava.util.regex.Pattern;
publicclassSFKafkaClientVersion {
privatestaticfinalPatternmajorMinorPatchPattern = Pattern.compile("([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)");
// Pattern for version missing the patch number: eg: 1.14-SNAPSHOTprivatestaticfinalPatternmajorMinorPatter = Pattern.compile("([0-9]+)\\.([0-9]+)(.*)");
// If the version string does not contain a patch version, add one so the// version becomes valid according to the SemVer library (see// https://github.com/zafarkhaja/jsemver).// This method (and it's only call above in the ctor) may be removed when SemVer// accepts null patch versionsstaticStringfixVersionString(Stringversion) {
if (null == version) {
returnnull;
}
MatchermajorMinorPatchMatcher = majorMinorPatchPattern.matcher(version);
if (majorMinorPatchMatcher.matches()) {
// this is a valid version, containing a major, a minor, and a patch version// (and optionally// a release candidate version and/or build metadata)returnversion;
}
else {
// the patch version is missing, so add one ("0")Matchermatcher2 = majorMinorPatter.matcher(version);
if (matcher2.matches()) {
intstartMajorVersion = matcher2.start(1);
intstopMinorVersion = matcher2.end(2);
intstartReleaseCandidate = matcher2.start(3);
Stringprefix = newString(version.getBytes(), startMajorVersion,
(stopMinorVersion - startMajorVersion));
StringpatchVersion = ".0";
Stringsuffix = newString(version.getBytes(), startReleaseCandidate,
version.length() - startReleaseCandidate);
return (prefix + patchVersion + suffix);
}
else {
// This is an invalid version, let the JSemVer library fail when it parses// itreturnversion;
}
}
}
publicstaticStringgetVersion() {
returnfixVersionString("${project.version}");
}
publicstaticStringgetGitSha() {
Stringcommit = "${git.commit.id}";
StringdirtyString = "${git.dirty}";
if (commit.contains("git.commit.id")) {
// this case may happen if you are building the sources// out of the git repositorycommit = "";
}
if (dirtyString == null || Boolean.valueOf(dirtyString)) {
returncommit + "(dirty)";
}
else {
returncommit;
}
}
publicstaticStringgetGitBranch() {
return"${git.branch}";
}
publicstaticStringgetBuildUser() {
Stringemail = "${git.build.user.email}";
Stringname = "${git.build.user.name}";
returnString.format("%s <%s>", name, email);
}
publicstaticStringgetBuildHost() {
return"${git.build.host}";
}
publicstaticStringgetBuildTime() {
return"${git.build.time}";
}
}