HADOOP-14985. Remove subversion related code from VersionInfoMojo.java. Contributed by Ajay Kumar.
(cherry picked from commit 9f1bdafedb
)
This commit is contained in:
parent
486311cdc4
commit
0a886461b5
|
@ -72,10 +72,7 @@ public class VersionInfoMojo extends AbstractMojo {
|
||||||
@Parameter(defaultValue="git")
|
@Parameter(defaultValue="git")
|
||||||
private String gitCommand;
|
private String gitCommand;
|
||||||
|
|
||||||
@Parameter(defaultValue="svn")
|
private enum SCM {NONE, GIT}
|
||||||
private String svnCommand;
|
|
||||||
|
|
||||||
private enum SCM {NONE, SVN, GIT}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException {
|
public void execute() throws MojoExecutionException {
|
||||||
|
@ -104,7 +101,7 @@ public class VersionInfoMojo extends AbstractMojo {
|
||||||
private List<String> scmOut;
|
private List<String> scmOut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines which SCM is in use (Subversion, git, or none) and captures
|
* Determines which SCM is in use (git or none) and captures
|
||||||
* output of the SCM command for later parsing.
|
* output of the SCM command for later parsing.
|
||||||
*
|
*
|
||||||
* @return SCM in use for this build
|
* @return SCM in use for this build
|
||||||
|
@ -114,27 +111,24 @@ public class VersionInfoMojo extends AbstractMojo {
|
||||||
Exec exec = new Exec(this);
|
Exec exec = new Exec(this);
|
||||||
SCM scm = SCM.NONE;
|
SCM scm = SCM.NONE;
|
||||||
scmOut = new ArrayList<String>();
|
scmOut = new ArrayList<String>();
|
||||||
int ret = exec.run(Arrays.asList(svnCommand, "info"), scmOut);
|
int ret;
|
||||||
|
ret = exec.run(Arrays.asList(gitCommand, "branch"), scmOut);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
scm = SCM.SVN;
|
ret = exec.run(Arrays.asList(gitCommand, "remote", "-v"), scmOut);
|
||||||
} else {
|
if (ret != 0) {
|
||||||
ret = exec.run(Arrays.asList(gitCommand, "branch"), scmOut);
|
scm = SCM.NONE;
|
||||||
if (ret == 0) {
|
scmOut = null;
|
||||||
ret = exec.run(Arrays.asList(gitCommand, "remote", "-v"), scmOut);
|
} else {
|
||||||
|
ret = exec.run(Arrays.asList(gitCommand, "log", "-n", "1"), scmOut);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
scm = SCM.NONE;
|
scm = SCM.NONE;
|
||||||
scmOut = null;
|
scmOut = null;
|
||||||
} else {
|
} else {
|
||||||
ret = exec.run(Arrays.asList(gitCommand, "log", "-n", "1"), scmOut);
|
scm = SCM.GIT;
|
||||||
if (ret != 0) {
|
|
||||||
scm = SCM.NONE;
|
|
||||||
scmOut = null;
|
|
||||||
} else {
|
|
||||||
scm = SCM.GIT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scmOut != null) {
|
if (scmOut != null) {
|
||||||
getLog().debug(scmOut.toString());
|
getLog().debug(scmOut.toString());
|
||||||
}
|
}
|
||||||
|
@ -142,35 +136,6 @@ public class VersionInfoMojo extends AbstractMojo {
|
||||||
return scm;
|
return scm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return URI and branch of Subversion repository.
|
|
||||||
*
|
|
||||||
* @param str String Subversion info output containing URI and branch
|
|
||||||
* @return String[] containing URI and branch
|
|
||||||
*/
|
|
||||||
private String[] getSvnUriInfo(String str) {
|
|
||||||
String[] res = new String[]{"Unknown", "Unknown"};
|
|
||||||
String path = str;
|
|
||||||
int index = path.indexOf("trunk");
|
|
||||||
if (index > -1) {
|
|
||||||
res[0] = path.substring(0, index - 1);
|
|
||||||
res[1] = "trunk";
|
|
||||||
} else {
|
|
||||||
index = path.indexOf("branches");
|
|
||||||
if (index > -1) {
|
|
||||||
res[0] = path.substring(0, index - 1);
|
|
||||||
int branchIndex = index + "branches".length() + 1;
|
|
||||||
index = path.indexOf('/', branchIndex);
|
|
||||||
if (index > -1) {
|
|
||||||
res[1] = path.substring(branchIndex, index);
|
|
||||||
} else {
|
|
||||||
res[1] = path.substring(branchIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses SCM output and returns URI of SCM.
|
* Parses SCM output and returns URI of SCM.
|
||||||
*
|
*
|
||||||
|
@ -180,15 +145,6 @@ public class VersionInfoMojo extends AbstractMojo {
|
||||||
private String getSCMUri(SCM scm) {
|
private String getSCMUri(SCM scm) {
|
||||||
String uri = "Unknown";
|
String uri = "Unknown";
|
||||||
switch (scm) {
|
switch (scm) {
|
||||||
case SVN:
|
|
||||||
for (String s : scmOut) {
|
|
||||||
if (s.startsWith("URL:")) {
|
|
||||||
uri = s.substring(4).trim();
|
|
||||||
uri = getSvnUriInfo(uri)[0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GIT:
|
case GIT:
|
||||||
for (String s : scmOut) {
|
for (String s : scmOut) {
|
||||||
if (s.startsWith("origin") && s.endsWith("(fetch)")) {
|
if (s.startsWith("origin") && s.endsWith("(fetch)")) {
|
||||||
|
@ -211,14 +167,6 @@ public class VersionInfoMojo extends AbstractMojo {
|
||||||
private String getSCMCommit(SCM scm) {
|
private String getSCMCommit(SCM scm) {
|
||||||
String commit = "Unknown";
|
String commit = "Unknown";
|
||||||
switch (scm) {
|
switch (scm) {
|
||||||
case SVN:
|
|
||||||
for (String s : scmOut) {
|
|
||||||
if (s.startsWith("Revision:")) {
|
|
||||||
commit = s.substring("Revision:".length());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GIT:
|
case GIT:
|
||||||
for (String s : scmOut) {
|
for (String s : scmOut) {
|
||||||
if (s.startsWith("commit")) {
|
if (s.startsWith("commit")) {
|
||||||
|
@ -240,15 +188,6 @@ public class VersionInfoMojo extends AbstractMojo {
|
||||||
private String getSCMBranch(SCM scm) {
|
private String getSCMBranch(SCM scm) {
|
||||||
String branch = "Unknown";
|
String branch = "Unknown";
|
||||||
switch (scm) {
|
switch (scm) {
|
||||||
case SVN:
|
|
||||||
for (String s : scmOut) {
|
|
||||||
if (s.startsWith("URL:")) {
|
|
||||||
branch = s.substring(4).trim();
|
|
||||||
branch = getSvnUriInfo(branch)[1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GIT:
|
case GIT:
|
||||||
for (String s : scmOut) {
|
for (String s : scmOut) {
|
||||||
if (s.startsWith("*")) {
|
if (s.startsWith("*")) {
|
||||||
|
|
Loading…
Reference in New Issue