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/09 06:59:50 UTC

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

jvanzyl     2002/12/08 21:59:50

  Modified:    src/java/org/apache/maven/project Dependency.java
  Log:
  refactoring
  
  Revision  Changes    Path
  1.24      +40 -25    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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Dependency.java	25 Nov 2002 19:20:49 -0000	1.23
  +++ Dependency.java	9 Dec 2002 05:59:50 -0000	1.24
  @@ -69,6 +69,9 @@
       /** The URL to the dependency's homepage. */
       private String url;
   
  +    /** Explictly set JAR name */
  +    private String jar;
  +
       /** Artifact name */
       private String artifact;
   
  @@ -180,16 +183,6 @@
       }
   
       /**
  -     * Set the artifact name.
  -     *
  -     * @param artifact The artifact name of the dependency.
  -     */
  -    public void setArtifact( String artifact )
  -    {
  -        this.artifact = artifact;
  -    }
  -
  -    /**
        * Gets the realId attribute of the Dependency object
        *
        * This is used by the reactor to turn a stated dependency
  @@ -225,26 +218,40 @@
       }
   
       /**
  -     * Gets the artifact name of the dependency.
  +     * Set the artifact name.
  +     *
  +     * @param artifact The artifact name of the dependency.
  +     */
  +    public void setArtifact( String artifact )
  +    {
  +        this.artifact = artifact;
  +    }
  +
  +    /**
  +     * 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.
        */
       public String getArtifact()
       {
  -        if ( artifact == null )
  +        // If the jar name has been explicty set then use that. This
  +        // is when the <jar/> element is explicity used in the POM.
  +        if ( jar != null)
           {
  -            if ( getIsPoorlyNamed() )
  -            {
  -                int j = getId().indexOf( ":" );
  -                return getId().substring( j + 1 ) + "-" + getVersion() + ".jar";
  -            }
  -            else
  -            {
  -                return getId().replace( '+', '-' ) + "-" + getVersion() + ".jar";
  -            }
  +            return jar;
           }
   
  -        return artifact;
  +        if ( getIsPoorlyNamed() )
  +        {
  +            int j = getId().indexOf( ":" );
  +            return getId().substring( j + 1 ) + "-" + getVersion() + ".jar";
  +        }
  +        else
  +        {
  +            return getId().replace( '+', '-' ) + "-" + getVersion() + ".jar";
  +        }
       }
   
       /**
  @@ -275,7 +282,15 @@
        */
       public void setJar( String jar )
       {
  -        setArtifact( jar );
  +        // 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 ( jar.trim().length() == 0 )
  +        {
  +            return;
  +        }
  +
  +        this.jar = jar;
       }
   
       /**
  @@ -286,7 +301,7 @@
        */
       public String getJar()
       {
  -        return getArtifact();
  +        return jar;
       }
   
       /**