brett 2004/07/06 05:45:48
Modified: . Tag: MAVEN-1_0-BRANCH build-bootstrap.xml
src/bootstrap/org/apache/maven Tag: MAVEN-1_0-BRANCH
BootstrapTask.java
src/java/org/apache/maven Tag: MAVEN-1_0-BRANCH
MavenConstants.java
src/java/org/apache/maven/util Tag: MAVEN-1_0-BRANCH
HttpUtils.java
src/java/org/apache/maven/verifier Tag: MAVEN-1_0-BRANCH
DependencyVerifier.java
xdocs Tag: MAVEN-1_0-BRANCH changes.xml
Added: src/java/org/apache/maven/util Tag: MAVEN-1_0-BRANCH
BootstrapDownloadMeter.java
ConsoleDownloadMeter.java DownloadMeter.java
SilentDownloadMeter.java
Log:
different download progress monitors (particularly for bootstrap compatibility)
Revision Changes Path
No revision
No revision
1.212.2.16 +6 -2 maven/build-bootstrap.xml
Index: build-bootstrap.xml
===================================================================
RCS file: /home/cvs/maven/build-bootstrap.xml,v
retrieving revision 1.212.2.15
retrieving revision 1.212.2.16
diff -u -r1.212.2.15 -r1.212.2.16
--- build-bootstrap.xml 2 Jul 2004 09:52:48 -0000 1.212.2.15
+++ build-bootstrap.xml 6 Jul 2004 12:45:47 -0000 1.212.2.16
@@ -69,7 +69,7 @@
<!-- B O O T S T R A P -->
<!-- ===================================================================== -->
- <target name="bootstrap" depends="env,check-properties,bootstrap-compile">
+ <target name="bootstrap" depends="bootstrap-compile">
<echo>
|
@@ -260,6 +260,7 @@
failonerror="true">
<arg value="-Dmaven.home.local=${maven.home.local}"/>
<arg value="-Dmaven.repo.local=${maven.repo.local}"/>
+ <arg value="-Dmaven.download.meter=bootstrap"/>
<arg value="${maven.bootstrap.online}"/>
<arg value="maven:plugins-install"/>
<arg value="-Dbootstrapping=true"/>
@@ -285,6 +286,7 @@
failonerror="true">
<arg value="-Dmaven.home.local=${maven.home.local}"/>
<arg value="-Dmaven.repo.local=${maven.repo.local}"/>
+ <arg value="-Dmaven.download.meter=bootstrap"/>
<arg value="${maven.bootstrap.online}"/>
<arg value="maven:plugins-test"/>
<arg value="-e"/>
@@ -300,6 +302,7 @@
<exec executable="${maven.command}" failonerror="true">
<arg value="-Dmaven.home.local=${maven.home.local}"/>
<arg value="-Dmaven.repo.local=${maven.repo.local}"/>
+ <arg value="-Dmaven.download.meter=bootstrap"/>
<arg value="${maven.bootstrap.online}"/>
<arg value="clean"/>
<arg value="jar:jar"/>
@@ -346,7 +349,7 @@
<!-- Compile our bootstrap helper classes and the HttpUtils class. -->
<!-- ===================================================================== -->
- <target name="bootstrap-compile">
+ <target name="bootstrap-compile" depends="env,check-properties">
<delete dir="${maven.bootstrap.dir}"/>
<mkdir dir="${maven.bootstrap.classes}"/>
@@ -365,6 +368,7 @@
optimize="off" classpathref="bootstrap.libs">
<src path="src"/>
<include name="bootstrap/**"/>
+ <include name="java/**/*DownloadMeter*"/>
<include name="java/**/HttpUtils*"/>
<include name="java/**/Base64*"/>
</javac>
No revision
No revision
1.20.2.6 +2 -1 maven/src/bootstrap/org/apache/maven/BootstrapTask.java
Index: BootstrapTask.java
===================================================================
RCS file: /home/cvs/maven/src/bootstrap/org/apache/maven/BootstrapTask.java,v
retrieving revision 1.20.2.5
retrieving revision 1.20.2.6
diff -u -r1.20.2.5 -r1.20.2.6
--- BootstrapTask.java 27 Jun 2004 07:57:48 -0000 1.20.2.5
+++ BootstrapTask.java 6 Jul 2004 12:45:48 -0000 1.20.2.6
@@ -26,6 +26,7 @@
import java.util.List;
import org.apache.maven.util.HttpUtils;
+import org.apache.maven.util.BootstrapDownloadMeter;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -378,7 +379,7 @@
proxyHost,
proxyPort,
proxyUserName,
- proxyPassword, loginHost, loginDomain );
+ proxyPassword, loginHost, loginDomain,
new BootstrapDownloadMeter() );
break;
}
catch ( Exception e )
No revision
No revision
1.30.4.9 +4 -1 maven/src/java/org/apache/maven/MavenConstants.java
Index: MavenConstants.java
===================================================================
RCS file: /home/cvs/maven/src/java/org/apache/maven/MavenConstants.java,v
retrieving revision 1.30.4.8
retrieving revision 1.30.4.9
diff -u -r1.30.4.8 -r1.30.4.9
--- MavenConstants.java 28 Jun 2004 09:39:09 -0000 1.30.4.8
+++ MavenConstants.java 6 Jul 2004 12:45:48 -0000 1.30.4.9
@@ -76,6 +76,9 @@
/** Proxy loginDomain tag. */
public static final String PROXY_LOGINDOMAIN = "maven.proxy.ntlm.domain";
+ /** Download meter type variable. */
+ public static final String DOWNLOAD_METER = "maven.download.meter";
+
/** Snapshot JAR signifier tag. */
public static final String SNAPSHOT_SIGNIFIER = "SNAPSHOT";
No revision
No revision
1.28.4.14 +44 -21 maven/src/java/org/apache/maven/util/HttpUtils.java
Index: HttpUtils.java
===================================================================
RCS file: /home/cvs/maven/src/java/org/apache/maven/util/HttpUtils.java,v
retrieving revision 1.28.4.13
retrieving revision 1.28.4.14
diff -u -r1.28.4.13 -r1.28.4.14
--- HttpUtils.java 1 Jul 2004 14:22:52 -0000 1.28.4.13
+++ HttpUtils.java 6 Jul 2004 12:45:48 -0000 1.28.4.14
@@ -68,6 +68,10 @@
/** @todo make it a property. */
private static final int REDIRECT_LIMIT = 5;
+ private static final DownloadMeter silentDownloadMeter = new
SilentDownloadMeter();
+
+ private static DownloadMeter defaultDownloadMeter = new ConsoleDownloadMeter();
+
/**
* Use a proxy to bypass the firewall with or without authentication
*
@@ -181,7 +185,7 @@
proxyHost,
proxyPort,
proxyUserName,
- proxyPassword, loginHost, loginDomain );
+ proxyPassword, loginHost, loginDomain, defaultDownloadMeter );
// Get the checksum if requested.
if ( useChecksum )
@@ -197,7 +201,7 @@
proxyHost,
proxyPort,
proxyUserName,
- proxyPassword, loginHost, loginDomain );
+ proxyPassword, loginHost, loginDomain, silentDownloadMeter
);
}
catch ( Exception e )
{
@@ -234,7 +238,7 @@
String proxyPassword )
throws IOException
{
- getFile( url, destinationFile, ignoreErrors, useTimestamp, proxyHost,
proxyPort, proxyUserName, proxyPassword, null, null );
+ getFile( url, destinationFile, ignoreErrors, useTimestamp, proxyHost,
proxyPort, proxyUserName, proxyPassword, null, null, defaultDownloadMeter );
}
/**
@@ -256,6 +260,7 @@
* @param loginHost The host the authentication request is originating from.
* Essentially, the computer name for this machine.
* @param loginDomain the domain to authenticate within.
+ * @param downloadMeter the download meter to use
*/
public static void getFile( String url,
File destinationFile,
@@ -266,11 +271,10 @@
String proxyUserName,
String proxyPassword,
String loginHost,
- String loginDomain )
+ String loginDomain,
+ DownloadMeter downloadMeter )
throws IOException
{
- LOG.debug( "Getting URL: " + url );
-
//set the timestamp to the file date.
long timestamp = -1;
if ( useTimestamp && destinationFile.exists() )
@@ -288,7 +292,8 @@
proxyUserName,
proxyPassword,
loginHost,
- loginDomain );
+ loginDomain,
+ downloadMeter );
}
catch ( IOException ex )
{
@@ -316,6 +321,7 @@
* @param loginHost The host the authentication request is originating from.
* Essentially, the computer name for this machine.
* @param loginDomain the domain to authenticate within.
+ * @param downloadMeter the download meter to use
* @exception IOException If an I/O exception occurs.
*/
public static void getFile( String url,
@@ -326,10 +332,11 @@
String proxyUserName,
String proxyPassword,
String loginHost,
- String loginDomain )
+ String loginDomain,
+ DownloadMeter downloadMeter )
throws IOException
{
- boolean silent = url.endsWith(".md5");
+ LOG.debug( "Getting URL: " + url );
String[] s = parseUrl( url );
String username = s[0];
@@ -371,7 +378,7 @@
for (int i = 0; i < REDIRECT_LIMIT; i++ )
{
- String redirect = retrieveArtifact(client, source, destinationFile,
timestamp, silent);
+ String redirect = retrieveArtifact(client, source, destinationFile,
timestamp, downloadMeter);
if (redirect == null) {
break;
}
@@ -422,7 +429,7 @@
long remoteTimestamp = connection.getLastModified();
is = connection.getInputStream();
- process( true, is, destinationFile, 0, timestamp, remoteTimestamp,
silent );
+ process( true, is, destinationFile, 0, timestamp, remoteTimestamp,
downloadMeter );
}
finally {
if (is != null) try { is.close(); } catch (Exception e) {
LOG.error("error closing stream", e); }
@@ -430,7 +437,7 @@
}
}
- private static String retrieveArtifact(HttpClient client, URL source, File
destinationFile, long timestamp, boolean silent) throws FileNotFoundException,
IOException, HttpRecoverableException {
+ private static String retrieveArtifact(HttpClient client, URL source, File
destinationFile, long timestamp, DownloadMeter downloadMeter ) throws
FileNotFoundException, IOException, HttpRecoverableException {
int statusCode = -1;
String redirectUrl = null;
InputStream is = null;
@@ -498,7 +505,7 @@
Header header = get.getResponseHeader("Content-Length");
if (header != null) {
try {
- projected = Integer.valueOf(header.getValue()).intValue()/1024;
+ projected = Integer.valueOf(header.getValue()).intValue();
}
catch (NumberFormatException e) {
LOG.warn( "error parsing content length header '" +
header.getValue() + "' " + e );
@@ -528,7 +535,7 @@
return null;
}
}
- process( use, is, destinationFile, projected, timestamp,
remoteTimestamp, silent );
+ process( use, is, destinationFile, projected, timestamp,
remoteTimestamp, downloadMeter );
}
finally {
if (is != null) try { is.close(); } catch (Exception e) {
LOG.error("error closing stream", e); }
@@ -552,7 +559,7 @@
return redirectUrl;
}
- private static void process( boolean use, InputStream is, File destinationFile,
long projected, long timestamp, long remoteTimestamp, boolean silent )
+ private static void process( boolean use, InputStream is, File destinationFile,
int projected, long timestamp, long remoteTimestamp, DownloadMeter downloadMeter )
throws IOException {
byte[] buffer = new byte[100 * 1024];
int length, total = 0;
@@ -567,9 +574,7 @@
if ( use ) {
os.write( buffer, 0, length );
total += length;
- if ( !silent ) {
- System.out.print( (total/1024) + "/" + (projected == 0 ?
"?" : projected + "K" ) + "\r");
- }
+ downloadMeter.update( total, projected );
}
}
}
@@ -578,9 +583,7 @@
}
if ( use ) {
- if ( !silent ) {
- System.out.println( (total/1024) + "K downloaded");
- }
+ downloadMeter.finish( total );
LOG.debug("Local timestamp: " + timestamp);
LOG.debug("Remote timestamp: " + remoteTimestamp);
@@ -662,4 +665,24 @@
}
private static boolean empty(String s) { return s == null || s.length() == 0; }
+
+ /**
+ * @todo this method of setting the meter is not desirable... but a static
method class is not really
+ * conducive to anything else :)
+ */
+ public static void setMeterType(String type) {
+ if (type.equals("bootstrap")) {
+ defaultDownloadMeter = new BootstrapDownloadMeter();
+ }
+ else if (type.equals("console")) {
+ defaultDownloadMeter = new ConsoleDownloadMeter();
+ }
+ else if (type.equals("silent")) {
+ defaultDownloadMeter = new SilentDownloadMeter();
+ }
+ else {
+ LOG.warn("Unknown download meter type: " + type);
+ }
+ }
}
+
No revision
Index: HttpUtils.java
===================================================================
RCS file: /home/cvs/maven/src/java/org/apache/maven/util/HttpUtils.java,v
retrieving revision 1.28.4.13
retrieving revision 1.28.4.14
diff -u -r1.28.4.13 -r1.28.4.14
--- HttpUtils.java 1 Jul 2004 14:22:52 -0000 1.28.4.13
+++ HttpUtils.java 6 Jul 2004 12:45:48 -0000 1.28.4.14
@@ -68,6 +68,10 @@
/** @todo make it a property. */
private static final int REDIRECT_LIMIT = 5;
+ private static final DownloadMeter silentDownloadMeter = new
SilentDownloadMeter();
+
+ private static DownloadMeter defaultDownloadMeter = new ConsoleDownloadMeter();
+
/**
* Use a proxy to bypass the firewall with or without authentication
*
@@ -181,7 +185,7 @@
proxyHost,
proxyPort,
proxyUserName,
- proxyPassword, loginHost, loginDomain );
+ proxyPassword, loginHost, loginDomain, defaultDownloadMeter );
// Get the checksum if requested.
if ( useChecksum )
@@ -197,7 +201,7 @@
proxyHost,
proxyPort,
proxyUserName,
- proxyPassword, loginHost, loginDomain );
+ proxyPassword, loginHost, loginDomain, silentDownloadMeter
);
}
catch ( Exception e )
{
@@ -234,7 +238,7 @@
String proxyPassword )
throws IOException
{
- getFile( url, destinationFile, ignoreErrors, useTimestamp, proxyHost,
proxyPort, proxyUserName, proxyPassword, null, null );
+ getFile( url, destinationFile, ignoreErrors, useTimestamp, proxyHost,
proxyPort, proxyUserName, proxyPassword, null, null, defaultDownloadMeter );
}
/**
@@ -256,6 +260,7 @@
* @param loginHost The host the authentication request is originating from.
* Essentially, the computer name for this machine.
* @param loginDomain the domain to authenticate within.
+ * @param downloadMeter the download meter to use
*/
public static void getFile( String url,
File destinationFile,
@@ -266,11 +271,10 @@
String proxyUserName,
String proxyPassword,
String loginHost,
- String loginDomain )
+ String loginDomain,
+ DownloadMeter downloadMeter )
throws IOException
{
- LOG.debug( "Getting URL: " + url );
-
//set the timestamp to the file date.
long timestamp = -1;
if ( useTimestamp && destinationFile.exists() )
@@ -288,7 +292,8 @@
proxyUserName,
proxyPassword,
loginHost,
- loginDomain );
+ loginDomain,
+ downloadMeter );
}
catch ( IOException ex )
{
@@ -316,6 +321,7 @@
* @param loginHost The host the authentication request is originating from.
* Essentially, the computer name for this machine.
* @param loginDomain the domain to authenticate within.
+ * @param downloadMeter the download meter to use
* @exception IOException If an I/O exception occurs.
*/
public static void getFile( String url,
@@ -326,10 +332,11 @@
String proxyUserName,
String proxyPassword,
String loginHost,
- String loginDomain )
+ String loginDomain,
+ DownloadMeter downloadMeter )
throws IOException
{
- boolean silent = url.endsWith(".md5");
+ LOG.debug( "Getting URL: " + url );
String[] s = parseUrl( url );
String username = s[0];
@@ -371,7 +378,7 @@
for (int i = 0; i < REDIRECT_LIMIT; i++ )
{
- String redirect = retrieveArtifact(client, source, destinationFile,
timestamp, silent);
+ String redirect = retrieveArtifact(client, source, destinationFile,
timestamp, downloadMeter);
if (redirect == null) {
break;
}
@@ -422,7 +429,7 @@
long remoteTimestamp = connection.getLastModified();
is = connection.getInputStream();
- process( true, is, destinationFile, 0, timestamp, remoteTimestamp,
silent );
+ process( true, is, destinationFile, 0, timestamp, remoteTimestamp,
downloadMeter );
}
finally {
if (is != null) try { is.close(); } catch (Exception e) {
LOG.error("error closing stream", e); }
@@ -430,7 +437,7 @@
}
}
- private static String retrieveArtifact(HttpClient client, URL source, File
destinationFile, long timestamp, boolean silent) throws FileNotFoundException,
IOException, HttpRecoverableException {
+ private static String retrieveArtifact(HttpClient client, URL source, File
destinationFile, long timestamp, DownloadMeter downloadMeter ) throws
FileNotFoundException, IOException, HttpRecoverableException {
int statusCode = -1;
String redirectUrl = null;
InputStream is = null;
@@ -498,7 +505,7 @@
Header header = get.getResponseHeader("Content-Length");
if (header != null) {
try {
- projected = Integer.valueOf(header.getValue()).intValue()/1024;
+ projected = Integer.valueOf(header.getValue()).intValue();
}
catch (NumberFormatException e) {
LOG.warn( "error parsing content length header '" +
header.getValue() + "' " + e );
@@ -528,7 +535,7 @@
return null;
}
}
- process( use, is, destinationFile, projected, timestamp,
remoteTimestamp, silent );
+ process( use, is, destinationFile, projected, timestamp,
remoteTimestamp, downloadMeter );
}
finally {
if (is != null) try { is.close(); } catch (Exception e) {
LOG.error("error closing stream", e); }
@@ -552,7 +559,7 @@
return redirectUrl;
}
- private static void process( boolean use, InputStream is, File destinationFile,
long projected, long timestamp, long remoteTimestamp, boolean silent )
+ private static void process( boolean use, InputStream is, File destinationFile,
int projected, long timestamp, long remoteTimestamp, DownloadMeter downloadMeter )
throws IOException {
byte[] buffer = new byte[100 * 1024];
int length, total = 0;
@@ -567,9 +574,7 @@
if ( use ) {
os.write( buffer, 0, length );
total += length;
- if ( !silent ) {
- System.out.print( (total/1024) + "/" + (projected == 0 ?
"?" : projected + "K" ) + "\r");
- }
+ downloadMeter.update( total, projected );
}
}
}
@@ -578,9 +583,7 @@
}
if ( use ) {
- if ( !silent ) {
- System.out.println( (total/1024) + "K downloaded");
- }
+ downloadMeter.finish( total );
LOG.debug("Local timestamp: " + timestamp);
LOG.debug("Remote timestamp: " + remoteTimestamp);
@@ -662,4 +665,24 @@
}
private static boolean empty(String s) { return s == null || s.length() == 0; }
+
+ /**
+ * @todo this method of setting the meter is not desirable... but a static
method class is not really
+ * conducive to anything else :)
+ */
+ public static void setMeterType(String type) {
+ if (type.equals("bootstrap")) {
+ defaultDownloadMeter = new BootstrapDownloadMeter();
+ }
+ else if (type.equals("console")) {
+ defaultDownloadMeter = new ConsoleDownloadMeter();
+ }
+ else if (type.equals("silent")) {
+ defaultDownloadMeter = new SilentDownloadMeter();
+ }
+ else {
+ LOG.warn("Unknown download meter type: " + type);
+ }
+ }
}
+
No revision
Index: HttpUtils.java
===================================================================
RCS file: /home/cvs/maven/src/java/org/apache/maven/util/HttpUtils.java,v
retrieving revision 1.28.4.13
retrieving revision 1.28.4.14
diff -u -r1.28.4.13 -r1.28.4.14
--- HttpUtils.java 1 Jul 2004 14:22:52 -0000 1.28.4.13
+++ HttpUtils.java 6 Jul 2004 12:45:48 -0000 1.28.4.14
@@ -68,6 +68,10 @@
/** @todo make it a property. */
private static final int REDIRECT_LIMIT = 5;
+ private static final DownloadMeter silentDownloadMeter = new
SilentDownloadMeter();
+
+ private static DownloadMeter defaultDownloadMeter = new ConsoleDownloadMeter();
+
/**
* Use a proxy to bypass the firewall with or without authentication
*
@@ -181,7 +185,7 @@
proxyHost,
proxyPort,
proxyUserName,
- proxyPassword, loginHost, loginDomain );
+ proxyPassword, loginHost, loginDomain, defaultDownloadMeter );
// Get the checksum if requested.
if ( useChecksum )
@@ -197,7 +201,7 @@
proxyHost,
proxyPort,
proxyUserName,
- proxyPassword, loginHost, loginDomain );
+ proxyPassword, loginHost, loginDomain, silentDownloadMeter
);
}
catch ( Exception e )
{
@@ -234,7 +238,7 @@
String proxyPassword )
throws IOException
{
- getFile( url, destinationFile, ignoreErrors, useTimestamp, proxyHost,
proxyPort, proxyUserName, proxyPassword, null, null );
+ getFile( url, destinationFile, ignoreErrors, useTimestamp, proxyHost,
proxyPort, proxyUserName, proxyPassword, null, null, defaultDownloadMeter );
}
/**
@@ -256,6 +260,7 @@
* @param loginHost The host the authentication request is originating from.
* Essentially, the computer name for this machine.
* @param loginDomain the domain to authenticate within.
+ * @param downloadMeter the download meter to use
*/
public static void getFile( String url,
File destinationFile,
@@ -266,11 +271,10 @@
String proxyUserName,
String proxyPassword,
String loginHost,
- String loginDomain )
+ String loginDomain,
+ DownloadMeter downloadMeter )
throws IOException
{
- LOG.debug( "Getting URL: " + url );
-
//set the timestamp to the file date.
long timestamp = -1;
if ( useTimestamp && destinationFile.exists() )
@@ -288,7 +292,8 @@
proxyUserName,
proxyPassword,
loginHost,
- loginDomain );
+ loginDomain,
+ downloadMeter );
}
catch ( IOException ex )
{
@@ -316,6 +321,7 @@
* @param loginHost The host the authentication request is originating from.
* Essentially, the computer name for this machine.
* @param loginDomain the domain to authenticate within.
+ * @param downloadMeter the download meter to use
* @exception IOException If an I/O exception occurs.
*/
public static void getFile( String url,
@@ -326,10 +332,11 @@
String proxyUserName,
String proxyPassword,
String loginHost,
- String loginDomain )
+ String loginDomain,
+ DownloadMeter downloadMeter )
throws IOException
{
- boolean silent = url.endsWith(".md5");
+ LOG.debug( "Getting URL: " + url );
String[] s = parseUrl( url );
String username = s[0];
@@ -371,7 +378,7 @@
for (int i = 0; i < REDIRECT_LIMIT; i++ )
{
- String redirect = retrieveArtifact(client, source, destinationFile,
timestamp, silent);
+ String redirect = retrieveArtifact(client, source, destinationFile,
timestamp, downloadMeter);
if (redirect == null) {
break;
}
@@ -422,7 +429,7 @@
long remoteTimestamp = connection.getLastModified();
is = connection.getInputStream();
- process( true, is, destinationFile, 0, timestamp, remoteTimestamp,
silent );
+ process( true, is, destinationFile, 0, timestamp, remoteTimestamp,
downloadMeter );
}
finally {
if (is != null) try { is.close(); } catch (Exception e) {
LOG.error("error closing stream", e); }
@@ -430,7 +437,7 @@
}
}
- private static String retrieveArtifact(HttpClient client, URL source, File
destinationFile, long timestamp, boolean silent) throws FileNotFoundException,
IOException, HttpRecoverableException {
+ private static String retrieveArtifact(HttpClient client, URL source, File
destinationFile, long timestamp, DownloadMeter downloadMeter ) throws
FileNotFoundException, IOException, HttpRecoverableException {
int statusCode = -1;
String redirectUrl = null;
InputStream is = null;
@@ -498,7 +505,7 @@
Header header = get.getResponseHeader("Content-Length");
if (header != null) {
try {
- projected = Integer.valueOf(header.getValue()).intValue()/1024;
+ projected = Integer.valueOf(header.getValue()).intValue();
}
catch (NumberFormatException e) {
LOG.warn( "error parsing content length header '" +
header.getValue() + "' " + e );
@@ -528,7 +535,7 @@
return null;
}
}
- process( use, is, destinationFile, projected, timestamp,
remoteTimestamp, silent );
+ process( use, is, destinationFile, projected, timestamp,
remoteTimestamp, downloadMeter );
}
finally {
if (is != null) try { is.close(); } catch (Exception e) {
LOG.error("error closing stream", e); }
@@ -552,7 +559,7 @@
return redirectUrl;
}
- private static void process( boolean use, InputStream is, File destinationFile,
long projected, long timestamp, long remoteTimestamp, boolean silent )
+ private static void process( boolean use, InputStream is, File destinationFile,
int projected, long timestamp, long remoteTimestamp, DownloadMeter downloadMeter )
throws IOException {
byte[] buffer = new byte[100 * 1024];
int length, total = 0;
@@ -567,9 +574,7 @@
if ( use ) {
os.write( buffer, 0, length );
total += length;
- if ( !silent ) {
- System.out.print( (total/1024) + "/" + (projected == 0 ?
"?" : projected + "K" ) + "\r");
- }
+ downloadMeter.update( total, projected );
}
}
}
@@ -578,9 +583,7 @@
}
if ( use ) {
- if ( !silent ) {
- System.out.println( (total/1024) + "K downloaded");
- }
+ downloadMeter.finish( total );
LOG.debug("Local timestamp: " + timestamp);
LOG.debug("Remote timestamp: " + remoteTimestamp);
@@ -662,4 +665,24 @@
}
private static boolean empty(String s) { return s == null || s.length() == 0; }
+
+ /**
+ * @todo this method of setting the meter is not desirable... but a static
method class is not really
+ * conducive to anything else :)
+ */
+ public static void setMeterType(String type) {
+ if (type.equals("bootstrap")) {
+ defaultDownloadMeter = new BootstrapDownloadMeter();
+ }
+ else if (type.equals("console")) {
+ defaultDownloadMeter = new ConsoleDownloadMeter();
+ }
+ else if (type.equals("silent")) {
+ defaultDownloadMeter = new SilentDownloadMeter();
+ }
+ else {
+ LOG.warn("Unknown download meter type: " + type);
+ }
+ }
}
+
1.1.2.1 +65 -0
maven/src/java/org/apache/maven/util/Attic/BootstrapDownloadMeter.java
1.1.2.1 +43 -0
maven/src/java/org/apache/maven/util/Attic/ConsoleDownloadMeter.java
1.1.2.1 +42 -0 maven/src/java/org/apache/maven/util/Attic/DownloadMeter.java
1.1.2.1 +42 -0
maven/src/java/org/apache/maven/util/Attic/SilentDownloadMeter.java
No revision
No revision
1.34.4.9 +5 -1 maven/src/java/org/apache/maven/verifier/DependencyVerifier.java
Index: DependencyVerifier.java
===================================================================
RCS file:
/home/cvs/maven/src/java/org/apache/maven/verifier/DependencyVerifier.java,v
retrieving revision 1.34.4.8
retrieving revision 1.34.4.9
diff -u -r1.34.4.8 -r1.34.4.9
--- DependencyVerifier.java 1 Jul 2004 12:55:46 -0000 1.34.4.8
+++ DependencyVerifier.java 6 Jul 2004 12:45:48 -0000 1.34.4.9
@@ -319,6 +319,10 @@
{
String loginHost = (String) getProject().getContext().getVariable(
MavenConstants.PROXY_LOGINHOST );
String loginDomain = (String)
getProject().getContext().getVariable( MavenConstants.PROXY_LOGINDOMAIN );
+ String meterType = (String) getProject().getContext().getVariable(
MavenConstants.DOWNLOAD_METER );
+ if ( meterType != null ) {
+ HttpUtils.setMeterType( meterType );
+ }
HttpUtils.getFile( url,
artifact.getFile(),
ignoreErrors,
No revision
No revision
1.14.4.30 +2 -0 maven/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/maven/xdocs/changes.xml,v
retrieving revision 1.14.4.29
retrieving revision 1.14.4.30
diff -u -r1.14.4.29 -r1.14.4.30
--- changes.xml 5 Jul 2004 21:01:49 -0000 1.14.4.29
+++ changes.xml 6 Jul 2004 12:45:48 -0000 1.14.4.30
@@ -25,6 +25,8 @@
</properties>
<body>
<release version="1.0-final-SNAPSHOT" date="in CVS">
+ <action dev="brett" type="fix" issue="MAVEN-1296" due-to="Eric Lapierre">Fix
property inheritence under some circumstances</action>
+ <action dev="brett" type="add">Add different types of download progress
meters.</action>
<action dev="brett" type="fix"><maven:get/> now initialises the plugin
if it has not already been loaded, removing the need for dependency handles</action>
<action dev="brett" type="fix" issue="MAVEN-1188">Check last modified
timestamp as well as conditional GET in case the server time is behind the local
time</action>
<action dev="brett" type="fix" issue="MAVEN-1343">Bugfixes for new httpclient
based downloading (incorrect timestamps)</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]