Message: A new issue has been created in JIRA.
--------------------------------------------------------------------- View the issue: http://jira.codehaus.org/secure/ViewIssue.jspa?key=MAVEN-751 Here is an overview of the issue: --------------------------------------------------------------------- Key: MAVEN-751 Summary: Getting remote artifact of type "distribution" doesn't fetch tar.gz, bin or zip type files Type: Improvement Status: Unassigned Priority: Minor Time Spent: Unknown Remaining: Unknown Project: maven Components: component-fetch Versions: 1.0-beta-10 Assignee: Reporter: Created: Wed, 27 Aug 2003 2:27 PM Updated: Wed, 27 Aug 2003 2:27 PM Environment: windows Description: When attempting to get dependencies of type "distribution", the current code assumes that you'll be fetching the dependency from the repository using the path [repo]/[artifactid]/distributions/[artifactid].distribution. Since a ".distribution" file is not typically what people need, rather they want .tar.gz, .zip or .bin files that contain the distribution, I'd suggest the following sort of change to org.apache.maven.verifier.DependencyVerifier.getRemoteArtifact(), I This implementation is a hack, but kept the changes localized for my purposes (if I had more time, I'd have moved some of the code into other classes). /** * DOCUMENT ME! * * @param artifact DOCUMENT ME! * @param ext DOCUMENT ME! * * @return DOCUMENT ME! */ private static String getDistUrlPath(Artifact artifact, String ext) { return "/" + artifact.getDependency().getArtifactDirectory() + "/" + artifact.getDependency().getType() + "s" + "/" + artifact.getDependency().getArtifactId() + "-" + artifact.getDependency().getVersion() + "." + ext; } /** * DOCUMENT ME! * * @param artifact DOCUMENT ME! * @param ext DOCUMENT ME! * * @return DOCUMENT ME! */ private File getDistFile(Artifact artifact, String ext) { return new File(getProject().getContext().getMavenRepoLocal() + ps + artifact.getDependency().getArtifactDirectory() + ps + artifact.getDependency().getType() + "s" + ps + artifact.getDependency().getArtifactId() + "-" + artifact.getDependency().getVersion() + "." + ext); } /** * Retrieve a <code>remoteFile</code> from the maven remote repositories * and store it at <code>localFile</code> * * @param artifact the artifact to retrieve from the repositories. * * @return true if the retrieval succeeds, false otherwise. */ private boolean getRemoteArtifact(Artifact artifact) { boolean artifactFound = false; for (Iterator i = getProject().getContext().getMavenRepoRemote().iterator(); i.hasNext();) { String remoteRepo = (String) i.next(); String url = null; if (DISTRIBUTION_TYPE.equals(artifact.getDependency().getType())) { Exception lastFailure = null; for (int j = 0; j < DIST_TYPES.length; j++) { try { url = remoteRepo + "/" + getDistUrlPath(artifact, DIST_TYPES[j]); url = StringUtils.replace(url, "//", "/"); url = StringUtils.replace(url, "http:/", "http://"); HttpUtils.getFile(url, getDistFile(artifact, DIST_TYPES[j]), ignoreErrors, useTimestamp, getProject().getContext() .getProxyHost(), getProject().getContext() .getProxyPort(), getProject().getContext() .getProxyUserName(), getProject().getContext() .getProxyPassword(), true); artifactFound = true; } catch (FileNotFoundException fe) { // ignore //System.out.println("Fetch of [" + url + "] to [" + // getDistFile(artifact, DIST_TYPES[j]) + // "] failed"); } catch (Exception e) { // lastFailure = e; System.out.println("Error retrieving artifact from [" + url + "]: " + lastFailure); } } /* if (!artifactFound && !(lastFailure instanceof FileNotFoundException) ) { System.out.println("Error retrieving artifact from [" + url + "]: " + lastFailure); } */ } else { // The username and password parameters are not being // used here. Those are the "" parameters you see below. 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. // if it's not found at all, artifactFound will be false. } 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 System.out.println("Error retrieving artifact from [" + url + "]: " + e); } } } return artifactFound; } --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]