jvanzyl 2002/07/22 06:12:16
Modified: src/java/org/apache/maven ProjectVerifier.java
src/java/org/apache/maven/app PluginManager.java
src/java/org/apache/maven/repository AbstractArtifact.java
Artifact.java DefaultJarArtifact.java
Log:
o Cleaning up the artifact stuff to be more friendly with windows boxes.
Have added the notion of a file system path and an URL path.
Revision Changes Path
1.22 +14 -11
jakarta-turbine-maven/src/java/org/apache/maven/ProjectVerifier.java
Index: ProjectVerifier.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/ProjectVerifier.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ProjectVerifier.java 21 Jul 2002 20:09:24 -0000 1.21
+++ ProjectVerifier.java 22 Jul 2002 13:12:16 -0000 1.22
@@ -289,7 +289,8 @@
log.debug("jar: " + dependency.getJar());
DefaultJarArtifact dja = new DefaultJarArtifact();
- String path = dja.getPath(dependency);
+ dja.setDependency(dependency);
+ String path = dja.getPath();
File jarFile = new File(getMavenLocalRepo(), path);
//!! Due to the jelly'ization of the project.xml I'm
@@ -299,6 +300,8 @@
continue;
}
+ log.debug("Looking for " + jarFile.getCanonicalPath());
+
if (jarFile.exists() == false || jar.endsWith("SNAPSHOT.jar"))
{
// The directory structure for this project may
@@ -313,7 +316,7 @@
// run update-jars or something else has gone wrong. So
// We'll add the jar to our list of failed dependencies
// and get them when we're done checking all the JARs.
- failedDependencies.add(path);
+ failedDependencies.add(dja);
}
}
@@ -348,16 +351,16 @@
for (Iterator i = failedDependencies.iterator(); i.hasNext();)
{
- String dependency = (String) i.next();
- File destinationFile = new File(getMavenLocalRepo(),
- dependency);
+ DefaultJarArtifact dja = (DefaultJarArtifact) i.next();
+ File destinationFile = new File(getMavenLocalRepo(),dja.getPath());
+ String artifactName = dja.getName();
- if (nonDistMap.containsKey(dependency))
+ if (nonDistMap.containsKey(artifactName))
{
if (!destinationFile.exists())
{
String[] entry = Strings.split(
- (String) nonDistMap.get(dependency), "$");
+ (String) nonDistMap.get(artifactName), "$");
String downloadLocation = entry[0];
String additionalNotes = entry[1];
@@ -368,7 +371,7 @@
+ "---------------\n");
warnings.append("The following JAR must be "
+ "downloaded manually:\n");
- warnings.append(dependency + "\n");
+ warnings.append(artifactName + "\n");
warnings.append("\n");
warnings.append("You can find the JAR here:\n");
warnings.append(downloadLocation + "\n");
@@ -379,7 +382,7 @@
continue;
}
- if (!getRemoteFile(dependency, destinationFile))
+ if (!getRemoteFile(dja.getUrlPath(), destinationFile))
{
warnings.append("-------------------------------------"
+ "------------\n");
@@ -387,7 +390,7 @@
warnings.append("-------------------------------------"
+ "-----------\n");
warnings.append("Failed to download dependent file ");
- warnings.append(dependency);
+ warnings.append(artifactName);
warnings.append("\n\n");
}
}
1.19 +2 -9
jakarta-turbine-maven/src/java/org/apache/maven/app/PluginManager.java
Index: PluginManager.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/PluginManager.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- PluginManager.java 21 Jul 2002 03:57:49 -0000 1.18
+++ PluginManager.java 22 Jul 2002 13:12:16 -0000 1.19
@@ -306,15 +306,8 @@
if (classloader != null)
{
DefaultJarArtifact dja = new DefaultJarArtifact();
-
- /*
- File jarFile = new File(getProjectVerifier().getMavenLocalRepo(),
- dfa.getPath(dependency.getId(),
- dependency.getVersion(),
- dependency.getJar()));
- */
-
- File jarFile = new File(getProjectVerifier().getMavenLocalRepo(),
dja.getPath(dependency));
+ dja.setDependency(dependency);
+ File jarFile = new File(getProjectVerifier().getMavenLocalRepo(),
dja.getPath());
log.debug("jarFile: " + jarFile);
1.3 +3 -3
jakarta-turbine-maven/src/java/org/apache/maven/repository/AbstractArtifact.java
Index: AbstractArtifact.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/repository/AbstractArtifact.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractArtifact.java 21 Jul 2002 03:56:49 -0000 1.2
+++ AbstractArtifact.java 22 Jul 2002 13:12:16 -0000 1.3
@@ -65,6 +65,6 @@
*/
public abstract class AbstractArtifact
{
- public abstract String getPath(String id, String version, String artifactName);
- public abstract String getPath(Dependency dependency);
+ public abstract String getPath();
+ public abstract String getUrlPath();
}
1.3 +3 -3
jakarta-turbine-maven/src/java/org/apache/maven/repository/Artifact.java
Index: Artifact.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/repository/Artifact.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Artifact.java 21 Jul 2002 03:56:49 -0000 1.2
+++ Artifact.java 22 Jul 2002 13:12:16 -0000 1.3
@@ -65,6 +65,6 @@
*/
public interface Artifact
{
- String getPath(String id, String version, String artifactName);
- String getPath(Dependency dependency);
+ String getPath();
+ String getUrlPath();
}
1.3 +52 -13
jakarta-turbine-maven/src/java/org/apache/maven/repository/DefaultJarArtifact.java
Index: DefaultJarArtifact.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/repository/DefaultJarArtifact.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultJarArtifact.java 21 Jul 2002 03:56:49 -0000 1.2
+++ DefaultJarArtifact.java 22 Jul 2002 13:12:16 -0000 1.3
@@ -69,33 +69,72 @@
* @version $Id$
*/
public class DefaultJarArtifact
+ extends AbstractArtifact
{
- /** Log. */
+ /**
+ *Log.
+ */
private static final Log log = LogFactory.getLog(DefaultJarArtifact.class);
+ /**
+ * Platform specific file separator used for file system
+ * operations.
+ */
private final static String ps = File.separator;
- public String getPath(String id, String version, String artifactName)
+ /**
+ * Dependency this artifact is based on.
+ */
+ private Dependency dependency;
+
+ /**
+ * Set the dependency.
+ */
+ public void setDependency(Dependency dependency)
+ {
+ this.dependency = dependency;
+ }
+
+ /**
+ * Set the dependency.
+ */
+ public Dependency getDependency()
{
- if (artifactName == null)
- {
- // Synthesize the name of the JAR if we haven't
- // been given one.
- artifactName = id + "-" + version + ".jar";
- }
+ return dependency;
+ }
+
+ /**
+ * Get the path of the artifact using platform specific
+ * naming conventions.
+ */
+ public String getPath()
+ {
+ String projectId = dependency.getProjectId();
+ String artifact = dependency.getArtifact();
- log.debug("jar artifact: " + artifactName);
+ log.debug("artifact: " + artifact);
- return ps + id + ps + "jars" + ps + artifactName;
+ return ps + projectId + ps + "jars" + ps + artifact;
}
- public String getPath(Dependency dependency)
+ /**
+ * Get an URL path that is platform agnostic.
+ */
+ public String getUrlPath()
{
String projectId = dependency.getProjectId();
String artifact = dependency.getArtifact();
log.debug("artifact: " + artifact);
- return ps + projectId + ps + "jars" + ps + artifact;
+ return "/" + projectId + "/" + "jars" + "/" + artifact;
}
+
+ /**
+ * Get the name of the artifact from the underlying dependency.
+ */
+ public String getName()
+ {
+ return dependency.getArtifact();
+ }
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>