OK for the failure, but a users doesn't always want to download sources and reduce his bandwidth.
Emmanuel ----- Original Message ----- From: "nicolas De Loof" <[EMAIL PROTECTED]> To: "Maven Developers List" <[EMAIL PROTECTED]> Sent: Monday, March 29, 2004 11:00 AM Subject: Re: Enhancement with patch avaible : artifact source attachement > A "source" failed download doesn't generate a build failed. Sources are > "implicit" optionnal > > Nico. > > Emmanuel Venisse a �crit : > > >Can you set optional the sources downloading? > > > >Emmanuel > > > >----- Original Message ----- > >From: "nicolas De Loof" <[EMAIL PROTECTED]> > >Cc: "Maven Developers List" <[EMAIL PROTECTED]> > >Sent: Monday, March 29, 2004 9:52 AM > >Subject: Re: Enhancement with patch avaible : artifact source attachement > > > > > > > > > >>Sorry, I forget to attach the patch files > >> > >>nicolas De Loof a �crit : > >> > >> > >> > >>>Hello, > >>> > >>>I've added a tiny enhancement to maven 1.0 RC2 : > >>> > >>>When downloading some artifact from remote repo(s), my patched maven > >>>tries to download the artifact sources. It is usefull on eclipse to > >>>get generated classpath with associated sources -> inheritence with > >>>parameters and javadoc, browse sources, debug ... > >>>(I patched eclispe generate-classpath goal to do this). > >>> > >>>The artifact sources for any artifact named "XXXXX.ext" is searched as > >>>"XXXXX-src.ext" > >>> > >>>You can test it by applying the patch or by downloading the patched > >>>"maven.jar" and eclipse plugin "classpath.jelly" from > >>>http://ndeloof.free.fr/maven. > >>> > >>>I setted a test sources repository on > >>>http://ndeloof.free.fr/maven/srcrepository. Naturally, if this patch > >>>is accepted, such artifact sources should go on ibiblio. > >>> > >>>Building the artifact sources for a mavenized project could be added > >>>as enhancement of the jar plugin or use a simpel maven.xml postGoal. > >>> > >>> > >>> > >>> > > > > > >--------------------------------------------------------------------------- - > >---- > > > > > > > > > >>Index: src/java/org/apache/maven/repository/AbstractArtifact.java > >>=================================================================== > >>retrieving revision 1.22.4.4 > >>diff -u -r1.22.4.4 AbstractArtifact.java > >>--- src/java/org/apache/maven/repository/AbstractArtifact.java 1 Mar 2004 > >> > >> > >22:36:39 -0000 1.22.4.4 > > > > > >>+++ src/java/org/apache/maven/repository/AbstractArtifact.java 29 Mar 2004 > >> > >> > >07:39:20 -0000 > > > > > >>@@ -48,7 +48,10 @@ > >> > >> /** Path to artifact. */ > >> private String path; > >>- > >>+ > >>+ /** flag to indicate sources are present in repository */ > >>+ private boolean hasSources = false; > >>+ > >> /** > >> * Default constructor. > >> * @param dependency the dependency the artifact is based on > >>@@ -58,6 +61,11 @@ > >> this.dependency = dependency; > >> } > >> > >>+ /** @see Artifact#setSourcesFound */ > >>+ public void setSourcesFound() { > >>+ this.hasSources = true; > >>+ } > >>+ > >> /** @see Artifact#setDependency */ > >> public void setDependency( Dependency dependency ) > >> { > >>@@ -102,6 +110,31 @@ > >> + "/" + getDependency().getType() + "s" > >> + "/" + getDependency().getArtifact(); > >> } > >>+ > >>+ /** @see Artifact#generateSourcesPath */ > >>+ public String generateSourcesPath() > >>+ { > >>+ String artifactPath = getPath(); > >>+ int dot = artifactPath.lastIndexOf("."); > >>+ if (dot > 0) > >>+ { > >>+ return artifactPath.substring(0, dot) + "-src" + > >> > >> > >artifactPath.substring(dot); > > > > > >>+ } > >>+ return ""; > >>+ } > >>+ > >>+ /** @see Artifact#getSourcesUrlPath */ > >>+ public String getSourcesUrlPath() > >>+ { > >>+ String artifactPath = getUrlPath(); > >>+ int dot = artifactPath.lastIndexOf("."); > >>+ if (dot > 0) > >>+ { > >>+ return artifactPath.substring(0, dot) + "-src" + > >> > >> > >artifactPath.substring(dot); > > > > > >>+ } > >>+ return ""; > >>+ } > >>+ > >> > >> /** @see Artifact#getChecksumUrl */ > >> public String getChecksumUrl() > >>@@ -125,7 +158,11 @@ > >> /** @see Artifact#exists */ > >> public boolean exists() > >> { > >>- return getFile().exists(); > >>+ boolean exist = getFile().exists(); > >>+ if (exist && getSourceFile().exists()) { > >>+ setSourcesFound(); > >>+ } > >>+ return exist; > >> } > >> > >> /** @see Artifact#isSnapshot */ > >>@@ -140,6 +177,17 @@ > >> return new File( getPath() ); > >> } > >> > >>+ /** @see Artifact#getSourceFile */ > >>+ public File getSourceFile() > >>+ { > >>+ return new File( generateSourcesPath() ); > >>+ } > >>+ > >>+ /** @see Artifact#hasSources */ > >>+ public boolean hasSources() { > >>+ return this.hasSources; > >>+ } > >>+ > >> /** > >> * C H E C K S U M V E R I F I C A T I O N > >> * @throws ChecksumVerificationException when the checksum differs > >>Index: src/java/org/apache/maven/repository/Artifact.java > >>=================================================================== > >>retrieving revision 1.18.10.2 > >>diff -u -r1.18.10.2 Artifact.java > >>--- src/java/org/apache/maven/repository/Artifact.java 1 Mar 2004 > >> > >> > >22:36:39 -0000 1.18.10.2 > > > > > >>+++ src/java/org/apache/maven/repository/Artifact.java 29 Mar 2004 > >> > >> > >07:39:20 -0000 > > > > > >>@@ -68,6 +68,14 @@ > >> * @return The generated path of the artifact based on the dependency > >> > >> > >attributes. > > > > > >> */ > >> String generatePath(); > >>+ > >>+ /** > >>+ * Generate the path for the sources artifact given its dependency > >> > >> > >attributes. > > > > > >>+ * > >>+ * @return The generated path of the artifact sources based on the > >> > >> > >dependency > > > > > >>+ * attributes. > >>+ */ > >>+ String generateSourcesPath(); > >> > >> /** > >> * Return an URL path that is platform agnostic. > >>@@ -77,6 +85,13 @@ > >> String getUrlPath(); > >> > >> /** > >>+ * Return an URL path to the artifact sources that is platform > >> > >> > >agnostic. > > > > > >>+ * > >>+ * @return URL of the artifact sources. > >>+ */ > >>+ String getSourcesUrlPath(); > >>+ > >>+ /** > >> * Return the url to the checksum file for this artifact. > >> * > >> * @return URL of the checksum file for this artifact. > >>@@ -103,6 +118,20 @@ > >> * @return Flag indicating the existance of the artifact in the local > >> > >> > >repository. > > > > > >> */ > >> boolean exists(); > >>+ > >>+ /** > >>+ * Boolean flag indicating whether this artifact has sources. > >>+ * > >>+ * @return Flag indicating the existance of the artifact sources in > >> > >> > >the local > > > > > >>+ * repository. > >>+ */ > >>+ boolean hasSources(); > >>+ > >>+ /** > >>+ * Indicates the sources for this artifact have been found and > >> > >> > >downloaded into > > > > > >>+ * local repository. > >>+ */ > >>+ void setSourcesFound(); > >> > >> /** > >> * Get the location of the artifact in the local file system. > >>@@ -110,6 +139,13 @@ > >> * @return The location of the artifact in the local file system. > >> */ > >> File getFile(); > >>+ > >>+ /** > >>+ * Get the location of the artifact sources in the local file system. > >>+ * > >>+ * @return The location of the artifact sources in the local file > >> > >> > >system. > > > > > >>+ */ > >>+ File getSourceFile(); > >> > >> /** > >> * Verify the artifact. > >>Index: src/java/org/apache/maven/verifier/DependencyVerifier.java > >>=================================================================== > >>retrieving revision 1.34.4.5 > >>diff -u -r1.34.4.5 DependencyVerifier.java > >>--- src/java/org/apache/maven/verifier/DependencyVerifier.java 18 Mar 2004 > >> > >> > >05:56:21 -0000 1.34.4.5 > > > > > >>+++ src/java/org/apache/maven/verifier/DependencyVerifier.java 29 Mar 2004 > >> > >> > >07:39:20 -0000 > > > > > >>@@ -296,20 +296,7 @@ > >> > >> // 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, "//", "/" ); > >>- > >>- if ( !url.startsWith( "file" ) ) > >>- { > >>- if ( url.startsWith( "https" ) ) > >>- { > >>- url = StringUtils.replace( url, "https:/", > >> > >> > >"https://" ); > > > > > >>- } > >>- else > >>- { > >>- url = StringUtils.replace( url, "http:/", > >> > >> > >"http://" ); > > > > > >>- } > >>- } > >>+ String url = getUrlInRepo(artifact.getUrlPath(), remoteRepo); > >> > >> // Attempt to retrieve the artifact and set the checksum if > >> > >> > >retrieval > > > > > >> // of the checksum file was successful. > >>@@ -361,9 +348,57 @@ > >> // FIXME: localize this message > >> log.warn("Error retrieving artifact from [" + url + "]: " > >> > >> > >+ e); > > > > > >> } > >>+ > >>+ // If found, search for the artifact sources > >>+ try { > >>+ > >>+ String sourcesUrl = > >>+ getUrlInRepo(artifact.getSourcesUrlPath(), > >> > >> > >remoteRepo); > > > > > >>+ log.debug( "Getting URL: " + sourcesUrl ); > >>+ HttpUtils.getFile( sourcesUrl, > >>+ artifact.getSourceFile(), > >>+ ignoreErrors, > >>+ useTimestamp, > >>+ > >> > >> > >getProject().getContext().getProxyHost(), > > > > > >>+ > >> > >> > >getProject().getContext().getProxyPort(), > > > > > >>+ > >> > >> > >getProject().getContext().getProxyUserName(), > > > > > >>+ > >> > >> > >getProject().getContext().getProxyPassword(), > > > > > >>+ true ); > >>+ artifact.setSourcesFound(); > >>+ } > >>+ catch (Exception e) > >>+ { > >>+ log.debug("No sources for artifact in this repos", e); > >>+ } > >> } > >> > >> return artifactFound; > >>+ } > >>+ > >>+ /** > >>+ * Convert the urlPath to URL for file in selected repository. > >>+ * > >>+ * @param urlPath path to convert > >>+ * @param remoteRepo selected repository > >>+ * @return url in repository > >>+ */ > >>+ private String getUrlInRepo(String urlPath, String remoteRepo) > >>+ { > >>+ String url = remoteRepo + "/" + urlPath; > >>+ url = StringUtils.replace( url, "//", "/" ); > >>+ > >>+ if ( !url.startsWith( "file" ) ) > >>+ { > >>+ if ( url.startsWith( "https" ) ) > >>+ { > >>+ url = StringUtils.replace( url, "https:/", "https://" ); > >>+ } > >>+ else > >>+ { > >>+ url = StringUtils.replace( url, "http:/", "http://" ); > >>+ } > >>+ } > >>+ return url; > >> } > >> > >> > >> > >> > > > > > > // ---------------------------------------------------------------------- > > > > > > > > > >--------------------------------------------------------------------------- - > >---- > > > > > > > > > >>Index: eclipse/src/plugin-resources/templates/classpath.jelly > >>=================================================================== > >>retrieving revision 1.9 > >>diff -u -r1.9 classpath.jelly > >>--- eclipse/src/plugin-resources/templates/classpath.jelly 4 Mar 2004 > >> > >> > >18:04:37 -0000 1.9 > > > > > >>+++ eclipse/src/plugin-resources/templates/classpath.jelly 29 Mar 2004 > >> > >> > >07:40:22 -0000 > > > > > >>@@ -114,7 +114,14 @@ > >> <!-- make sure it's a classpath dependency --> > >> <j:set var="isClasspath" > >> > >> > >value="${lib.dependency.isAddedToClasspath()}"/> > > > > > >> <j:if test="${isClasspath}"> > >>+ <j:choose> > >>+ <j:when test="${lib.hasSources()}"> > >>+ <classpathentry kind="var" path="MAVEN_REPO${lib.urlPath}" > >> > >> > >sourcepath="MAVEN_REPO${lib.urlSourcePath}"/> > > > > > >>+ </j:when> > >>+ <j:otherwise> > >> <classpathentry kind="var" path="MAVEN_REPO${lib.urlPath}"/> > >>+ </j:otherwise> > >>+ </j:choose> > >> </j:if> > >> </j:otherwise> > >> </j:choose> > >> > >> > >> > >> > > > > > >--------------------------------------------------------------------------- - > >---- > > > > > > > > > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
