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/12 06:41:51 UTC

cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/project BaseObject.java Dependency.java Project.java

jvanzyl     2003/01/11 21:41:51

  Modified:    src/java/org/apache/maven/project BaseObject.java
                        Dependency.java Project.java
  Log:
  o Adding support for dependencies using the groupId/artifactId combination.
  
  Revision  Changes    Path
  1.21      +24 -5     jakarta-turbine-maven/src/java/org/apache/maven/project/BaseObject.java
  
  Index: BaseObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/BaseObject.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- BaseObject.java	31 Dec 2002 07:02:43 -0000	1.20
  +++ BaseObject.java	12 Jan 2003 05:41:51 -0000	1.21
  @@ -71,14 +71,14 @@
   public class BaseObject
   {
       /**
  -     * Display name to use for this object.
  +     * Id to use for this object.
        */
  -    private String name;
  +    protected String id;
   
       /**
  -     * Id to use for this object.
  +     * Display name to use for this object.
        */
  -    private String id;
  +    private String name;
   
       /**
        * Give object that have not been given an explicit unique id
  @@ -293,5 +293,24 @@
           {
               return super.hashCode();
           }
  +    }
  +
  +    /**
  +     * Simple check for a value in the POM. Due to the Jelly swizzling
  +     * fields that aren't set come out as empty strings. This will not
  +     * be required when the new lazy evaluation mechanism is put in place.
  +     *
  +     * @param value POM value to test.
  +     * @return Is the value valid.
  +     */
  +    protected boolean isValid( String value )
  +    {
  +        if (    value != null
  +             && value.trim().equals("") == false )
  +        {
  +            return true;
  +        }
  +
  +        return false;
       }
   }
  
  
  
  1.30      +60 -47    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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Dependency.java	11 Jan 2003 01:11:46 -0000	1.29
  +++ Dependency.java	12 Jan 2003 05:41:51 -0000	1.30
  @@ -73,10 +73,7 @@
       private String jar;
   
       /** Artifact name */
  -    private String artifact;
  -
  -    /** Project id */
  -    private String projectId;
  +    private String artifactId;
   
       /** Group id */
       private String groupId;
  @@ -95,18 +92,6 @@
       }
   
       /**
  -     * Debug string.
  -     *
  -     * @return Debugging string.
  -     */
  -    public String toString()
  -    {
  -        return "Dep[ id:" + getId() + " pid:" + getProjectId()
  -            + " ver:" + getVersion() + " ar:" + getArtifact() + " jar:"
  -            + getJar() + " ]";
  -    }
  -
  -    /**
        * Set the id for this dependency.
        *
        * @param id for this dependency
  @@ -123,7 +108,7 @@
               // We have something like 'ant+optional' where the
               // project id is 'ant' and the artifact name is
               // 'ant-optional'.
  -            setProjectId( getId().substring( 0, i ) );
  +            setGroupId( getId().substring( 0, i ) );
           }
           else if ( j > 0 )
           {
  @@ -131,18 +116,41 @@
               // project id is 'ant' and the artifact name is
               // 'my-poorly-named.jar'.
               setIsPoorlyNamed( true );
  -            setProjectId( getId().substring( 0, j ) );
  +            setGroupId( getId().substring( 0, j ) );
           }
           else
           {
               // We have something like 'ant' where the
               // the project id is 'ant' and the artifact name
               // is 'ant'.
  -            setProjectId( getId() );
  +            setGroupId( getId() );
           }
       }
   
       /**
  +     *
  +     * @return
  +     */
  +    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();
  +        }
  +
  +        return id;
  +    }
  +
  +    /**
        * Set the group id.
        *
        * @param groupId Group id for the dependency.
  @@ -170,33 +178,12 @@
        */
       public String getArtifactDirectory()
       {
  -        if (    getGroupId() != null
  -             && getGroupId().trim().equals("") == false )
  +        if ( isValid( getGroupId() ) )
           {
               return getGroupId();
           }
   
  -        return getProjectId();
  -    }
  -
  -    /**
  -     * Set the project id.
  -     *
  -     * @param projectId The project id for the dependency.
  -     */
  -    public void setProjectId( String projectId )
  -    {
  -        this.projectId = projectId;
  -    }
  -
  -    /**
  -     * Get the project id.
  -     *
  -     * @return The project id for the dependency.
  -     */
  -    public String getProjectId()
  -    {
  -        return projectId;
  +        return getId();
       }
   
       /**
  @@ -235,13 +222,23 @@
       }
   
       /**
  +     * Get the artifact id.
  +     *
  +     * @return The artifact id.
  +     */
  +    public String getArtifactId()
  +    {
  +        return artifactId;
  +    }
  +
  +    /**
        * Set the artifact name.
        *
  -     * @param artifact The artifact name of the dependency.
  +     * @param artifactId The artifact name of the dependency.
        */
  -    public void setArtifact( String artifact )
  +    public void setArtifactId( String artifactId )
       {
  -        this.artifact = artifact;
  +        this.artifactId = artifactId;
       }
   
       /**
  @@ -260,7 +257,11 @@
               return jar;
           }
   
  -        if ( getIsPoorlyNamed() )
  +        if ( isValid( getArtifactId() ) )
  +        {
  +            return getArtifactId() + "-" + getVersion() + "." + getType();
  +        }
  +        else if ( getIsPoorlyNamed() )
           {
               int j = getId().indexOf( ":" );
               return getId().substring( j + 1 ) + "-" + getVersion() + "." + getType();
  @@ -380,5 +381,17 @@
       public boolean getIsPoorlyNamed()
       {
           return isPoorlyNamed;
  +    }
  +
  +    /**
  +     * Debug string.
  +     *
  +     * @return Debugging string.
  +     */
  +    public String toString()
  +    {
  +        return "Dep[ id:" + getId() + " pid:" + getId()
  +            + " ver:" + getVersion() + " ar:" + getArtifact() + " jar:"
  +            + getJar() + " ]";
       }
   }
  
  
  
  1.61      +2 -2      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.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- Project.java	7 Jan 2003 08:23:27 -0000	1.60
  +++ Project.java	12 Jan 2003 05:41:51 -0000	1.61
  @@ -571,7 +571,7 @@
           for ( int i = 0; i < dependencies.size(); i++ )
           {
               dependency = (Dependency) dependencies.get( i );
  -            projectIds.add( dependency.getProjectId() );
  +            projectIds.add( dependency.getId() );
           }
           return projectIds;
       }