michal 2003/05/29 13:26:24
Modified: core/src/java/org/apache/maven/artifact/collector
DefaultArtifactCollector.java
core/src/java/org/apache/maven/artifact Artifact.java
DefaultArtifact.java
core/src/test/org/apache/maven/artifact/download
MockArtifactDownloader.java
core/src/test/org/apache/maven/artifact/satisfy
DefaultDependencySatisfierTest.java
core/src/java/org/apache/maven MavenConstants.java
core/src/java/org/apache/maven/artifact/handlers
DefaultArtifactHandlerManager.java JarHandler.java
core/src/test-input/overriding project.xml
project.properties
core/src/java/org/apache/maven/artifact/satisfy
DefaultDependencySatisfier.java
core/src/java/org/apache/maven/project Dependency.java
core/src/java/org/apache/maven/project/builder
DefaultProjectUnmarshaller.java
core/src/test/org/apache/maven/artifact/handlers
DefaultArtifactHandlerManagerTest.java
MockArtifactHandler.java
core/src/java/org/apache/maven/artifact/factory
DefaultArtifactFactory.java
core/src/java/org/apache/maven/artifact/layout
RepositoryLayout.java DefaultRepositoryLayout.java
core/src/test/org/apache/maven/artifact/factory
DefaultArtifactFactoryTest.java
core/src/java/org/apache/maven/artifact/processor
DefaultArtifactProcessor.java
core/src/test/org/apache/maven/artifact/layout
DefaultRepositoryLayoutTest.java
Log:
After long thought I decided to come back to the "old" roles of Artifact and
Dependency.
So Dependency contains "metadata" information about file, and Artifact contains
paths
auxiliary methods for dealing with Paths. I think that only such distinction of roles
is clear (kudos for "old" design! It was perfect!!). Note: Still some tests are
broken.
The changes in the code are mainly related to this decision + but some minor changes
were also introduced. Other note: Dependency and Artifact classes are not 100%
compatible
with old code.
Revision Changes Path
1.3 +22 -6
maven-new/core/src/java/org/apache/maven/artifact/collector/DefaultArtifactCollector.java
Index: DefaultArtifactCollector.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/artifact/collector/DefaultArtifactCollector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultArtifactCollector.java 23 May 2003 10:36:04 -0000 1.2
+++ DefaultArtifactCollector.java 29 May 2003 20:26:19 -0000 1.3
@@ -1,9 +1,11 @@
package org.apache.maven.artifact.collector;
+import org.apache.maven.project.Dependency;
import org.apache.maven.project.Project;
import org.apache.maven.project.builder.ProjectBuilder;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.layout.RepositoryLayout;
import org.apache.plexus.logging.AbstractLogEnabled;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.service.ServiceException;
@@ -37,6 +39,12 @@
private Map artifacts;
/** Dependency builder. */
private ProjectBuilder builder;
+
+ /** Repository layout */
+ private RepositoryLayout repositoryLayout = null;
+
+
+
/** Non existent POMs. */
private Map artifactsWithoutPoms;
@@ -104,14 +112,14 @@
Artifact artifact = (Artifact) i.next();
// Add the dependency itself
- artifacts.put( artifact.getId(), artifact );
+ artifacts.put( artifact.getDependency().getId(), artifact );
// Now find the artifacts for each of the artifacts.
Project p = findPom( artifact );
if ( p == null )
{
- artifactsWithoutPoms.put( artifact.getId(), artifact );
+ artifactsWithoutPoms.put( artifact.getDependency().getId(),
artifact );
continue;
}
@@ -121,9 +129,15 @@
Project findPom( Artifact artifact )
throws Exception
- {
- String pomFileBasename = artifact.getArtifactId() + "-" +
artifact.getVersion() + ".pom";
- File pomFile = new File( new File ( new File( mavenRepoLocal,
artifact.getGroupId() ), "poms" ), pomFileBasename );
+ {
+ Dependency dependency = artifact.getDependency();
+ String path = repositoryLayout.generatePath(
+ dependency.getGroupId(),
+ dependency.getArtifactId(),
+ "pom",
+ dependency.getVersion());
+
+ File pomFile = new File( mavenRepoLocal, path );
Project pom = null;
@@ -144,5 +158,7 @@
throws ServiceException
{
builder = (ProjectBuilder) serviceManager.lookup( ProjectBuilder.ROLE );
+ repositoryLayout =
+ ( RepositoryLayout ) serviceManager.lookup( RepositoryLayout.ROLE );
}
}
1.8 +20 -75 maven-new/core/src/java/org/apache/maven/artifact/Artifact.java
Index: Artifact.java
===================================================================
RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/Artifact.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Artifact.java 24 May 2003 13:00:07 -0000 1.7
+++ Artifact.java 29 May 2003 20:26:19 -0000 1.8
@@ -77,70 +77,16 @@
*/
public Dependency getDependency();
- /**
- * Set the dependency for this JAR artifact.
- *
- * @param dependency Dependency this artifact is based on.
- */
- public void setDependency( Dependency dependency );
-
- /**
- * Get the artifactId
- *
- * @return artifactId for the artifact
- */
- public String getArtifactId();
-
- /**
- * Set artifactId
- *
- * @param artifactId The artifactId for the artifact
- */
- public void setArtifactId( String artifactId );
+
/**
- * Get the group id.
+ * Get the artifact
*
- * @return The group id for the artifact.
+ * @return artifact for the artifact
*/
- public String getGroupId();
+ public String getArtifact();
/**
- * Set the group id.
- *
- * @param groupId Group id for the artifact.
- */
- public void setGroupId( String groupId );
-
- /**
- * Get the version of this artifact.
- *
- * @return Version of this artifact
- */
- public String getVersion();
-
- /**
- * Set the version for this artifact.
- *
- * @param version Version for this artifact
- */
- public void setVersion( String version );
-
- /**
- * Get the type of the artifact.
- *
- * @return dependency type such as "compile" or "test"
- */
- public String getType();
-
- /**
- * Sets the dependency type such as "compile" or "test"
- *
- * @param type The type of artifact.
- */
- public void setType( String type );
-
- /**
* Return a path that is platform agnostic.
*
* @return URL of the artifact.
@@ -148,12 +94,16 @@
public String getPath();
/**
- * Set the path to the artifact.
+ * Return a path that is platform agnostic.
+ *
+ * Path is relataive to repsository root
*
- * @param path Path to the artifact.
+ * @return URL of the artifact.
*/
public void setPath( String path );
+
+
/**
* Get the location of the artifact in the local file system.
*
@@ -185,24 +135,19 @@
/**
- * Sets the flag which indicates
- * if version override mechanism was applied to this artifact
+ * Sets the version
+ * This is used only when
+ * version override mechanism was applied to this artifact. So
+ * dependecy version and artifact version are different
*/
- public void setVersionOveridden( boolean versionOverriden );
+ public void setOverriddenVersion( String version );
/**
- * Gets the flag is artifact's version has been overriden
- * @return
+ * Gets the artifact's version if the dependecy' version has been overriden
+ *
+ * @return Overriden version or <code>null</code>
*/
- public boolean isVersionOverridden();
-
-
- /**
- * Returns id which is "groupId:artifactId"
- *
- * @return id of this artifact
- */
- public String getId();
+ public String getOverriddenVersion();
/**
* Return an URL path that is platform agnostic.
1.11 +31 -113
maven-new/core/src/java/org/apache/maven/artifact/DefaultArtifact.java
Index: DefaultArtifact.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/artifact/DefaultArtifact.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultArtifact.java 25 May 2003 10:26:07 -0000 1.10
+++ DefaultArtifact.java 29 May 2003 20:26:19 -0000 1.11
@@ -74,25 +74,6 @@
*/
protected final static String PATH_SEPARATOR = File.separator;
- /**
- * The id of this artifact
- */
- private String artifactId;
-
- /**
- * The group id for the artifact.
- */
- private String groupId;
-
- /**
- * Version of this artifact
- */
- private String version;
-
- /**
- * Type such as "jar" or "war"
- */
- private String type;
/**
* The artifact path
@@ -110,21 +91,15 @@
private Dependency dependency = null;
/**
- * Overidden file flag
+ * Flag indicating that this artifact has been overidden
*/
private boolean fileOverriden;
/**
- * Overidden version flag
+ * Overidden version
*/
- private boolean versionOverriden;
+ private String version;
- /**
- * Default constructor
- */
- public DefaultArtifact()
- {
- }
/**
* Create artifacts from supplied dependecy
@@ -133,85 +108,30 @@
*/
public DefaultArtifact(Dependency dependency)
{
- setArtifactId(dependency.getArtifactId());
- setGroupId(dependency.getGroupId());
- setVersion(dependency.getVersion());
- setType(dependency.getType());
- }
-
- /**
- * @see org.apache.maven.artifact.Artifact#setArtifactId(String)
- */
- public void setArtifactId(String artifactId)
- {
- this.artifactId = artifactId;
+ this.dependency = dependency;
+
}
- /**
- * @see org.apache.maven.artifact.Artifact#getArtifactId()()
- */
- public String getArtifactId()
- {
- return artifactId;
- }
- /**
- * @see org.apache.maven.artifact.Artifact#setGroupId(java.lang.String)
- */
- public void setGroupId(String groupId)
- {
- this.groupId = groupId;
- }
/**
- * @see org.apache.maven.artifact.Artifact#getGroupId()
- */
- public String getGroupId()
- {
- return groupId;
- }
-
- /**
- * @see org.apache.maven.artifact.Artifact#setVersion(java.lang.String)
- */
- public void setVersion(String version)
- {
- this.version = version;
- }
-
- /**
- * @see org.apache.maven.artifact.Artifact#getVersion()
+ * @see org.apache.maven.artifact.Artifact#getArtifactId()()
*/
- public String getVersion()
+ public String getArtifact()
{
- return version;
+ return getFile().getName();
}
- /**
- * @see org.apache.maven.artifact.Artifact#getType()
- */
- public String getType()
- {
- return type;
- }
/**
* @see org.apache.maven.artifact.Artifact#setType(java.lang.String)
*/
- public void setPath(String path)
+ public void setPath( String path )
{
this.path = path;
}
/**
- * @see org.apache.maven.artifact.Artifact#setType(java.lang.String)
- */
- public void setType(String type)
- {
- this.type = type;
- }
-
- /**
* @see org.apache.maven.artifact.Artifact#getPath()
*/
public String getPath()
@@ -240,7 +160,12 @@
*/
public boolean isSnapshot()
{
- return getVersion().endsWith(MavenConstants.SNAPSHOT_SIGNIFIER);
+ String version = getDependency().getVersion();
+ if ( version == null )
+ {
+ return false;
+ }
+ return version.equalsIgnoreCase(MavenConstants.SNAPSHOT_SIGNIFIER);
}
/**
@@ -301,22 +226,6 @@
{
return dependency;
}
-
- /**
- * @see org.apache.maven.artifact.Artifact#getName()
- */
- public String getId()
- {
- return getGroupId() + ":" + getArtifactId();
- }
-
- /**
- * @see org.apache.maven.artifact.Artifact#setDependency(Dependency )
- */
- public void setDependency(Dependency dependency)
- {
- this.dependency = dependency;
- }
/**
* @see org.apache.maven.artifact.Artifact#setOverriden(boolean )
@@ -334,19 +243,28 @@
return fileOverriden;
}
/**
- * @see org.apache.maven.artifact.Artifact#setVersionOverriden(boolean )
+ * @see org.apache.maven.artifact.Artifact#setVersion(String )
*/
- public void setVersionOveridden( boolean versionOverriden )
+ public void setOverriddenVersion( String version )
{
- this.versionOverriden = versionOverriden;
+ this.version= version;
}
/**
- * @see org.apache.maven.artifact.Artifact#isVersionOverriden()
+ * @see org.apache.maven.artifact.Artifact#getVersion()
*/
- public boolean isVersionOverridden()
+ public String getOverriddenVersion()
{
- return versionOverriden;
+ return version;
}
+
+
+ /**
+ *
+ */
+ public String toString()
+ {
+ return "Artifact:[" + dependency.getId() + ":" + dependency.getVersion()
+"]";
+ }
}
1.4 +11 -8
maven-new/core/src/test/org/apache/maven/artifact/download/MockArtifactDownloader.java
Index: MockArtifactDownloader.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/test/org/apache/maven/artifact/download/MockArtifactDownloader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MockArtifactDownloader.java 27 May 2003 13:04:15 -0000 1.3
+++ MockArtifactDownloader.java 29 May 2003 20:26:19 -0000 1.4
@@ -81,14 +81,15 @@
/**
* @see
org.apache.maven.artifact.download.ArtifactDownloader#getRemoteArtifact(org.apache.maven.artifact.Artifact,
org.apache.maven.project.Project)
*/
- public boolean getRemoteArtifact(Artifact artifact, Project project)
+ public boolean getRemoteArtifact( Artifact artifact, Project project)
{
- if (forcedFailures.contains(artifact.getId()))
+ String id = artifact.getDependency().getId();
+ if (forcedFailures.contains( id ))
{
- System.out.println("Forced failure for: " + artifact.getId() );
+ System.out.println( "Forced failure for: " + id );
return false;
}
- downloadedDependencies.add(artifact.getId());
+ downloadedDependencies.add( id );
return true;
}
@@ -98,8 +99,9 @@
*/
public static void forceFailure(Artifact artifact)
{
- System.out.println(" Forced failure requested for: " + artifact.getId() );
- forcedFailures.add(artifact.getId());
+ String id = artifact.getDependency().getId();
+ System.out.println( " Forced failure requested for: " + id );
+ forcedFailures.add( id );
}
/**
@@ -129,7 +131,8 @@
*/
public static boolean wasArtifactDownloaded(Artifact artifact)
{
- return downloadedDependencies.contains(artifact.getId());
+ String id = artifact.getDependency().getId();
+ return downloadedDependencies.contains( id );
}
1.4 +64 -28
maven-new/core/src/test/org/apache/maven/artifact/satisfy/DefaultDependencySatisfierTest.java
Index: DefaultDependencySatisfierTest.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/test/org/apache/maven/artifact/satisfy/DefaultDependencySatisfierTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultDependencySatisfierTest.java 27 May 2003 13:04:16 -0000 1.3
+++ DefaultDependencySatisfierTest.java 29 May 2003 20:26:21 -0000 1.4
@@ -82,7 +82,7 @@
*/
public DefaultDependencySatisfierTest(String testName)
{
- super(testName);
+ super( testName );
}
/**
@@ -92,10 +92,10 @@
{
super.setUp();
dependencySatisfier =
- (DependencySatisfier) lookup(DependencySatisfier.ROLE);
+ ( DependencySatisfier ) lookup( DependencySatisfier.ROLE );
- builder = (ProjectBuilder) lookup(ProjectBuilder.ROLE);
- artifactFactory = (ArtifactFactory) lookup(ArtifactFactory.ROLE);
+ builder = ( ProjectBuilder ) lookup( ProjectBuilder.ROLE );
+ artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
// We are setting the value of the test local repository because if a value
is set
// it will be used. If you have maven.repo.local set in your
~/build.properties then
@@ -103,11 +103,17 @@
// should set this up to always use our test repo.
artifactFactory.setMavenRepoLocal(
- getTestFile("src/test-input/maven-repo-local"));
+ getTestFile( "src/test-input/maven-repo-local" ) );
MockArtifactDownloader.clear();
}
- private Project getProject(String file)
+
+ /**
+ *
+ * @param file
+ * @return
+ */
+ private Project getProject( String file )
{
Project project = null;
@@ -211,25 +217,24 @@
MockArtifactDownloader.wasArtifactDownloaded(testB);
String msg =
"There was no attempt made to download required artifact: ";
- assertTrue(msg + testA.getId(), testAWasDownloaded);
- assertTrue(msg + testB.getId(), testBWasDownloaded);
+ assertTrue(msg + testA, testAWasDownloaded);
+ assertTrue(msg + testB, testBWasDownloaded);
}
/**
- *
- *
- */
+ *
+ *
+ */
public void testNotReachableDependencies()
{
-
Project project =
- getProject("src/test-input/artifact-satisfier/missed-deps/project.xml");
- project.setOnline(Boolean.TRUE);
+ getProject(
"src/test-input/artifact-satisfier/missed-deps/project.xml");
+ project.setOnline( Boolean.TRUE );
try
{
- artifactFactory.createArtifacts(project);
+ artifactFactory.createArtifacts( project );
}
- catch (Exception e)
+ catch ( Exception e )
{
String msg =
"Cannot build artifact list for a project: " + e.getMessage();
@@ -238,7 +243,7 @@
Artifact testA = (Artifact) project.getArtifacts().get(0);
Artifact testB = (Artifact) project.getArtifacts().get(1);
- // we wil smulate the failure for testB
+ // we wil simulate the failure for artifact 'testB'
MockArtifactDownloader.forceFailure(testB);
try
@@ -266,18 +271,32 @@
expectedNumOfDownloads,
actualNumOfDownloads);
+ }
+
+ /**
+ *
+ *
+ */
+ public void testDependecyResolving()
+ {
+ Project project = getProject(
"src/test-input/artifact-satisfier/all-in-repo/project.xml" );
+
+ Artifact testA = (Artifact) project.getArtifacts().get(0);
+ Artifact testB = (Artifact) project.getArtifacts().get(1);
+
boolean testAWasDownloaded =
MockArtifactDownloader.wasArtifactDownloaded(testA);
boolean testBWasDownloaded =
MockArtifactDownloader.wasArtifactDownloaded(testB);
+
assertTrue(
"There was no attempt made to download required artifact: "
- + testA.getId(),
+ + testA,
testAWasDownloaded);
assertFalse(
- " The failure was expected for: " + testB.getId(),
+ " The failure was expected for: " + testB,
testBWasDownloaded);
}
@@ -289,30 +308,47 @@
public void testSnapshotDependenciesOnLine()
{
Project project =
- getProject("src/test-input/artifact-satisfier/snapshots/project.xml");
+ getProject( "src/test-input/artifact-satisfier/snapshots/project.xml" );
- project.setOnline(Boolean.TRUE);
+ project.setOnline( Boolean.TRUE );
try
{
- artifactFactory.createArtifacts(project);
+ artifactFactory.createArtifacts( project );
}
- catch (Exception e)
+ catch ( Exception e )
{
String msg =
"Cannot build artifact list for a project: " + e.getMessage();
- fail(msg);
+ fail( msg );
}
-
try
{
dependencySatisfier.satisfyDependencies(project);
}
- catch (Exception e)
+ catch ( Exception e )
{
String msg =
"Unexpected error occurred in 'satisfyDependencies': "
+ e.getMessage();
- fail(msg);
+ fail( msg );
+ }
+ Set deps = MockArtifactDownloader.getDownloadedDependencies();
+ int expectedNumOfDownloads = 0;
+ int actualNumOfDownloads = deps.size();
+ assertEquals(
+ "No dependecy should be downloaded",
+ expectedNumOfDownloads,
+ actualNumOfDownloads );
+ try
+ {
+ dependencySatisfier.satisfyDependencies( project );
+ }
+ catch ( Exception e )
+ {
+ String msg =
+ "Unexpected error occurred in 'satisfyDependencies': "
+ + e.getMessage();
+ fail( msg );
}
Set deps1 = MockArtifactDownloader.getDownloadedDependencies();
int expectedNumOfDownloads1 = 2;
1.5 +2 -2 maven-new/core/src/java/org/apache/maven/MavenConstants.java
Index: MavenConstants.java
===================================================================
RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/MavenConstants.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MavenConstants.java 24 May 2003 13:00:08 -0000 1.4
+++ MavenConstants.java 29 May 2003 20:26:22 -0000 1.5
@@ -104,7 +104,7 @@
/** Version Override property tag. */
- public static final String FILE_OVERRIDE_PROPERTY = "maven.override.file.";
+ public static final String ARTIFACT_OVERRIDE_PROPERTY =
"maven.override.artifact.";
/** Local Repository tag. */
public static final String REPO_LOCAL = "maven.repo.local";
1.5 +3 -11
maven-new/core/src/java/org/apache/maven/artifact/handlers/DefaultArtifactHandlerManager.java
Index: DefaultArtifactHandlerManager.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/DefaultArtifactHandlerManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultArtifactHandlerManager.java 26 May 2003 16:23:47 -0000 1.4
+++ DefaultArtifactHandlerManager.java 29 May 2003 20:26:22 -0000 1.5
@@ -56,17 +56,9 @@
* ====================================================================
*/
-import java.io.File;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.maven.MavenConstants;
+import org.apache.avalon.framework.service.Serviceable;
import org.apache.maven.MavenException;
import org.apache.maven.artifact.Artifact;
@@ -93,7 +85,7 @@
public ArtifactHandler getHandler( Artifact artifact )
throws MavenException
{
- String type = artifact.getType();
+ String type = artifact.getDependency().getType();
ArtifactHandler handler = null;
1.6 +2 -2
maven-new/core/src/java/org/apache/maven/artifact/handlers/JarHandler.java
Index: JarHandler.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/JarHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JarHandler.java 26 May 2003 16:25:13 -0000 1.5
+++ JarHandler.java 29 May 2003 20:26:22 -0000 1.6
@@ -77,7 +77,7 @@
*/
public void process( Artifact artifact, Project project )
{
- project.setDependencyPath( artifact.getId(), artifact.getPath() );
+ project.setDependencyPath( artifact.getDependency().getId(),
artifact.getPath() );
}
}
1.4 +2 -2 maven-new/core/src/test-input/overriding/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/maven-new/core/src/test-input/overriding/project.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- project.xml 25 May 2003 10:26:07 -0000 1.3
+++ project.xml 29 May 2003 20:26:22 -0000 1.4
@@ -11,7 +11,7 @@
<groupId>g1</groupId>
<artifactId>d1</artifactId>
<version>v1</version>
- <file>lutefisk.fish</file>
+ <artifact>lutefisk.fish</artifact>
</dependency>
@@ -30,7 +30,7 @@
<groupId>g3</groupId>
<artifactId>d3</artifactId>
<version>3.0</version>
- <file>should_be_ignored</file>
+ <artifact>should_be_ignored</artifact>
</dependency>
<!-- Version overriding in properties file -->
1.3 +2 -2 maven-new/core/src/test-input/overriding/project.properties
Index: project.properties
===================================================================
RCS file: /home/cvs/maven-new/core/src/test-input/overriding/project.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- project.properties 24 May 2003 18:30:26 -0000 1.2
+++ project.properties 29 May 2003 20:26:22 -0000 1.3
@@ -7,8 +7,8 @@
# ------------------------------------------------------------------------
# Artifacts set explicity by path.
# ------------------------------------------------------------------------
-maven.override.file.g2.d2.jar = /lib/d2.jar
-maven.override.file.g3.d3.jar = /lib/d3.jar
+maven.override.artifact.g2.d2.jar = /lib/d2.jar
+maven.override.artifact.g3.d3.jar = /lib/d3.jar
# ------------------------------------------------------------------------
1.7 +5 -5
maven-new/core/src/java/org/apache/maven/artifact/satisfy/DefaultDependencySatisfier.java
Index: DefaultDependencySatisfier.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/artifact/satisfy/DefaultDependencySatisfier.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultDependencySatisfier.java 27 May 2003 13:04:16 -0000 1.6
+++ DefaultDependencySatisfier.java 29 May 2003 20:26:22 -0000 1.7
@@ -166,7 +166,7 @@
System.out.println(
I18NUtils.getMessage(
"offline.snapshot.warning",
- artifact.getId() ) );
+ artifact.getDependency().getId() ) );
}
}
}
@@ -215,7 +215,7 @@
for ( Iterator i = failedDependencies.iterator(); i.hasNext(); )
{
Artifact artifact = (Artifact) i.next();
- message.append( artifact.getId() ).append( "\n" );
+ message.append( artifact.getDependency().getId() ).append( "\n" );
}
return message.toString();
}
@@ -244,7 +244,7 @@
}
System.out.println(
- I18NUtils.getMessage( "download.message", artifact.getId() ) );
+ I18NUtils.getMessage( "download.message",
artifact.getDependency().getId() ) );
if ( artifactDownloader.getRemoteArtifact( artifact, project ) )
{
@@ -257,7 +257,7 @@
String warning =
I18NUtils.getMessage(
"failed.download.warning",
- artifact.getId() );
+ artifact.getDependency().getId() );
System.err.println( warning );
}
}
1.4 +44 -124 maven-new/core/src/java/org/apache/maven/project/Dependency.java
Index: Dependency.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/project/Dependency.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Dependency.java 24 May 2003 18:30:26 -0000 1.3
+++ Dependency.java 29 May 2003 20:26:22 -0000 1.4
@@ -1,7 +1,5 @@
package org.apache.maven.project;
-import org.apache.maven.DeprecationWarning;
-
/* ====================================================================
* The Apache Software License, Version 1.1
*
@@ -71,8 +69,8 @@
/** The URL to the dependency's homepage. */
private String url;
- /** Explictly set file name */
- private String file;
+ /** Explictly set artifact name */
+ private String artifact;
/** Artifact name */
private String artifactId;
@@ -130,36 +128,18 @@
}
/**
- *
- * @return
+ * Get Id = <code>"groupId:artifactId:type"<code>
+ * @return id of this dependecy
*/
public String getId()
{
- if ( isValid( getGroupId() )
- &&
- isValid( getArtifactId() ) )
- {
- // We have something like:
- //
- // <dependency>
- // <groupId>commons-jelly</groupId>
- // <artifactId>commons-jelly-tags-velocity</artifactId>
- // <version>SNAPSHOT</version>
- // </dependency>
-
- return getGroupId() + ":" + getArtifactId();
- }
-
- //!! I have no idea where this is coming from.
-
- /*
- if ( id == null )
- {
- System.out.println( "ERROR: Somehow you've managed to set the ID of
dep(" + id + " / " + groupId + ":" + artifactId + ") to null" );
- }
- */
-
- return id;
+ StringBuffer id = new StringBuffer();
+ id.append( getGroupId() );
+ id.append( ":" );
+ id.append( getArtifactId() );
+ id.append(":");
+ id.append( getType() );
+ return id.toString();
}
/**
@@ -182,21 +162,7 @@
return groupId;
}
- /**
- * Get the directory to place the artifact in. If the groupId has been
- * set then use that, otherwise use the id.
- *
- * @return The artifact directory.
- */
- public String getArtifactDirectory()
- {
- if ( isValid( getGroupId() ) )
- {
- return getGroupId();
- }
-
- return getId();
- }
+
/**
* Get the artifact id.
@@ -219,23 +185,17 @@
}
/**
- * Gets the artifact name of the dependency. This is always calculated so
- * that the version can be changed dynamically using the maven override
- * facility.
- *
- * @return The artifact name.
- * @deprecated I don't think we should use this (mm)
- */
- public String getArtifact()
- {
- // If the file name has been explicty set then use that. This
- // is when the <file/> element is explicity used in the POM.
- if ( file != null )
- {
- return file;
- }
-
- return getArtifactId() + "-" + getVersion() + "." + getType();
+ * Get the name of the artifact if expliciltly
+ * set by user
+ *
+ * This is part of artifact overrding mechanism
+ *
+ *
+ * @return The artifact name.
+ */
+ public String getArtifact()
+ {
+ return artifact;
}
/**
@@ -257,73 +217,30 @@
{
return version;
}
+
/**
- * Set the name of the JAR if it cannot be synthesized from the id and
- * version.
- *
- * @param jar Name of the jar
- *
- * @deprecated [EMAIL PROTECTED] setFile } should be used instead
- */
- public void setJar( String jar )
- {
- DeprecationWarning.warn(" setJar( String jar ) method is deprecated");
- setFile( jar );
- }
-
-
-
-
- /**
- * Set the name of the JAR if it cannot be synthesized from the id and
+ * This method lets explicitly set the name of the artifact to use
+ * if it cannot be synthesized from the artifactId and
* version.
*
- * @param jar Name of the jar
+ * @param artifact The name of the artifact
+ * @see getArtifact
*/
- public void setFile( String file )
- {
+ public void setArtifact( String artifact )
+ {
+
// This is a check we need because of the jelly interpolation
// process. If we don't check an empty string will be set and
// screw up getArtifact() above.
- if ( file.trim().length() == 0 )
+ if ( artifact.trim().length() == 0 )
{
- return;
+ return;
}
-
- this.file = file;
+ this.artifact = artifact;
}
-
-
-
- /**
- * Get the name of the JAR. We will attempt to synthesize the name of the
- * JAR from the id and version.
- *
- * @return Name of the jar
- * @deprecated <code>getFile()</code> should be used instead
- */
- public String getJar()
- {
- DeprecationWarning.warn(" String getJar() method is deprecated");
- return getFile();
- }
-
-
- /**
- * Get the name of the file. This is part of artifact override mechanism
- *
- * @return Name of the the file
- */
- public String getFile()
- {
- return file;
- }
-
-
-
/**
* Set the name of url for the dependency.
*
@@ -346,12 +263,17 @@
/**
- * Set the type of the dependency.
+ * Get the type of the dependency. If no type was set it is
+ * assumed that is of type <code>jar</code>
*
- * @return dependency type such as "compile" or "test"
+ * @return dependency type such as <code>jar</code> or <code>war</code>
*/
public String getType()
- {
+ {
+ if ( type == null || type.trim().length() == 0 )
+ {
+ return "jar";
+ }
return type;
}
@@ -372,9 +294,7 @@
*/
public String toString()
{
- return "Dep[ id:" + getId() + " pid:" + getId()
- + " ver:" + getVersion() + " ar:" + getArtifact() + " file:"
- + getFile() + " ]";
+ return "Dep[" + getId() + " ]";
}
1.8 +46 -9
maven-new/core/src/java/org/apache/maven/project/builder/DefaultProjectUnmarshaller.java
Index: DefaultProjectUnmarshaller.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/project/builder/DefaultProjectUnmarshaller.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultProjectUnmarshaller.java 24 May 2003 18:30:26 -0000 1.7
+++ DefaultProjectUnmarshaller.java 29 May 2003 20:26:22 -0000 1.8
@@ -1,5 +1,10 @@
package org.apache.maven.project.builder;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Properties;
+
import org.apache.maven.DeprecationWarning;
import org.apache.maven.project.Build;
import org.apache.maven.project.Contributor;
@@ -16,9 +21,6 @@
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
-import java.io.IOException;
-import java.io.Reader;
-
/**
* @author Jason van Zyl
* @version $Id$
@@ -358,14 +360,49 @@
{
d.setUrl( parser.nextText() );
}
- else if ( parser.getName().equals( "file" ) )
+ else if ( parser.getName().equals( "artifact" ) )
{
- d.setFile( parser.nextText() );
+ d.setArtifact( parser.nextText() );
}
else if ( parser.getName().equals( "jar" ) )
{
- d.setFile( parser.nextText() );
- }
+ String msg = "You should be using <artifact> tag
" +
+ "instead of <jar> for Dependency: " +
+ d.getId();
+ DeprecationWarning.warn( msg );
+ d.setArtifact( parser.nextText() );
+ }
+ // E X P E R I M E N T A L
+ //
+ // istead of
+ // <properties>
+ // <war.bundle>true</war.bundle>
+ // </properties>
+ //
+ // which is not very XML'ish enayway
+ // we will have:
+ // <properties>
+ // war.bundle=true
+ // foo=baa
+ // </properties>
+ //
+ // This is has two advantages:
+ // a) very simple to implement
+ // b) simpler to use for end user
+ //
+ //
+ //
+ else if ( parser.getName().equals( "properties" ) )
+ {
+
+ String str = parser.nextText();
+ ByteArrayInputStream bais
+ = new ByteArrayInputStream( str.getBytes() );
+ Properties properties = new Properties();
+ properties.load( bais );
+ d.setProperties( properties );
+ }
+
else
{
parser.nextText();
@@ -489,7 +526,7 @@
}
}
}
-
+
eventType = parser.next();
}
1.3 +17 -5
maven-new/core/src/test/org/apache/maven/artifact/handlers/DefaultArtifactHandlerManagerTest.java
Index: DefaultArtifactHandlerManagerTest.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/test/org/apache/maven/artifact/handlers/DefaultArtifactHandlerManagerTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultArtifactHandlerManagerTest.java 26 May 2003 16:25:13 -0000 1.2
+++ DefaultArtifactHandlerManagerTest.java 29 May 2003 20:26:23 -0000 1.3
@@ -58,6 +58,7 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.project.Dependency;
import org.apache.plexus.PlexusTestCase;
/**
@@ -92,8 +93,15 @@
public void testHandlerAssiging()
{
String msg = "Wrong artifact handler was assigned for artifact of type: '";
- Artifact artifact1 = new DefaultArtifact();
- artifact1.setType("jar");
+
+ Dependency dependency1 = new Dependency();
+ dependency1.setGroupId( "g1" );
+ dependency1.setArtifactId( "g1" );
+ dependency1.setType( "jar" );
+ dependency1.setVersion( "1.0" );
+
+ Artifact artifact1 = new DefaultArtifact( dependency1 );
+
String expectedHandler1 = new JarHandler().getClass().getName();
String actualHandler1 = null;
try
@@ -111,8 +119,12 @@
assertEquals(msg + "jar'.", expectedHandler1, actualHandler1);
// 2
- Artifact artifact2 = new DefaultArtifact();
- artifact2.setType("fish");
+ Dependency dependency2 = new Dependency();
+ dependency2.setGroupId( "g1" );
+ dependency2.setArtifactId( "g1" );
+ dependency2.setType( "fish" );
+ dependency2.setVersion( "1.0" );
+ Artifact artifact2 = new DefaultArtifact( dependency2 );
String expectedHandler2 = new NOPHandler().getClass().getName();
String actualHandler2 = null;
try
1.2 +2 -2
maven-new/core/src/test/org/apache/maven/artifact/handlers/MockArtifactHandler.java
Index: MockArtifactHandler.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/test/org/apache/maven/artifact/handlers/MockArtifactHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MockArtifactHandler.java 25 May 2003 19:10:24 -0000 1.1
+++ MockArtifactHandler.java 29 May 2003 20:26:23 -0000 1.2
@@ -82,7 +82,7 @@
*/
public void process( Artifact artifact, Project project )
{
- processedArtifacts.add( artifact.getId() );
+ processedArtifacts.add( artifact.getDependency().getId() );
}
1.18 +27 -47
maven-new/core/src/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
Index: DefaultArtifactFactory.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DefaultArtifactFactory.java 26 May 2003 16:25:13 -0000 1.17
+++ DefaultArtifactFactory.java 29 May 2003 20:26:23 -0000 1.18
@@ -114,31 +114,13 @@
boolean mavenJarOverride =
project.getMavenArtifactOverride().booleanValue();
for ( Iterator iter = dependencies.iterator(); iter.hasNext(); )
{
- // if dependecy has no type we are assuming that it is jar
- // BRW: Might it be better to have this logic in the Dependency.getType?
Dependency dependency = (Dependency) iter.next();
- if ( dependency.getType() == null
- || dependency.getType().trim().length() == 0 )
+
+ Artifact artifact = new DefaultArtifact( dependency );
+
+ if ( mavenJarOverride )
{
- dependency.setType( "jar" );
- }
- Artifact artifact = new DefaultArtifact();
- artifact.setDependency( dependency );
- artifact.setArtifactId( dependency.getArtifactId() );
- artifact.setGroupId( dependency.getArtifactDirectory() );
- artifact.setType( dependency.getType() );
- artifact.setVersion( dependency.getVersion() );
-
- // If artifact has a file set but no
- // file overriding mechanism was applied
- // it means that file sits in repository
- // and just last part of the path should
- // be replaced
- artifact.setFile(dependency.getFile());
-
- if (mavenJarOverride)
- {
- String file = getOverriddenFile( artifact, project );
+ String file = getOverriddenArtifact( dependency , project );
if ( file != null )
{
artifact.setFile( file );
@@ -146,11 +128,10 @@
}
else
{
- String version = getOverriddenVersion( artifact, project );
+ String version = getOverriddenVersion( dependency, project );
if ( version != null)
{
- artifact.setVersion( version );
- artifact.setVersionOveridden( true );
+ artifact.setOverriddenVersion( version );
}
}
}
@@ -233,17 +214,17 @@
* @param id Id of the project to override.
* @return MavenSession jar override value for a particular dependency.
*/
- public String getOverriddenFile( Artifact artifact, Project project )
+ public String getOverriddenArtifact( Dependency dependency, Project project )
{
- // XXX start of the block for backward compatibility
+ // XXX start of the block, which exists only for backward
compatibility
// this should be removed somewhere in the future
- String file = null;
- file = getMavenJarOverride ( artifact.getArtifactId(), project );
- if ( file != null)
+ String artifact = null;
+ artifact = getMavenJarOverride ( dependency.getArtifactId(), project
);
+ if ( artifact != null)
{
- if ( !Character.isDigit( file.charAt(0) ) )
+ if ( !Character.isDigit( artifact.charAt(0) ) )
{
- return file;
+ return artifact;
}
else
{
@@ -252,15 +233,14 @@
}
// end of block
- String key = MavenConstants.FILE_OVERRIDE_PROPERTY +
- artifact.getGroupId() +
+ String key = MavenConstants.ARTIFACT_OVERRIDE_PROPERTY +
+ dependency.getGroupId() +
"." +
- artifact.getArtifactId() +
+ dependency.getArtifactId() +
"." +
- artifact.getType();
-
- file = (String) project.getProperties().get( key );
- return file;
+ dependency.getType();
+ artifact = (String) project.getProperties().get( key );
+ return artifact;
}
/**
@@ -269,12 +249,12 @@
* @param id Id of the project to override.
* @return MavenSession jar override value for a particular dependency.
*/
- public String getOverriddenVersion( Artifact artifact, Project project )
+ public String getOverriddenVersion( Dependency dependency, Project project )
{
- // XXX start of the block for backward compatibility
+ // XXX start of the block, which exists only for backward
compatibility
// this should be removed somewhere in the future
String version = null;
- version = getMavenJarOverride ( artifact.getArtifactId(), project );
+ version = getMavenJarOverride ( dependency.getArtifactId(), project );
if ( version != null)
{
if ( Character.isDigit( version.charAt(0) ) )
@@ -289,11 +269,11 @@
// end of block
String key = MavenConstants.VERSION_OVERRIDE_PROPERTY +
- artifact.getGroupId() +
+ dependency.getGroupId() +
"." +
- artifact.getArtifactId() +
+ dependency.getArtifactId() +
"." +
- artifact.getType();
+ dependency.getType();
version = (String) project.getProperties().get( key );
return version;
}
1.3 +20 -3
maven-new/core/src/java/org/apache/maven/artifact/layout/RepositoryLayout.java
Index: RepositoryLayout.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/artifact/layout/RepositoryLayout.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RepositoryLayout.java 24 May 2003 05:48:05 -0000 1.2
+++ RepositoryLayout.java 29 May 2003 20:26:23 -0000 1.3
@@ -78,9 +78,26 @@
/**
* Returns the relative path for an artifact in local repository.
*
- * @param artifact the Artifact for which
+ * @param artifact the Artifact for which the path will be built
* @return the path
*/
- public String generatePath( Artifact artifact ) throws Exception;
+ public String generatePath(Artifact artifact) throws Exception;
+
+ /**
+ * Returns the relative path for an artifact in local repository.
+ *
+ * @param groupId
+ * @param artifactId
+ * @param type
+ * @param version
+ *
+ * @return the path
+ */
+ public String generatePath(
+ String groupId,
+ String artifactId,
+ String type,
+ String version)
+ throws Exception;
}
1.6 +75 -29
maven-new/core/src/java/org/apache/maven/artifact/layout/DefaultRepositoryLayout.java
Index: DefaultRepositoryLayout.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/artifact/layout/DefaultRepositoryLayout.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultRepositoryLayout.java 25 May 2003 10:26:07 -0000 1.5
+++ DefaultRepositoryLayout.java 29 May 2003 20:26:23 -0000 1.6
@@ -59,7 +59,6 @@
import org.apache.avalon.framework.activity.Initializable;
import org.apache.maven.MavenConstants;
import org.apache.maven.MavenException;
-import org.apache.maven.artifact.layout.RepositoryLayout;
import org.apache.maven.artifact.Artifact;
import org.apache.plexus.util.StringUtils;
@@ -90,7 +89,7 @@
*/
private final static String DEFAULT_LAYOUT =
"${groupId}/${type}s/${artifactId}-${version}.${type}";
-
+
/**
* List of cachedGlobalLayouts.
*/
@@ -99,30 +98,76 @@
/**
* see org.apache.maven.artifact.RepositoryLayout#generatePath(Artifact)
*/
- public String generatePath( Artifact artifact ) throws Exception
+ public String generatePath(Artifact artifact) throws Exception
{
- String layout = null;
- if ( artifact.getFile()!= null )
+ String layout = null;
+ String groupId = artifact.getDependency().getGroupId();
+ String artifactId = artifact.getDependency().getArtifactId();
+ String type = artifact.getDependency().getType();
+
+ // Use overriden vesrion if provided
+ String version = artifact.getOverriddenVersion();
+ if ( version == null )
+ {
+ version = artifact.getDependency().getVersion();
+ }
+
+ String artifactFile = null;
+ if (artifact.getDependency() != null)
+ {
+ artifactFile = artifact.getDependency().getArtifact();
+ }
+ // it means that user is requesting to use a given artifact name
+ // so path is: "{group directories}/{type}s/[user provided artifact]"
+ //in such case we will use special layout <<nameless>>
+ // ( find a better name for this)
+
+ if (artifactFile != null)
{
- //it means that user is requesting to use a given file name
- // so path is: "{group directories}/{type}s/[user provided file]"
- //in such case we will use special layout <<nameless>>
- // ( find a better name for this)
- layout = getLayout("nameless") + artifact.getFile();;
+ layout = getLayout("nameless") + artifactFile;
}
else
- {
+ {
// see if we have layout for this artifact type alredy in the cache
- layout = getLayout( artifact.getType() );
- }
- // interpolation of layout
- layout = StringUtils.replace( layout, "${artifactId}",
artifact.getArtifactId() );
- layout =
- StringUtils.replace( layout, "${groupId}", artifact.getGroupId() );
-
- layout = StringUtils.replace( layout, "${type}", artifact.getType() );
- layout =
- StringUtils.replace( layout, "${version}", artifact.getVersion() );
+ layout = getLayout(type);
+ }
+ return interpolateLayout( groupId, artifactId, type, version, layout );
+ }
+
+ /**
+ * @see
org.apache.maven.artifact.layout.RepositoryLayout#generatePath(java.lang.String,
java.lang.String, java.lang.String, java.lang.String)
+ */
+ public String generatePath(
+ String groupId,
+ String artifactId,
+ String type,
+ String version)
+ throws Exception
+ {
+ String layout = getLayout( type );
+ return interpolateLayout( groupId, artifactId, type, version, layout );
+ }
+
+ /**
+ *
+ * @param groupId
+ * @param artifactId
+ * @param type
+ * @param version
+ * @param layout
+ * @return
+ */
+ private String interpolateLayout(
+ String groupId,
+ String artifactId,
+ String type,
+ String version,
+ String layout)
+ {
+ layout = StringUtils.replace(layout, "${groupId}", groupId);
+ layout = StringUtils.replace(layout, "${artifactId}", artifactId);
+ layout = StringUtils.replace(layout, "${type}", type);
+ layout = StringUtils.replace(layout, "${version}", version);
return layout;
}
@@ -153,7 +198,7 @@
return layout;
}
-
+
// ----------------------------------------------------------------------
// Lifecycle Management
// ----------------------------------------------------------------------
@@ -169,26 +214,27 @@
{
inputStream =
DefaultRepositoryLayout.class.getResourceAsStream(
- MavenConstants.LAYOUT_PROPERTIES );
- globalLayouts.load( inputStream );
+ MavenConstants.LAYOUT_PROPERTIES);
+ globalLayouts.load(inputStream);
}
- catch ( Exception e )
+ catch (Exception e)
{
String message = "Cannot read 'layout.properties' file";
- throw new MavenException( message, e );
+ throw new MavenException(message, e);
}
finally
{
- if ( inputStream != null )
+ if (inputStream != null)
{
try
{
inputStream.close();
}
- catch ( Exception e )
+ catch (Exception e)
{
}
}
}
}
+
}
1.9 +7 -13
maven-new/core/src/test/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
Index: DefaultArtifactFactoryTest.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/test/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DefaultArtifactFactoryTest.java 25 May 2003 10:26:07 -0000 1.8
+++ DefaultArtifactFactoryTest.java 29 May 2003 20:26:24 -0000 1.9
@@ -140,12 +140,12 @@
// a1
String expectedPath1 = "g1/jars/d1-1.0.jar" ;
String actualPath1= artifact1.getPath();
- assertEquals( msg2,expectedPath1,actualPath1 );
+ assertEquals( msg2 + artifact1 ,expectedPath1,actualPath1 );
// a2
String expectedPath2 = "g2/jars/d2-2.0.jar";
String actualPath2= artifact2.getPath();
- assertEquals( msg2,expectedPath2,actualPath2 );
+ assertEquals( msg2 + artifact2 ,expectedPath2,actualPath2 );
//4 Check if files were set correctly
String msg3="Artifact file has been set incorrectly.";
@@ -160,14 +160,8 @@
assertEquals( msg3,expectedFile2,actualFile2 );
-
-
- //5 check if artifact's fields were set properly
- assertEquals( "Group was incorrectly set." , artifact1.getGroupId() , "g1"
);
- assertEquals( "ArtifactId was incorrectly set." , artifact1.getArtifactId()
, "d1" );
- assertEquals( "Version was incorrectly set." , artifact1.getVersion() ,
"1.0" );
- assertEquals( "Type was incorrectly set." , artifact1.getType() , "jar" );
- assertFalse( "Version should not be overriden" ,
artifact1.isVersionOverridden() );
+ // 5 check if some fields were set correctly
+ assertNull( "Version should not be overriden" ,
artifact1.getOverriddenVersion() );
assertFalse( "File should not be overriden" ,
artifact1.isFileOverridden() );
assertFalse( "Artifact is not a SNAPHOT" , artifact1.isSnapshot() );
}
@@ -277,10 +271,10 @@
//4 check if some choosen artifacts' fields were set properly
- assertTrue( "Version was overriden." , artifact4.isVersionOverridden()
);
+ assertNotNull( "Version was overriden." ,
artifact4.getOverriddenVersion() );
assertFalse( "File should not be overriden." ,
artifact4.isFileOverridden() );
- assertFalse( "Version should not be overriden." ,
artifact3.isVersionOverridden() );
+ assertNull( "Version should not be overriden." ,
artifact3.getOverriddenVersion() );
assertTrue( "File was not overriden." , artifact3.isFileOverridden() );
}
1.5 +1 -2
maven-new/core/src/java/org/apache/maven/artifact/processor/DefaultArtifactProcessor.java
Index: DefaultArtifactProcessor.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/java/org/apache/maven/artifact/processor/DefaultArtifactProcessor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultArtifactProcessor.java 26 May 2003 16:25:13 -0000 1.4
+++ DefaultArtifactProcessor.java 29 May 2003 20:26:24 -0000 1.5
@@ -113,7 +113,6 @@
for (Iterator iter = artifacts.iterator(); iter.hasNext();)
{
Artifact artifact = (Artifact) iter.next();
- String type = artifact.getType();
ArtifactHandler artifactHandler = handlerManager.getHandler( artifact );
artifactHandler.process(artifact, project);
1.5 +19 -13
maven-new/core/src/test/org/apache/maven/artifact/layout/DefaultRepositoryLayoutTest.java
Index: DefaultRepositoryLayoutTest.java
===================================================================
RCS file:
/home/cvs/maven-new/core/src/test/org/apache/maven/artifact/layout/DefaultRepositoryLayoutTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultRepositoryLayoutTest.java 24 May 2003 05:55:47 -0000 1.4
+++ DefaultRepositoryLayoutTest.java 29 May 2003 20:26:24 -0000 1.5
@@ -58,6 +58,7 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.project.Dependency;
import org.apache.plexus.PlexusTestCase;
/**
@@ -88,11 +89,14 @@
{
String msg = "Expected path in repository is different than actual.";
- Artifact a = new DefaultArtifact();
- a.setArtifactId("mm_id");
- a.setGroupId("mm_group_id");
- a.setVersion("1.0.0");
- a.setType("a");
+ Dependency d = new Dependency();
+ d.setArtifactId("mm_id");
+ d.setGroupId("mm_group_id");
+ d.setVersion("1.0.0");
+ d.setType("a");
+ Artifact a = new DefaultArtifact( d );
+
+
String expectedPath1 = "mm_group_id/as/mm_id-1.0.0.a";
String actualPath1 = null;
try
@@ -108,21 +112,23 @@
assertEquals(msg, expectedPath1, actualPath1);
- Artifact ejb = new DefaultArtifact();
- ejb.setGroupId("boo");
- ejb.setArtifactId("foo");
- ejb.setVersion("1.1.1");
- ejb.setType("ejb");
+ Dependency ejbD = new Dependency();
+ ejbD.setGroupId("boo");
+ ejbD.setArtifactId("foo");
+ ejbD.setVersion("1.1.1");
+ ejbD.setType("ejb");
+ Artifact ejbA = new DefaultArtifact( ejbD );
+
String expectedPath2 = "boo/ejbs/foo-1.1.1.jar";
String actualPath2 = null;
try
{
- actualPath2 = repositoryLayout.generatePath(ejb);
+ actualPath2 = repositoryLayout.generatePath( ejbA );
}
catch (Exception e)
{
String msg2 =
- "Cannot bulid repository layout for: " + ejb + ".";
+ "Cannot bulid repository layout for: " + ejbA + ".";
fail(msg2);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]