mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-25 05:45:15 +00:00
Output revision with -v/--version
This commit is contained in:
@@ -108,6 +108,7 @@ public class DefaultClient implements Client {
|
||||
boolean version = false;
|
||||
boolean showVersion = false;
|
||||
boolean debug = false;
|
||||
boolean batchMode = false;
|
||||
for (String arg : argv) {
|
||||
switch (arg) {
|
||||
case "-v":
|
||||
@@ -126,6 +127,11 @@ public class DefaultClient implements Client {
|
||||
debug = true;
|
||||
args.add(arg);
|
||||
break;
|
||||
case "-B":
|
||||
case "--batch-mode":
|
||||
batchMode = true;
|
||||
args.add(arg);
|
||||
break;
|
||||
default:
|
||||
if (arg.startsWith("-D")) {
|
||||
final int eqPos = arg.indexOf('=');
|
||||
@@ -144,14 +150,16 @@ public class DefaultClient implements Client {
|
||||
if (version || showVersion || debug) {
|
||||
// Print mvnd version
|
||||
BuildProperties buildProperties = BuildProperties.getInstance();
|
||||
final String nativeSuffix = Environment.isNative() ? " (native)" : "";
|
||||
final String v = Ansi.ansi().bold().a(
|
||||
"Maven Daemon "
|
||||
+ buildProperties.getVersion()
|
||||
+ "-" + buildProperties.getOsName()
|
||||
+ "-" + buildProperties.getOsArch()
|
||||
+ nativeSuffix)
|
||||
.reset().toString();
|
||||
final String mvndVersionString = "mvnd "
|
||||
+ (Environment.isNative() ? "native client " : "JVM client ")
|
||||
+ buildProperties.getVersion()
|
||||
+ "-" + buildProperties.getOsName()
|
||||
+ "-" + buildProperties.getOsArch()
|
||||
+ " (" + buildProperties.getRevision() + ")";
|
||||
|
||||
final String v = batchMode
|
||||
? mvndVersionString
|
||||
: Ansi.ansi().bold().a(mvndVersionString).reset().toString();
|
||||
output.accept(Message.log(v));
|
||||
// Print terminal information
|
||||
output.describeTerminal();
|
||||
|
@@ -66,6 +66,22 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<locale>en_US</locale>
|
||||
<timestampFormat>{0,date,yyyy-MM-dd'T'HH:mm:ssX}</timestampFormat>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>create</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.takari.maven.plugins</groupId>
|
||||
<artifactId>takari-lifecycle-plugin</artifactId>
|
||||
|
@@ -36,6 +36,7 @@ public class BuildProperties {
|
||||
}
|
||||
return new BuildProperties(
|
||||
buildProperties.getProperty("version"),
|
||||
buildProperties.getProperty("revision"),
|
||||
buildProperties.getProperty("os.detected.name"),
|
||||
buildProperties.getProperty("os.detected.arch"));
|
||||
}
|
||||
@@ -43,9 +44,11 @@ public class BuildProperties {
|
||||
private final String version;
|
||||
private final String osName;
|
||||
private final String osArch;
|
||||
private final String revision;
|
||||
|
||||
public BuildProperties(String version, String os, String arch) {
|
||||
public BuildProperties(String version, String revision, String os, String arch) {
|
||||
this.version = version;
|
||||
this.revision = revision;
|
||||
this.osName = os;
|
||||
this.osArch = arch;
|
||||
}
|
||||
@@ -61,4 +64,8 @@ public class BuildProperties {
|
||||
public String getOsArch() {
|
||||
return osArch;
|
||||
}
|
||||
|
||||
public String getRevision() {
|
||||
return revision;
|
||||
}
|
||||
}
|
||||
|
@@ -15,11 +15,8 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
buildNumber=${buildNumber}
|
||||
revision=${buildNumber}
|
||||
timestamp=${timestamp}
|
||||
version=${project.version}
|
||||
distributionId=${distributionId}
|
||||
distributionShortName=${distributionShortName}
|
||||
distributionName=${distributionName}
|
||||
os.detected.name=${os.detected.name}
|
||||
os.detected.arch=${os.detected.arch}
|
@@ -40,11 +40,15 @@ public class VersionNativeIT {
|
||||
client.execute(output, "-v").assertSuccess();
|
||||
|
||||
output.assertContainsMatchingSubsequence(
|
||||
"\\QMaven Daemon "
|
||||
"\\Qmvnd " + (isNative() ? "native client " : "JVM client ")
|
||||
+ System.getProperty("project.version")
|
||||
+ "-" + System.getProperty("os.detected.name")
|
||||
+ "-" + System.getProperty("os.detected.arch")
|
||||
+ "\\E",
|
||||
"\\QMaven home: " + parameters.mvndHome() + "\\E");
|
||||
}
|
||||
|
||||
protected boolean isNative() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -20,5 +20,8 @@ import org.mvndaemon.mvnd.junit.MvndTestExtension;
|
||||
|
||||
@MvndTest(projectDir = MvndTestExtension.TEMP_EXTERNAL)
|
||||
public class VersionTest extends VersionNativeIT {
|
||||
protected boolean isNative() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
13
pom.xml
13
pom.xml
@@ -48,6 +48,7 @@
|
||||
<takari-local-repository.version>0.11.2</takari-local-repository.version>
|
||||
|
||||
<!-- plugin versions a..z -->
|
||||
<buildnumber-maven-plugin.version>1.4</buildnumber-maven-plugin.version>
|
||||
<compiler.version>3.8.1</compiler.version>
|
||||
<formatter-maven-plugin.version>2.12.1</formatter-maven-plugin.version>
|
||||
<groovy-maven-plugin.version>2.1.1</groovy-maven-plugin.version>
|
||||
@@ -71,6 +72,13 @@
|
||||
<module>integration-tests</module>
|
||||
</modules>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:mvndaemon/mvnd.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:mvndaemon/mvnd.git</developerConnection>
|
||||
<url>https://github.com/mvndaemon/mvnd</url>
|
||||
<tag>head</tag>
|
||||
</scm>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
@@ -348,6 +356,11 @@ limitations under the License.</inlineHeader>
|
||||
<artifactId>mrm-maven-plugin</artifactId>
|
||||
<version>${mrm.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||
<version>${buildnumber-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.graalvm.nativeimage</groupId>
|
||||
<artifactId>native-image-maven-plugin</artifactId>
|
||||
|
Reference in New Issue
Block a user