mirror of
https://github.com/apache/maven-mvnd.git
synced 2026-01-13 07:04:14 +08:00
This commit is contained in:
@@ -24,12 +24,8 @@ public abstract class AbstractLoggingSpy {
|
||||
|
||||
public static AbstractLoggingSpy instance() {
|
||||
if (instance == null) {
|
||||
if ("mvns".equals(System.getProperty("mvnd.logging", "mvn"))) {
|
||||
instance = new MavenLoggingSpy();
|
||||
} else {
|
||||
instance = new AbstractLoggingSpy() {
|
||||
};
|
||||
}
|
||||
instance = new AbstractLoggingSpy() {
|
||||
};
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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.jboss.fuse.mvnd.logging.smart;
|
||||
|
||||
import java.io.IOError;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.jboss.fuse.mvnd.common.Message;
|
||||
import org.jboss.fuse.mvnd.common.Message.BuildStarted;
|
||||
import org.jboss.fuse.mvnd.common.logging.TerminalOutput;
|
||||
|
||||
public class MavenLoggingSpy extends AbstractLoggingSpy {
|
||||
|
||||
private TerminalOutput output;
|
||||
|
||||
public MavenLoggingSpy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartSession(MavenSession session) {
|
||||
try {
|
||||
output = new TerminalOutput(null);
|
||||
output.accept(new BuildStarted(
|
||||
session.getTopLevelProject().getName(),
|
||||
session.getAllProjects().size(),
|
||||
session.getRequest().getDegreeOfConcurrency()));
|
||||
} catch (Exception e) {
|
||||
throw new IOError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishSession() {
|
||||
try {
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
throw new IOError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartProject(String projectId, String display) {
|
||||
super.onStartProject(projectId, display);
|
||||
output.accept(Message.projectStarted(projectId, display));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStopProject(String projectId, String display) {
|
||||
output.accept(Message.projectStopped(projectId, display));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartMojo(String projectId, String display) {
|
||||
super.onStartMojo(projectId, display);
|
||||
output.accept(Message.mojoStarted(projectId, display));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProjectLog(String projectId, String message) {
|
||||
super.onProjectLog(projectId, message);
|
||||
output.accept(projectId == null ? Message.log(message) : Message.log(projectId, message));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user