Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apache-maven/src/assembly/component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ under the License.
<include>mvnenc</include>
<include>mvnsh</include>
<include>mvnup</include>
<include>mvnlog</include>
<include>mvnDebug</include>
<include>mvnencDebug</include>
<!-- This is so that CI systems can periodically run the profiler -->
Expand Down
4 changes: 4 additions & 0 deletions apache-maven/src/assembly/maven/bin/mvn
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ handle_args() {
--up)
MAVEN_MAIN_CLASS="org.apache.maven.cling.MavenUpCling"
;;
--log)
MAVEN_MAIN_CLASS="org.apache.maven.cling.MavenLogCling"
;;

*)
;;
esac
Expand Down
3 changes: 3 additions & 0 deletions apache-maven/src/assembly/maven/bin/mvn.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ if "%~1"=="--debug" (
set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenShellCling"
) else if "%~1"=="--up" (
set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenUpCling"
) else if "%~1"=="--log" (
set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenLogCling"
)

exit /b 0

:processArgs
Expand Down
30 changes: 30 additions & 0 deletions apache-maven/src/assembly/maven/bin/mvnlog
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# 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.

# -----------------------------------------------------------------------------
# Apache Maven Log Script
#
# Environment Variable Prerequisites
#
# JAVA_HOME (Optional) Points to a Java installation.
# MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
# -----------------------------------------------------------------------------

"`dirname "$0"`/mvn" --log "$@"
37 changes: 37 additions & 0 deletions apache-maven/src/assembly/maven/bin/mvnlog.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.

@REM -----------------------------------------------------------------------------
@REM Apache Maven Log Script
@REM
@REM Environment Variable Prerequisites
@REM
@REM JAVA_HOME (Optional) Points to a Java installation.
@REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
@REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
@REM -----------------------------------------------------------------------------

@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO%

@setlocal

@call "%~dp0"mvn.cmd --log %*
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,31 @@ static Builder mvnup(@Nonnull List<String> args, @Nonnull MessageBuilderFactory
return builder(Tools.MVNUP_CMD, Tools.MVNUP_NAME, args, messageBuilderFactory);
}

/**
* Creates a new Builder instance for constructing a Maven Log Viewer Tool ParserRequest.
*
* @param args the command-line arguments
* @param messageBuilderFactory the factory for creating message builders
* @return a new Builder instance
*/
@Nonnull
static Builder mvnlog(@Nonnull String[] args, @Nonnull MessageBuilderFactory messageBuilderFactory) {
return mvnlog(Arrays.asList(args), messageBuilderFactory);
}

/**
* Creates a new Builder instance for constructing a Maven Log Viewer Tool ParserRequest.
*
* @param args the command-line arguments
* @param messageBuilderFactory the factory for creating message builders
* @return a new Builder instance
*/
@Nonnull
static Builder mvnlog(@Nonnull List<String> args, @Nonnull MessageBuilderFactory messageBuilderFactory) {
return builder(Tools.MVNLOG_CMD, Tools.MVNLOG_NAME, args, messageBuilderFactory);
}


/**
* Creates a new Builder instance for constructing a ParserRequest.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ private Tools() {}

public static final String MVNUP_CMD = "mvnup";
public static final String MVNUP_NAME = "Maven Upgrade Tool";

public static final String MVNLOG_CMD = "mvnlog";
public static final String MVNLOG_NAME = "Maven Log Viewer Tool";
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.
*/
package org.apache.maven.api.cli.mvnlog;

import java.util.Optional;

import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.cli.Options;

/**
* Defines the options specific to the Maven build log viewer tool.
*
* @since 4.0.0
*/
@Experimental
public interface LogOptions extends Options {
/**
* Should start the local HTTP server for interactive build report viewing.
*
* @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
@Nonnull
Optional<Boolean> web();

/**
* Returns the port on which to start the local HTTP server.
*
* @return an {@link Optional} containing the port value, or empty if not specified
*/
@Nonnull
Optional<Integer> port();

/**
* Returns the specific build report file to view.
*
* @return an {@link Optional} containing the file path, or empty if not specified
*/
@Nonnull
Optional<String> file();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.
*/

/**
* Provides the API for the Maven Log Viewer tool ({@code mvnlog}).
*
* @see org.apache.maven.api.cli.Tools#MVNLOG_CMD
* @see org.apache.maven.api.cli.Tools#MVNLOG_NAME
* @since 4.0.0
*/
package org.apache.maven.api.cli.mvnlog;
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* 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.
*/
package org.apache.maven.cling;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.api.cli.Invoker;
import org.apache.maven.api.cli.Parser;
import org.apache.maven.api.cli.ParserRequest;
import org.apache.maven.cling.invoker.ProtoLookup;
import org.apache.maven.cling.invoker.mvnlog.LogInvoker;
import org.apache.maven.cling.invoker.mvnlog.LogParser;
import org.codehaus.plexus.classworlds.ClassWorld;

/**
* Maven build report / log viewer CLI.
*/
public class MavenLogCling extends ClingSupport {
/**
* Java entry point.
*/
public static void main(String[] args) throws IOException {
int exitCode = new MavenLogCling().run(args, null, null, null, false);
System.exit(exitCode);
}

/**
* ClassWorld Launcher "enhanced" entry point.
*/
public static int main(String[] args, ClassWorld world) throws IOException {
return new MavenLogCling(world).run(args, null, null, null, false);
}

/**
* ClassWorld Launcher "embedded" entry point.
*/
public static int main(
String[] args,
ClassWorld world,
@Nullable InputStream stdIn,
@Nullable OutputStream stdOut,
@Nullable OutputStream stdErr)
throws IOException {
return new MavenLogCling(world).run(args, stdIn, stdOut, stdErr, true);
}

public MavenLogCling() {
super();
}

public MavenLogCling(ClassWorld classWorld) {
super(classWorld);
}

@Override
protected Invoker createInvoker() {
return new LogInvoker(
ProtoLookup.builder().addMapping(ClassWorld.class, classWorld).build(), null);
}

@Override
protected Parser createParser() {
return new LogParser();
}

@Override
protected ParserRequest.Builder createParserRequestBuilder(String[] args) {
return ParserRequest.mvnlog(args, createMessageBuilderFactory());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,14 @@ protected BuildEventListener determineBuildEventListener(C context) {

protected BuildEventListener doDetermineBuildEventListener(C context) {
Consumer<String> writer = determineWriter(context);
return new SimpleBuildEventListener(writer);
BuildEventListener delegate = new SimpleBuildEventListener(writer);
if (context.invokerRequest.command().equals("mvn")) {
return new org.apache.maven.logging.BuildReportEventListener(delegate);
}
return delegate;
}


protected final void createTerminal(C context) {
if (context.terminal == null) {
MessageUtils.systemInstall(builder -> doCreateTerminal(context, builder), terminal -> {
Expand Down
Loading