mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-26 05:58:27 +00:00
Let mvnd -v show os name and arch
This commit is contained in:
@@ -123,7 +123,12 @@ public class DefaultClient implements Client {
|
|||||||
// Print version if needed
|
// Print version if needed
|
||||||
if (version || showVersion || debug) {
|
if (version || showVersion || debug) {
|
||||||
final String nativeSuffix = Environment.isNative() ? " (native)" : "";
|
final String nativeSuffix = Environment.isNative() ? " (native)" : "";
|
||||||
final String v = Ansi.ansi().bold().a("Maven Daemon " + buildProperties.getVersion() + nativeSuffix)
|
final String v = Ansi.ansi().bold().a(
|
||||||
|
"Maven Daemon "
|
||||||
|
+ buildProperties.getVersion()
|
||||||
|
+ "-" + buildProperties.getOsName()
|
||||||
|
+ "-" + buildProperties.getOsArch()
|
||||||
|
+ nativeSuffix)
|
||||||
.reset().toString();
|
.reset().toString();
|
||||||
output.accept(v);
|
output.accept(v);
|
||||||
/*
|
/*
|
||||||
|
@@ -23,6 +23,7 @@ import java.io.InputStream;
|
|||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -127,7 +128,7 @@ public class ScriptUtils {
|
|||||||
private static final boolean windows;
|
private static final boolean windows;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
windows = System.getProperty("os.name").toLowerCase().contains("windows");
|
windows = System.getProperty("os.name").toLowerCase(Locale.ROOT).startsWith("windows");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWindows() {
|
public static boolean isWindows() {
|
||||||
|
@@ -34,16 +34,31 @@ public class BuildProperties {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Could not read build.properties");
|
throw new RuntimeException("Could not read build.properties");
|
||||||
}
|
}
|
||||||
return new BuildProperties(buildProperties.getProperty("version"));
|
return new BuildProperties(
|
||||||
|
buildProperties.getProperty("version"),
|
||||||
|
buildProperties.getProperty("os.detected.name"),
|
||||||
|
buildProperties.getProperty("os.detected.arch"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String version;
|
private final String version;
|
||||||
|
private final String osName;
|
||||||
|
private final String osArch;
|
||||||
|
|
||||||
public BuildProperties(String version) {
|
public BuildProperties(String version, String os, String arch) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
this.osName = os;
|
||||||
|
this.osArch = arch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOsName() {
|
||||||
|
return osName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOsArch() {
|
||||||
|
return osArch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,4 +20,6 @@ timestamp=${timestamp}
|
|||||||
version=${project.version}
|
version=${project.version}
|
||||||
distributionId=${distributionId}
|
distributionId=${distributionId}
|
||||||
distributionShortName=${distributionShortName}
|
distributionShortName=${distributionShortName}
|
||||||
distributionName=${distributionName}
|
distributionName=${distributionName}
|
||||||
|
os.detected.name=${os.detected.name}
|
||||||
|
os.detected.arch=${os.detected.arch}
|
@@ -36,6 +36,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -479,7 +480,8 @@ public class CliPluginRealmCache
|
|||||||
};
|
};
|
||||||
|
|
||||||
public CliPluginRealmCache() {
|
public CliPluginRealmCache() {
|
||||||
this.watcher = System.getProperty("os.name").toLowerCase().contains("mac")
|
final String osName = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||||
|
this.watcher = osName.startsWith("osx") || osName.startsWith("mac os x")
|
||||||
? new TimestampedRecordValidator()
|
? new TimestampedRecordValidator()
|
||||||
: new MultiWatcher();
|
: new MultiWatcher();
|
||||||
}
|
}
|
||||||
|
@@ -87,6 +87,8 @@
|
|||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<project.version>${project.version}</project.version>
|
<project.version>${project.version}</project.version>
|
||||||
<mvnd.home>${mvnd.home}</mvnd.home>
|
<mvnd.home>${mvnd.home}</mvnd.home>
|
||||||
|
<os.detected.name>${os.detected.name}</os.detected.name>
|
||||||
|
<os.detected.arch>${os.detected.arch}</os.detected.arch>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@@ -111,6 +113,8 @@
|
|||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<project.version>${project.version}</project.version>
|
<project.version>${project.version}</project.version>
|
||||||
<mvnd.home>${mvnd.home}</mvnd.home>
|
<mvnd.home>${mvnd.home}</mvnd.home>
|
||||||
|
<os.detected.name>${os.detected.name}</os.detected.name>
|
||||||
|
<os.detected.arch>${os.detected.arch}</os.detected.arch>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@@ -48,7 +48,11 @@ public class VersionNativeIT {
|
|||||||
|
|
||||||
Assertions.assertThat(logMessage.getAllValues())
|
Assertions.assertThat(logMessage.getAllValues())
|
||||||
.is(new MatchInOrderAmongOthers<>(
|
.is(new MatchInOrderAmongOthers<>(
|
||||||
"\\QMaven Daemon " + System.getProperty("project.version") + "\\E",
|
"\\QMaven Daemon "
|
||||||
|
+ System.getProperty("project.version")
|
||||||
|
+ "-" + System.getProperty("os.detected.name")
|
||||||
|
+ "-" + System.getProperty("os.detected.arch")
|
||||||
|
+ "\\E",
|
||||||
"\\QMaven home: " + layout.mavenHome() + "\\E"));
|
"\\QMaven home: " + layout.mavenHome() + "\\E"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.jboss.fuse.mvnd.client.Client;
|
import org.jboss.fuse.mvnd.client.Client;
|
||||||
@@ -98,7 +99,7 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
|
|||||||
} else if (f.getType() == Client.class) {
|
} else if (f.getType() == Client.class) {
|
||||||
if (resource.isNative) {
|
if (resource.isNative) {
|
||||||
final Path mvndNativeExecutablePath = resource.layout.mavenHome().resolve(
|
final Path mvndNativeExecutablePath = resource.layout.mavenHome().resolve(
|
||||||
System.getProperty("os.name").toLowerCase().contains("windows")
|
System.getProperty("os.name").toLowerCase(Locale.ROOT).startsWith("windows")
|
||||||
? "bin/mvnd.exe"
|
? "bin/mvnd.exe"
|
||||||
: "bin/mvnd")
|
: "bin/mvnd")
|
||||||
.toAbsolutePath().normalize();
|
.toAbsolutePath().normalize();
|
||||||
|
10
pom.xml
10
pom.xml
@@ -378,6 +378,8 @@ limitations under the License.</inlineHeader>
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>
|
<source>
|
||||||
|
// Naming conventions coined by GraalVM
|
||||||
|
// https://github.com/graalvm/graalvm-ce-builds/releases/
|
||||||
String osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
|
String osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
|
||||||
if (osName.startsWith('windows')) {
|
if (osName.startsWith('windows')) {
|
||||||
project.properties['os.detected.name'] = 'windows'
|
project.properties['os.detected.name'] = 'windows'
|
||||||
@@ -386,7 +388,13 @@ limitations under the License.</inlineHeader>
|
|||||||
} else if (osName.startsWith('osx') || osName.startsWith('mac os x')) {
|
} else if (osName.startsWith('osx') || osName.startsWith('mac os x')) {
|
||||||
project.properties['os.detected.name'] = 'darwin'
|
project.properties['os.detected.name'] = 'darwin'
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException('Unknown OS ' + osName);
|
project.properties['os.detected.name'] = osName
|
||||||
|
}
|
||||||
|
String osArch = System.getProperty('os.arch').toLowerCase(Locale.ROOT)
|
||||||
|
if (osArch.equals('amd64') || osArch.equals('x86_64')) {
|
||||||
|
project.properties['os.detected.arch'] = 'amd64'
|
||||||
|
} else {
|
||||||
|
project.properties['os.detected.arch'] = osArch
|
||||||
}
|
}
|
||||||
</source>
|
</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
Reference in New Issue
Block a user