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 2003/01/13 18:21:43 UTC
cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/project Dependency.java Project.java
jvanzyl 2003/01/13 09:21:42
Modified: src/java/org/apache/maven ArtifactListBuilder.java
DependencyClasspathBuilder.java
src/java/org/apache/maven/jelly/tags/maven
DependencyResolver.java SnapshotSignature.java
src/java/org/apache/maven/project Dependency.java
Project.java
Log:
o Cleanup to fully support old notation and the new (standard)
groupId/artifactId notation.
Revision Changes Path
1.7 +2 -2 jakarta-turbine-maven/src/java/org/apache/maven/ArtifactListBuilder.java
Index: ArtifactListBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/ArtifactListBuilder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ArtifactListBuilder.java 13 Jan 2003 00:04:52 -0000 1.6
+++ ArtifactListBuilder.java 13 Jan 2003 17:21:42 -0000 1.7
@@ -92,7 +92,7 @@
for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
{
Dependency d = (Dependency) i.next();
- String mavenJarProperty = project.getContext().getMavenJarOverride( d.getId() );
+ String mavenJarProperty = project.getContext().getMavenJarOverride( Project.standardToLegacyId( d.getId() ) );
Artifact artifact = DefaultArtifactFactory.createArtifact( d );
if ( mavenJarOverride
1.9 +1 -2 jakarta-turbine-maven/src/java/org/apache/maven/DependencyClasspathBuilder.java
Index: DependencyClasspathBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/DependencyClasspathBuilder.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DependencyClasspathBuilder.java 2 Jan 2003 01:30:22 -0000 1.8
+++ DependencyClasspathBuilder.java 13 Jan 2003 17:21:42 -0000 1.9
@@ -90,7 +90,6 @@
public static String build( Project project )
throws Exception
{
- //Path classpath = new Path( getProject().getRootContext().getAntProject() );
StringBuffer classpath = new StringBuffer();
for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); )
1.2 +5 -21 jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/maven/DependencyResolver.java
Index: DependencyResolver.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/maven/DependencyResolver.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DependencyResolver.java 31 Dec 2002 07:01:06 -0000 1.1
+++ DependencyResolver.java 13 Jan 2003 17:21:42 -0000 1.2
@@ -81,9 +81,6 @@
/** List of maven projects to analyse. */
private List projects;
- /** Project dependencies. */
- private HashMap projectDeps;
-
/** Flag to indicate whether the graph has been built. */
private boolean graphBuilt;
@@ -94,7 +91,6 @@
{
dependencyGraph = new DependencyGraph();
projects = new ArrayList();
- projectDeps = new HashMap();
graphBuilt = false;
}
@@ -108,17 +104,6 @@
}
/**
- * These are the fully populated projects that
- * are being fed into the reactor.
- *
- * @param project Project to add to the list.
- */
- public void addProject( Project project )
- {
- projects.add( project );
- }
-
- /**
* Set a list of projects to process.
*
* @param projects List of projects.
@@ -197,7 +182,7 @@
for ( Iterator i = projects.iterator(); i.hasNext(); )
{
Project p = (Project) i.next();
- idMap.put( p.getId(), p );
+ idMap.put( p.getId() , p );
}
List binaryDeps = new ArrayList();
@@ -233,10 +218,9 @@
for ( Iterator j = p.getDependencies().iterator(); j.hasNext(); )
{
Dependency d = (Dependency) j.next();
- Project dp = new Project();
- dp.setId( d.getRealId() );
- dp.setCurrentVersion( d.getVersion() );
- dependencies.add( dp );
+ Project dependentProject = new Project();
+ dependentProject.setId( d.getId() );
+ dependencies.add( dependentProject );
}
dependencyGraph.addDependencies( p, dependencies );
1.2 +3 -3 jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/maven/SnapshotSignature.java
Index: SnapshotSignature.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/maven/SnapshotSignature.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SnapshotSignature.java 31 Dec 2002 07:01:25 -0000 1.1
+++ SnapshotSignature.java 13 Jan 2003 17:21:42 -0000 1.2
@@ -31,7 +31,7 @@
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache MavenSession", nor may "Apache" appear in their name, without
+ * "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -73,7 +73,7 @@
public class SnapshotSignature
extends TagSupport
{
- /** MavenSession project */
+ /** Maven project */
private Project project;
/**
1.31 +11 -78 jakarta-turbine-maven/src/java/org/apache/maven/project/Dependency.java
Index: Dependency.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/Dependency.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- Dependency.java 12 Jan 2003 05:41:51 -0000 1.30
+++ Dependency.java 13 Jan 2003 17:21:42 -0000 1.31
@@ -82,7 +82,7 @@
private String type;
/** Flag to indicate the artifact is poorly named. */
- private boolean isPoorlyNamed = false;
+ //private boolean isPoorlyNamed = false;
/**
* Default constructor
@@ -98,32 +98,32 @@
*/
public void setId( String id )
{
- super.setId( id );
-
int i = id.indexOf( "+" );
int j = id.indexOf( ":" );
if ( i > 0 )
{
// We have something like 'ant+optional' where the
- // project id is 'ant' and the artifact name is
+ // group id is 'ant' and the artifact id is
// 'ant-optional'.
- setGroupId( getId().substring( 0, i ) );
+ setGroupId( id.substring( 0, i ) );
+ setArtifactId( id.replace( '+', '-' ) );
}
else if ( j > 0 )
{
// We have something like 'ant:my-poorly-name.jar' where the
- // project id is 'ant' and the artifact name is
+ // group id is 'ant' and the artifact id is
// 'my-poorly-named.jar'.
- setIsPoorlyNamed( true );
- setGroupId( getId().substring( 0, j ) );
+ setGroupId( id.substring( 0, j ) );
+ setArtifactId( id.substring( j + 1 ) );
}
else
{
// We have something like 'ant' where the
// the project id is 'ant' and the artifact name
// is 'ant'.
- setGroupId( getId() );
+ setGroupId( id );
+ setArtifactId( id );
}
}
@@ -187,41 +187,6 @@
}
/**
- * Gets the realId attribute of the Dependency object
- *
- * This is used by the reactor to turn a stated dependency
- * like this:
- *
- * maven+importscrubber-plugin
- *
- * into the id that the project declares for itself which
- * in this case looks like this:
- *
- * maven-importscrubber-plugin
- *
- * We also deal with poorly named artifacts:
- *
- * aspectj:aspectjrt
- *
- * becomes
- *
- * aspectj-aspectjrt
- *
- * @return The real id of the dependency.
- */
- public String getRealId()
- {
- if ( getIsPoorlyNamed() )
- {
- return getId().replace( ':', '-' );
- }
- else
- {
- return getId().replace( '+', '-' );
- }
- }
-
- /**
* Get the artifact id.
*
* @return The artifact id.
@@ -257,19 +222,7 @@
return jar;
}
- if ( isValid( getArtifactId() ) )
- {
- return getArtifactId() + "-" + getVersion() + "." + getType();
- }
- else if ( getIsPoorlyNamed() )
- {
- int j = getId().indexOf( ":" );
- return getId().substring( j + 1 ) + "-" + getVersion() + "." + getType();
- }
- else
- {
- return getId().replace( '+', '-' ) + "-" + getVersion() + "." + getType();
- }
+ return getArtifactId() + "-" + getVersion() + "." + getType();
}
/**
@@ -361,26 +314,6 @@
public void setType( String type )
{
this.type = type;
- }
-
- /**
- * Set the poorly named flag.
- *
- * @param isPoorlyNamed The poorly named flag.
- */
- public void setIsPoorlyNamed( boolean isPoorlyNamed )
- {
- this.isPoorlyNamed = isPoorlyNamed;
- }
-
- /**
- * Get poorly named flag.
- *
- * @return Poorly named flag.
- */
- public boolean getIsPoorlyNamed()
- {
- return isPoorlyNamed;
}
/**
1.65 +108 -40 jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java
Index: Project.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- Project.java 13 Jan 2003 07:08:10 -0000 1.64
+++ Project.java 13 Jan 2003 17:21:42 -0000 1.65
@@ -242,28 +242,75 @@
// A C C E S S O R S
// ----------------------------------------------------------------------
+ // trying to align dep.id with project.id
+ public String getId()
+ {
+ // The id has already been set.
+ if ( id != null && id.indexOf( ":" ) > 0 )
+ {
+ return id;
+ }
+
+ if ( isValid( getGroupId() ) )
+ {
+ return getGroupId() + ":" + id;
+ }
+
+ return id + ":" + id;
+ }
+
+ /**
+ * Set the project group id.
+ *
+ * @param groupId Project group id.
+ */
+ public void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ /**
+ * The group id in a particular POM refers to a real id of another
+ * project. We will use the Jelly and its tag libraries as an example
+ * of how this mechanism works.
+ *
+ * Jelly has a separate build for each Jelly tag lib that contributes to
+ * the overall family of tag libs. Much of the information required to build
+ * each tag library is shared so Maven's extension mechanism is utilized.
+ *
+ * We want each Jelly tag lib to have a group id of 'commons-jelly' because we
+ * want the resultant artifact to be of the form 'commons-jelly-X' where X is the
+ * id of the individual tag lib.
+ *
+ * @return Project group id.
+ */
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
/**
* Add a plugin context to the list of project's plugin contexts.
*
- * @param pluginName Plugin name.
+ * @param pluginId Plugin id.
* @param pluginContext The plugin context created when loading the plugin against this
* project's context.
*/
- public void addPluginContext( String pluginName, MavenJellyContext pluginContext )
+ public void addPluginContext( String pluginId, MavenJellyContext pluginContext )
{
- pluginContexts.put( pluginName, pluginContext );
+ pluginContexts.put( Project.standardToLegacyId( pluginId ), pluginContext );
}
/**
* Get the plugin context using the plugin name.
*
- * @param pluginName Plugin name.
+ * @param pluginId Plugin name.
* @return The plugin context create for the named plugin when it was loaded for
* this project.
*/
- public MavenJellyContext getPluginContext( String pluginName )
+ public MavenJellyContext getPluginContext( String pluginId )
{
- return (MavenJellyContext) pluginContexts.get( pluginName );
+ return (MavenJellyContext) pluginContexts.get( pluginId );
}
/**
@@ -396,40 +443,9 @@
return shortDescription;
}
- /**
- * Set the project group id.
- *
- * @param groupId Project group id.
- */
- public void setGroupId( String groupId )
- {
- this.groupId = groupId;
- }
-
- /**
- * The group id in a particular POM refers to a real id of another
- * project. We will use the Jelly and its tag libraries as an example
- * of how this mechanism works.
- *
- * Jelly has a separate build for each Jelly tag lib that contributes to
- * the overall family of tag libs. Much of the information required to build
- * each tag library is shared so Maven's extension mechanism is utilized.
- *
- * We want each Jelly tag lib to have a group id of 'commons-jelly' because we
- * want the resultant artifact to be of the form 'commons-jelly-X' where X is the
- * id of the individual tag lib.
- *
- * @return Project group id.
- */
- public String getGroupId()
- {
- return groupId;
- }
-
public String getArtifactDirectory()
{
- if ( getGroupId() != null
- && getGroupId().trim().equals("") == false )
+ if ( isValid( getGroupId() ) )
{
return getGroupId();
}
@@ -595,7 +611,7 @@
*/
public String getDependencyPath( String id )
{
- return (String) dependencyPaths.get( id );
+ return (String) dependencyPaths.get( legacyToStandardId( id ) );
}
/**
@@ -1326,5 +1342,57 @@
throws Exception
{
getContext().getMavenSession().loadJellyScript( jellyScript, this );
+ }
+
+ // ----------------------------------------------------------------------
+ // L E G A C Y I D S U P P O R T
+ // ----------------------------------------------------------------------
+
+ /**
+ * This is to support methods that are using the legacy form of
+ * the project id. Currently the id is <groupId>:<artifactId> but the
+ * following methods assume <groupId>:
+ *
+ * Project::getDependencyPath( <groupId> )
+ *
+ * We don't want users to have to alter any usage until we have properly
+ * deprecated the use of the <groupId> form.
+ *
+ * @param id
+ * @return
+ */
+ public static String legacyToStandardId( String id )
+ {
+ if ( id.indexOf( ":" ) < 0 )
+ {
+ id += ":" + id;
+ }
+
+ return id;
+ }
+
+ /**
+ * This method is to support methods are expecting legacy ids. The following
+ * methods expect legacy ids.
+ *
+ * MavenJellyContext::getMavenJarOverride( <groupId> )
+ * Project::addPluginContext( <groupId>, pluginContext )
+ *
+ * We don't want users to have to alter any usage until we have properly
+ * deprecated the use of the <groupId> form.
+ *
+ * @param id
+ * @return
+ */
+ public static String standardToLegacyId( String id )
+ {
+ int i = id.indexOf( ":" );
+
+ if ( i > 0 )
+ {
+ id = id.substring( i + 1 );
+ }
+
+ return id;
}
}