Skip to content

Commit

Permalink
Silent transferlistener
Browse files Browse the repository at this point in the history
  • Loading branch information
espenhw committed Mar 18, 2009
1 parent 6dd6eff commit 6d68d46
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 74 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
Expand Down
76 changes: 2 additions & 74 deletions src/main/groovy/org/grumblesmurf/malabar/MvnServer.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ import org.apache.maven.errors.DefaultCoreErrorReporter;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.wagon.events.TransferEvent;
import org.codehaus.plexus.logging.AbstractLogEnabled;

import java.util.Arrays;
import java.util.Properties;

import java.io.File;

public enum MvnServer
public class MvnServer
{
INSTANCE;
static MvnServer INSTANCE = new MvnServer();

private Configuration configuration;
private MavenEmbedder mavenEmbedder;
Expand Down Expand Up @@ -216,73 +214,3 @@ public class MvnServerLogger
public void close() {
}
}

class MvnServerTransferListener
extends AbstractLogEnabled
implements MavenTransferListener
{
private boolean showChecksumEvents = false;

protected boolean showEvent(TransferEvent event) {
if (!event.resource) {
return true;
}

String resource = event.resource.name;

if (!resource) {
return true;
}

if (resource.endsWith(".sha1") || resource.endsWith(".md5")) {
return showChecksumEvents;
}

return true;
}

public void transferInitiated(TransferEvent transferEvent) {
if (!showEvent(transferEvent)) {
return;
}

String message =
transferEvent.requestType == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading";

String url = transferEvent.wagon.repository.url;

Utils.println(message + ": " + url + "/" + transferEvent.resource.name);
}

public void transferStarted(TransferEvent transferEvent) {
}

public void transferProgress(TransferEvent transferEvent, byte[] buffer, int length) {
}

public void transferCompleted(TransferEvent transferEvent) {
long contentLength = transferEvent.resource.contentLength;
if (contentLength != WagonConstants.UNKNOWN_LENGTH) {
String type = (transferEvent.requestType() == TransferEvent.REQUEST_PUT ? "uploaded" : "downloaded");
String l = contentLength >= 1024 ? (contentLength / 1024) + "K" : contentLength + "b";
Utils.println(l + " " + type);
}
}

public void transferError(TransferEvent event) {
Utils.println(event.getException().getMessage());
}

public void debug(String message) {
}

public boolean isShowChecksumEvents()
{
return showChecksumEvents;
}

public void setShowChecksumEvents(boolean showChecksumEvents)
{
this.showChecksumEvents = showChecksumEvents;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright (c) 2009 Espen Wiborg <espenhw@grumblesmurf.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
package org.grumblesmurf.malabar;

import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.apache.maven.MavenTransferListener;
import org.apache.maven.wagon.events.TransferEvent;

public class MvnServerTransferListener
extends AbstractLogEnabled
implements MavenTransferListener
{
public void transferInitiated(TransferEvent transferEvent) {
}

public void transferStarted(TransferEvent transferEvent) {
}

public void transferProgress(TransferEvent transferEvent, byte[] buffer, int length) {
}

public void transferCompleted(TransferEvent transferEvent) {
}

public void transferError(TransferEvent event) {
Utils.println(event.getException().getMessage());
}

public void debug(String message) {
}

public boolean isShowChecksumEvents() {
return false;
}

public void setShowChecksumEvents(boolean showChecksumEvents) {
}
}

0 comments on commit 6d68d46

Please sign in to comment.