Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix terminal width (fixes #870) #891

Merged
merged 1 commit into from
Oct 16, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.apache.maven.cli.event.ExecutionEventLogger;
import org.apache.maven.cli.internal.BootstrapCoreExtensionManager;
import org.apache.maven.cli.internal.extension.model.CoreExtension;
import org.apache.maven.cli.jansi.JansiMessageBuilderFactory;
import org.apache.maven.cli.jansi.MessageUtils;
import org.apache.maven.cli.logging.Slf4jConfiguration;
import org.apache.maven.cli.logging.Slf4jConfigurationFactory;
Expand Down Expand Up @@ -184,7 +183,7 @@ public DaemonMavenCli() throws Exception {
plexusLoggerManager = new Slf4jLoggerManager();

this.classWorld = ((ClassRealm) Thread.currentThread().getContextClassLoader()).getWorld();
this.messageBuilderFactory = new JansiMessageBuilderFactory();
this.messageBuilderFactory = new DaemonMessageBuilderFactory();

container = container();

Expand Down Expand Up @@ -289,7 +288,7 @@ void initialize(CliRequest cliRequest) throws ExitException {
topDirectory = getCanonicalPath(topDirectory);
cliRequest.topDirectory = topDirectory;
// We're very early in the process and we don't have the container set up yet,
// so we rely on the JDK services to eventually lookup a custom RootLocator.
// so we rely on the JDK services to eventually look up a custom RootLocator.
// This is used to compute {@code session.rootDirectory} but all {@code project.rootDirectory}
// properties will be compute through the RootLocator found in the container.
RootLocator rootLocator =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.cli;

import javax.annotation.Priority;
import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.cli.jansi.JansiMessageBuilderFactory;
import org.mvndaemon.mvnd.common.Environment;

@Named
@Singleton
@Priority(10)
@Experimental
public class DaemonMessageBuilderFactory extends JansiMessageBuilderFactory {

@Override
public int getTerminalWidth() {
int terminalWidth;
try {
terminalWidth = Environment.MVND_TERMINAL_WIDTH.asInt();
} catch (Exception e) {
terminalWidth = 80;
}
return terminalWidth;
}
}
Loading