Index: DependencyVerifier.java =================================================================== RCS file: /home/cvspublic/maven/src/java/org/apache/maven/verifier/DependencyVerifier.java,v retrieving revision 1.32 diff -u -r1.32 DependencyVerifier.java --- DependencyVerifier.java 4 Sep 2003 15:19:25 -0000 1.32 +++ DependencyVerifier.java 30 Sep 2003 01:54:20 -0000 @@ -323,6 +323,7 @@ * Retrieve a remoteFile from the maven remote repositories * and store it at localFile * @param artifact the artifact to retrieve from the repositories. + * @todo Move some of the distribution logic into the Artifact and Dependency implementations. * @return true if the retrieval succeeds, false otherwise. */ private boolean getRemoteArtifact( Artifact artifact ) @@ -333,60 +334,133 @@ { String remoteRepo = (String) i.next(); - // The username and password parameters are not being - // used here. Those are the "" parameters you see below. - String url = remoteRepo + "/" + artifact.getUrlPath(); - url = StringUtils.replace( url, "//", "/" ); - url = StringUtils.replace( url, "http:/", "http://" ); - - // Attempt to retrieve the artifact and set the checksum if retrieval - // of the checksum file was successful. - try + if ( artifact.getDependency().getType().equals("distribution") ) { - HttpUtils.getFile( url, - artifact.getFile(), - ignoreErrors, - useTimestamp, - getProject().getContext().getProxyHost(), - getProject().getContext().getProxyPort(), - getProject().getContext().getProxyUserName(), - getProject().getContext().getProxyPassword(), - true ); + // Move this logic into the Artifact and Dependency implementations. + // This is just an easy way to fix it now. + String [] distTypes = { "tar.gz", "zip", "bin" }; - // Artifact was found, continue checking additional remote repos (if any) - // in case there is a newer version (i.e. snapshots) in another repo - artifactFound = true; - } - catch (FileNotFoundException e) - { - // Multiple repositories may exist, and if the file is not found - // in just one of them, it's no problem, and we don't want to - // even print out an error. - // if it's not found at all, artifactFound will be false, and the - // build _will_ break, and the user will get an error message - log.debug("File not found on one of the repos", e); + for ( int j = 0; j < distTypes.length; j++ ) + { + // Move this logic into the Artifact and Dependency implementations. + // This is just an easy way to fix it now. + String url = remoteRepo + "/" + artifact.getDependency().getArtifactDirectory() + + "/" + artifact.getDependency().getType() + "s" + "/" + + artifact.getDependency().getArtifactId() + "-" + + artifact.getDependency().getVersion() + "." + distTypes[j]; + + url = StringUtils.replace( url, "//", "/" ); + url = StringUtils.replace( url, "http:/", "http://" ); + + // Attempt to retrieve the artifact and set the checksum if retrieval + // of the checksum file was successful. + try + { + HttpUtils.getFile( url, + artifact.getFile(), + ignoreErrors, + useTimestamp, + getProject().getContext().getProxyHost(), + getProject().getContext().getProxyPort(), + getProject().getContext().getProxyUserName(), + getProject().getContext().getProxyPassword(), + true ); + + // Artifact was found, continue checking additional remote repos (if any) + // in case there is a newer version (i.e. snapshots) in another repo + artifactFound = true; + } + catch (FileNotFoundException e) + { + // Multiple repositories may exist, and if the file is not found + // in just one of them, it's no problem, and we don't want to + // even print out an error. + // if it's not found at all, artifactFound will be false, and the + // build _will_ break, and the user will get an error message + log.debug("File not found on one of the repos", e); + } + catch ( Exception e ) + { + // If there are additional remote repos, then ignore exception + // as artifact may be found in another remote repo. If there + // are no more remote repos to check and the artifact wasn't found in + // a previous remote repo, then artifactFound is false indicating + // that the artifact could not be found in any of the remote repos + // + // arguably, we need to give the user better control (another command- + // line switch perhaps) of what to do in this case? Maven already has + // a command-line switch to work in offline mode, but what about when + // one of two or more remote repos is unavailable? There may be multiple + // remote repos for redundancy, in which case you probably want the build + // to continue. There may however be multiple remote repos because some + // artifacts are on one, and some are on another. In this case, you may + // want the build to break. + // + // print a warning, in any case, so user catches on to mistyped + // hostnames, or other snafus + // FIXME: localize this message + log.warn("Error retrieving artifact from [" + url + "]: " + e); + } + } + } - catch ( Exception e ) + else { - // If there are additional remote repos, then ignore exception - // as artifact may be found in another remote repo. If there - // are no more remote repos to check and the artifact wasn't found in - // a previous remote repo, then artifactFound is false indicating - // that the artifact could not be found in any of the remote repos - // - // arguably, we need to give the user better control (another command- - // line switch perhaps) of what to do in this case? Maven already has - // a command-line switch to work in offline mode, but what about when - // one of two or more remote repos is unavailable? There may be multiple - // remote repos for redundancy, in which case you probably want the build - // to continue. There may however be multiple remote repos because some - // artifacts are on one, and some are on another. In this case, you may - // want the build to break. - // - // print a warning, in any case, so user catches on to mistyped - // hostnames, or other snafus - // FIXME: localize this message - log.warn("Error retrieving artifact from [" + url + "]: " + e); + // The username and password parameters are not being + // used here. Those are the "" parameters you see below. + String url = remoteRepo + "/" + artifact.getUrlPath(); + url = StringUtils.replace( url, "//", "/" ); + url = StringUtils.replace( url, "http:/", "http://" ); + + // Attempt to retrieve the artifact and set the checksum if retrieval + // of the checksum file was successful. + try + { + HttpUtils.getFile( url, + artifact.getFile(), + ignoreErrors, + useTimestamp, + getProject().getContext().getProxyHost(), + getProject().getContext().getProxyPort(), + getProject().getContext().getProxyUserName(), + getProject().getContext().getProxyPassword(), + true ); + + // Artifact was found, continue checking additional remote repos (if any) + // in case there is a newer version (i.e. snapshots) in another repo + artifactFound = true; + } + catch (FileNotFoundException e) + { + // Multiple repositories may exist, and if the file is not found + // in just one of them, it's no problem, and we don't want to + // even print out an error. + // if it's not found at all, artifactFound will be false, and the + // build _will_ break, and the user will get an error message + log.debug("File not found on one of the repos", e); + } + catch ( Exception e ) + { + // If there are additional remote repos, then ignore exception + // as artifact may be found in another remote repo. If there + // are no more remote repos to check and the artifact wasn't found in + // a previous remote repo, then artifactFound is false indicating + // that the artifact could not be found in any of the remote repos + // + // arguably, we need to give the user better control (another command- + // line switch perhaps) of what to do in this case? Maven already has + // a command-line switch to work in offline mode, but what about when + // one of two or more remote repos is unavailable? There may be multiple + // remote repos for redundancy, in which case you probably want the build + // to continue. There may however be multiple remote repos because some + // artifacts are on one, and some are on another. In this case, you may + // want the build to break. + // + // print a warning, in any case, so user catches on to mistyped + // hostnames, or other snafus + // FIXME: localize this message + log.warn("Error retrieving artifact from [" + url + "]: " + e); + } } }