Skip to content

Commit

Permalink
Merge pull request #58 from ppalaga/200815-amd64-on-mac
Browse files Browse the repository at this point in the history
Use amd64 arch label also on Mac
  • Loading branch information
ppalaga authored Aug 15, 2020
2 parents 469c430 + 28d0765 commit 0e7ddf8
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 20 deletions.
1 change: 0 additions & 1 deletion .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ jobs:
fi
echo "Using VERSION=$VERSION"
echo "::set-env name=VERSION::$VERSION"
mv ./mvnd-dist.zip/mvnd-dist-*.zip ./mvnd-dist.zip/mvnd-dist.zip
- name: Create Release
id: create_release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ public ExecutionResult execute(ClientOutput output, List<String> argv) {
// Print version if needed
if (version || showVersion || debug) {
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();
output.accept(v);
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Locale;
import java.util.Map;
import java.util.Scanner;
import org.slf4j.Logger;
Expand Down Expand Up @@ -127,7 +128,7 @@ private static String filter(String line, Map<String, String> props) {
private static final boolean windows;

static {
windows = System.getProperty("os.name").toLowerCase().contains("windows");
windows = System.getProperty("os.name").toLowerCase(Locale.ROOT).startsWith("windows");
}

public static boolean isWindows() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,31 @@ public static BuildProperties load() {
} catch (IOException e) {
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 osName;
private final String osArch;

public BuildProperties(String version) {
public BuildProperties(String version, String os, String arch) {
this.version = version;
this.osName = os;
this.osArch = arch;
}

public String getVersion() {
return version;
}

public String getOsName() {
return osName;
}

public String getOsArch() {
return osArch;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ timestamp=${timestamp}
version=${project.version}
distributionId=${distributionId}
distributionShortName=${distributionShortName}
distributionName=${distributionName}
distributionName=${distributionName}
os.detected.name=${os.detected.name}
os.detected.arch=${os.detected.arch}
4 changes: 0 additions & 4 deletions daemon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
<packaging>jar</packaging>
<name>Maven Daemon</name>

<properties>
<os.arch>${os.arch}</os.arch><!-- provisio plugin does not see system properties -->
</properties>

<dependencies>
<dependency>
<groupId>org.jboss.fuse.mvnd</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
Expand Down Expand Up @@ -479,7 +480,8 @@ public void close() throws Exception {
};

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 MultiWatcher();
}
Expand Down
10 changes: 5 additions & 5 deletions daemon/src/main/provisio/maven-distro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@
-->
<assembly>

<artifactSet to="mvnd-${project.version}-${os.detected.name}-${os.arch}">
<artifactSet to="mvnd-${project.version}-${os.detected.name}-${os.detected.arch}">
<artifact id="org.apache.maven:apache-maven:tar.gz:bin">
<unpack useRoot="false"
excludes="lib/slf4j*,conf/logging/*,lib/maven-slf4j-provider*,bin/mvn*"/>
</artifact>
</artifactSet>

<artifactSet to="mvnd-${project.version}-${os.detected.name}-${os.arch}/lib">
<artifactSet to="mvnd-${project.version}-${os.detected.name}-${os.detected.arch}/lib">
<artifact id="org.apache.maven:maven-embedder"/>
<artifactSet to="ext" ref="runtime.classpath"/>
</artifactSet>

<fileSet to="mvnd-${project.version}-${os.detected.name}-${os.arch}">
<fileSet to="mvnd-${project.version}-${os.detected.name}-${os.detected.arch}">
<directory path="${basedir}/src/main/distro"/>
</fileSet>
<fileSet to="mvnd-${project.version}-${os.detected.name}-${os.arch}/bin">
<fileSet to="mvnd-${project.version}-${os.detected.name}-${os.detected.arch}/bin">
<directory path="${basedir}/../client/target">
<include>mvnd</include>
<include>mvnd.exe</include>
</directory>
</fileSet>

<archive name="mvnd-${project.version}-${os.detected.name}-${os.arch}.zip" executable="**/bin/mvnd"/>
<archive name="mvnd-${project.version}-${os.detected.name}-${os.detected.arch}.zip" executable="**/bin/mvnd"/>

</assembly>
6 changes: 5 additions & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<mvnd.home>${project.basedir}/../daemon/target/maven-distro/mvnd-${project.version}-${os.detected.name}-${os.arch}</mvnd.home>
<mvnd.home>${project.basedir}/../daemon/target/maven-distro/mvnd-${project.version}-${os.detected.name}-${os.detected.arch}</mvnd.home>
</properties>

<dependencies>
Expand Down Expand Up @@ -87,6 +87,8 @@
<systemPropertyVariables>
<project.version>${project.version}</project.version>
<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>
</configuration>
</plugin>
Expand All @@ -111,6 +113,8 @@
<systemPropertyVariables>
<project.version>${project.version}</project.version>
<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>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ void version() throws IOException, InterruptedException {

Assertions.assertThat(logMessage.getAllValues())
.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"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Stream;
import org.jboss.fuse.mvnd.client.Client;
Expand Down Expand Up @@ -98,7 +99,7 @@ public void beforeEach(ExtensionContext context) throws Exception {
} else if (f.getType() == Client.class) {
if (resource.isNative) {
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")
.toAbsolutePath().normalize();
Expand Down
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ limitations under the License.</inlineHeader>
</goals>
<configuration>
<source>
// Naming conventions coined by GraalVM
// https://github.com/graalvm/graalvm-ce-builds/releases/
String osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
if (osName.startsWith('windows')) {
project.properties['os.detected.name'] = 'windows'
Expand All @@ -386,7 +388,13 @@ limitations under the License.</inlineHeader>
} else if (osName.startsWith('osx') || osName.startsWith('mac os x')) {
project.properties['os.detected.name'] = 'darwin'
} 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>
</configuration>
Expand Down

0 comments on commit 0e7ddf8

Please sign in to comment.