mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-09 15:09:23 +00:00
Support for --version, fixes #2
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -80,6 +80,12 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.takari.maven.plugins</groupId>
|
||||
|
@@ -15,17 +15,21 @@
|
||||
*/
|
||||
package org.jboss.fuse.mvnd.daemon;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.maven.cli.CLIReportingUtils;
|
||||
import org.jboss.fuse.mvnd.daemon.Message.BuildEvent;
|
||||
import org.jboss.fuse.mvnd.daemon.Message.BuildMessage;
|
||||
import org.jboss.fuse.mvnd.daemon.Message.MessageSerializer;
|
||||
@@ -51,6 +55,24 @@ public class Client {
|
||||
LOGGER.debug("Starting client");
|
||||
List<String> args = new ArrayList<>(Arrays.asList(argv));
|
||||
|
||||
// Print version if needed
|
||||
boolean version = args.remove("-v") || args.remove("--version");
|
||||
boolean showVersion = args.contains("-V") || args.contains("--show-version");
|
||||
boolean debug = args.contains("-X") || args.contains("--debug");
|
||||
if (version || showVersion || debug) {
|
||||
Properties props = new Properties();
|
||||
try (InputStream is = Client.class.getResourceAsStream("build.properties")) {
|
||||
props.load(is);
|
||||
}
|
||||
String v = buffer().strong( "Maven Daemon " + props.getProperty("version") ).toString()
|
||||
+ System.getProperty( "line.separator" )
|
||||
+ CLIReportingUtils.showVersion();
|
||||
System.out.println(v);
|
||||
if (version) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Path javaHome = Layout.javaHome();
|
||||
DaemonRegistry registry = DaemonRegistry.getDefault();
|
||||
|
||||
|
@@ -0,0 +1,23 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
buildNumber=${buildNumber}
|
||||
timestamp=${timestamp}
|
||||
version=${project.version}
|
||||
distributionId=${distributionId}
|
||||
distributionShortName=${distributionShortName}
|
||||
distributionName=${distributionName}
|
Reference in New Issue
Block a user