You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2002/12/10 03:22:57 UTC
cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/repository AbstractArtifact.java Artifact.java DefaultArtifactFactory.java DefaultJarArtifact.java GenericArtifact.java
jvanzyl 2002/12/09 18:22:57
Modified: src/java/org/apache/maven/repository AbstractArtifact.java
Artifact.java DefaultArtifactFactory.java
DefaultJarArtifact.java GenericArtifact.java
Log:
o Totally revamp and collapse down to the point where we can simply
use the GenericArtifact with the factory setting the values correctly
based on the values in the POM.
Revision Changes Path
1.13 +22 -8 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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- AbstractArtifact.java 9 Dec 2002 06:51:14 -0000 1.12
+++ AbstractArtifact.java 10 Dec 2002 02:22:57 -0000 1.13
@@ -118,10 +118,20 @@
}
/** @see Artifact#generatePath */
- public abstract String generatePath();
+ public String generatePath()
+ {
+ return ps + getDependency().getGroupId()
+ + ps + getDependency().getType() + "s"
+ + ps + getDependency().getArtifact();
+ }
/** @see Artifact#getUrlPath */
- public abstract String getUrlPath();
+ public String getUrlPath()
+ {
+ return "/" + getDependency().getGroupId()
+ + "/" + getDependency().getType() + "s"
+ + "/" + getDependency().getArtifact();
+ }
/**
* Get the name of the artifact from the underlying dependency.
@@ -136,16 +146,20 @@
/** @see Artifact#exists */
public boolean exists()
{
- if ( getFile().exists() == false
- ||
- getDependency().getArtifact().indexOf( MavenConstants.SNAPSHOT_SIGNIFIER ) > 0)
+ if ( getFile().exists() )
{
- return false;
+ return true;
}
else
{
- return true;
+ return false;
}
+ }
+
+ /** @see Artifact#isSnapshot */
+ public boolean isSnapshot()
+ {
+ return getDependency().getArtifact().indexOf( MavenConstants.SNAPSHOT_SIGNIFIER ) > 0;
}
/** @see Artifact#getFile */
1.12 +8 -1 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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Artifact.java 9 Dec 2002 06:51:14 -0000 1.11
+++ Artifact.java 10 Dec 2002 02:22:57 -0000 1.12
@@ -122,6 +122,13 @@
String getName();
/**
+ * Boolean flag indicating whether this artifact is a snapshot.
+ *
+ * @return Flag indicating whether this artifact is a snapshot.
+ */
+ boolean isSnapshot();
+
+ /**
* Boolean flag indicating whether this artifact exists.
*
* @return Flag indicating the existance of the artifact in the local repository.
1.10 +14 -5 jakarta-turbine-maven/src/java/org/apache/maven/repository/DefaultArtifactFactory.java
Index: DefaultArtifactFactory.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/repository/DefaultArtifactFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DefaultArtifactFactory.java 9 Dec 2002 06:53:00 -0000 1.9
+++ DefaultArtifactFactory.java 10 Dec 2002 02:22:57 -0000 1.10
@@ -63,7 +63,12 @@
* type.
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
+ *
* @version $Id$
+ *
+ * @todo The factor needs to take a properties file describing the acceptable
+ * types of artifacts. We can have a default set and also allow users
+ * to customize the list for their own purposes.
*/
public class DefaultArtifactFactory
{
@@ -76,11 +81,15 @@
*/
public static Artifact createArtifact( Dependency dependency )
{
- if ( dependency.isCompileType()
- || dependency.isTestType()
- || "jar".equals( dependency.getType() ) )
+ //!! I certainly have to revisit this. As sometimes we get
+ // any of the following conditions satisfied.
+ if ( dependency.getType() == null
+ || dependency.getType().trim().length() == 0
+ || dependency.getType().equals( "jar" )
+ || dependency.getType().equals( "test" ) )
{
- return new DefaultJarArtifact( dependency );
+ dependency.setType( "jar" );
+ return new GenericArtifact( dependency );
}
else
{
1.15 +1 -21 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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DefaultJarArtifact.java 9 Dec 2002 06:51:14 -0000 1.14
+++ DefaultJarArtifact.java 10 Dec 2002 02:22:57 -0000 1.15
@@ -73,24 +73,4 @@
{
super( dependency );
}
-
- /**
- * Generate the path to a JAR artifact.
- *
- * @return The path to this JAR artifact.
- */
- public String generatePath()
- {
- return ps + getDependency().getGroupId() + ps + "jars" + ps + getDependency().getArtifact();
- }
-
- /**
- * Get an URL path that is platform agnostic.
- *
- * @return Get URL of the dependency.
- */
- public String getUrlPath()
- {
- return "/" + getDependency().getGroupId() + "/" + "jars" + "/" + getDependency().getArtifact();
- }
}
1.9 +1 -41 jakarta-turbine-maven/src/java/org/apache/maven/repository/GenericArtifact.java
Index: GenericArtifact.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/repository/GenericArtifact.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- GenericArtifact.java 9 Dec 2002 06:00:17 -0000 1.8
+++ GenericArtifact.java 10 Dec 2002 02:22:57 -0000 1.9
@@ -69,9 +69,6 @@
public class GenericArtifact
extends AbstractArtifact
{
- /** Type */
- private String typeDir;
-
/**
* Constructor for the GenericArtifact object
*
@@ -80,42 +77,5 @@
public GenericArtifact( Dependency dependency )
{
super( dependency );
-
- if ( dependency.isCompileType() || dependency.isTestType()
- || "jar".equals( dependency.getType() ) )
- {
- typeDir = "jars";
- }
- else
- {
- typeDir = dependency.getType();
- if ( "distribution".equals( typeDir ) )
- {
- // make plural to conform to existing naming
- // conventions.
- typeDir = "distributions";
- }
- }
- }
-
- /**
- * Generate the path to the artifact.
- *
- * @return The generated path to the artifact.
- */
- public String generatePath()
- {
- return ps + getDependency().getGroupId() + ps + typeDir + ps + getDependency().getArtifact();
- }
-
- /**
- * Get an URL path that is platform agnostic. The returned URL is derived
- * from the underlying dependency in the form "id/type/artifact".
- *
- * @return Get the URL of the dependency.
- */
- public String getUrlPath()
- {
- return "/" + getDependency().getProjectId() + "/" + typeDir + "/" + getDependency().getArtifact();
}
}