class ConsoleMavenTransferListener extends AbstractMavenTransferListener {

    private Map<TransferResource, Long> transfers = new LinkedHashMap<>();
    private FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH); // use in a synchronized fashion
    private StringBuilder buffer = new StringBuilder(128); // use in a synchronized fashion

    private boolean printResourceNames;
    private int lastLength;

    public ConsoleMavenTransferListener(
            MessageBuilderFactory messageBuilderFactory, PrintStream out, boolean printResourceNames) {
        super(messageBuilderFactory, out);
        this.printResourceNames = printResourceNames;
    }

    @Override
    public void transferInitiated(TransferEvent event) {
        overridePreviousTransfer(event);

        super.transferInitiated(event);
    }

    @Override
    public void transferCorrupted(TransferEvent event) throws TransferCancelledException {
        overridePreviousTransfer(event);

        super.transferCorrupted(event);
    }

    @Override
    public void transferProgressed(TransferEvent event) throws TransferCancelledException {<FILL_FUNCTION_BODY>}

    private void pad(StringBuilder buffer, int spaces) {
        String block = "                                        ";
        while (spaces > 0) {
            int n = Math.min(spaces, block.length());
            buffer.append(block, 0, n);
            spaces -= n;
        }
    }

    @Override
    public void transferSucceeded(TransferEvent event) {
        transfers.remove(event.getResource());
        overridePreviousTransfer(event);

        super.transferSucceeded(event);
    }

    @Override
    public void transferFailed(TransferEvent event) {
        transfers.remove(event.getResource());
        overridePreviousTransfer(event);

        super.transferFailed(event);
    }

    private void overridePreviousTransfer(TransferEvent event) {
        if (lastLength > 0) {
            pad(buffer, lastLength);
            buffer.append('\r');
            out.print(buffer);
            out.flush();
            lastLength = 0;
            buffer.setLength(0);
        }
    }
}

        TransferResource resource = event.getResource();
        transfers.put(resource, event.getTransferredBytes());

        buffer.append("Progress (").append(transfers.size()).append("): ");

        Iterator<Map.Entry<TransferResource, Long>> entries =
                transfers.entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry<TransferResource, Long> entry = entries.next();
            long total = entry.getKey().getContentLength();
            Long complete = entry.getValue();

            String resourceName = entry.getKey().getResourceName();

            if (printResourceNames) {
                int idx = resourceName.lastIndexOf('/');

                if (idx < 0) {
                    buffer.append(resourceName);
                } else {
                    buffer.append(resourceName, idx + 1, resourceName.length());
                }
                buffer.append(" (");
            }

            format.formatProgress(buffer, complete, total);

            if (printResourceNames) {
                buffer.append(")");
            }

            if (entries.hasNext()) {
                buffer.append(" | ");
            }
        }

        int pad = lastLength - buffer.length();
        lastLength = buffer.length();
        pad(buffer, pad);
        buffer.append('\r');
        out.print(buffer);
        out.flush();
        buffer.setLength(0);
    
<methods>public void transferCorrupted(TransferEvent) throws TransferCancelledException,public void transferInitiated(TransferEvent) ,public void transferSucceeded(TransferEvent) <variables>public static final java.lang.String STYLE,protected final non-sealed org.apache.maven.api.services.MessageBuilderFactory messageBuilderFactory,protected final non-sealed java.io.PrintStream out