1 | |
package org.apache.maven.artifact.ant; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.wagon.events.TransferEvent; |
23 | |
import org.apache.maven.wagon.events.TransferListener; |
24 | |
import org.apache.tools.ant.Project; |
25 | |
import org.apache.tools.ant.ProjectComponent; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class AntDownloadMonitor |
34 | |
extends ProjectComponent |
35 | |
implements TransferListener |
36 | |
{ |
37 | |
private static final int KILO = 1024; |
38 | |
|
39 | |
public void debug( String s ) |
40 | |
{ |
41 | 0 | log( s, Project.MSG_DEBUG ); |
42 | 0 | } |
43 | |
|
44 | |
public void transferCompleted( TransferEvent event ) |
45 | |
{ |
46 | 0 | long contentLength = event.getResource().getContentLength(); |
47 | 0 | if ( ( contentLength > 0 ) && ( event.getRequestType() == TransferEvent.REQUEST_PUT ) ) |
48 | |
{ |
49 | 0 | log( "Uploaded " + ( ( contentLength + KILO / 2 ) / KILO ) + "K" ); |
50 | |
} |
51 | 0 | } |
52 | |
|
53 | |
public void transferError( TransferEvent event ) |
54 | |
{ |
55 | 0 | log( event.getException().getMessage(), Project.MSG_ERR ); |
56 | 0 | } |
57 | |
|
58 | |
public void transferInitiated( TransferEvent event ) |
59 | |
{ |
60 | 0 | String message = event.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading"; |
61 | 0 | String dest = event.getRequestType() == TransferEvent.REQUEST_PUT ? " to " : " from "; |
62 | |
|
63 | 0 | log( message + ": " + event.getResource().getName() + dest + "repository " |
64 | |
+ event.getWagon().getRepository().getId() + " at " + event.getWagon().getRepository().getUrl() ); |
65 | 0 | } |
66 | |
|
67 | |
public void transferProgress( TransferEvent event, byte[] bytes, int i ) |
68 | |
{ |
69 | 0 | } |
70 | |
|
71 | |
public void transferStarted( TransferEvent event ) |
72 | |
{ |
73 | 0 | long contentLength = event.getResource().getContentLength(); |
74 | 0 | if ( contentLength > 0 ) |
75 | |
{ |
76 | 0 | log( "Transferring " + ( ( contentLength + KILO / 2 ) / KILO ) + "K from " |
77 | |
+ event.getWagon().getRepository().getId() ); |
78 | |
} |
79 | 0 | } |
80 | |
} |