jvanzyl     01/08/26 11:06:07

  Modified:    jjar/src/java/org/apache/commons/jjar DependencyEngine.java
  Log:
  - adding the option to exclude the target from the created
    dependency list. for maven type builds the targets need to
    be included because they are built after the deps are satisfied
  
    in the case of JJAR you only need the JARs to build the project
    somewhere else.
  
  Revision  Changes    Path
  1.5       +45 -6     
jakarta-commons-sandbox/jjar/src/java/org/apache/commons/jjar/DependencyEngine.java
  
  Index: DependencyEngine.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/jjar/src/java/org/apache/commons/jjar/DependencyEngine.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DependencyEngine.java     2001/08/26 16:21:40     1.4
  +++ DependencyEngine.java     2001/08/26 18:06:07     1.5
  @@ -82,7 +82,7 @@
    *  </p>
    *
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Geir Magnusson Jr.</a>
  - *  @version $Id: DependencyEngine.java,v 1.4 2001/08/26 16:21:40 jvanzyl Exp $ 
  + *  @version $Id: DependencyEngine.java,v 1.5 2001/08/26 18:06:07 jvanzyl Exp $ 
    */
   public class DependencyEngine
   {    
  @@ -114,9 +114,26 @@
   
       /**
        *  returns a list of dependencies for a given package
  +     *  with the target being excluded from the list.
  +     *
  +     *  @param pkg package to get dependency list for
  +     *  @return List list of dependencies, in order
        */
       public List getDependencies( String pkg )
       {
  +        return getDependencies(pkg, true);
  +    }        
  +
  +    /**
  +     *  returns a list of dependencies for a given package
  +     *  allowing the exclusion/inclusion of the target package.
  +     *
  +     *  @param pkg package to get dependency list for
  +     *  @param excludeTarget boolean to control exclusion of target package
  +     *  @return List list of dependencies, in order
  +     */
  +    public List getDependencies( String pkg, boolean excludeTarget )
  +    {
           buildList = new ArrayList();
   
           try
  @@ -147,21 +164,43 @@
           {
               System.out.println("DE.getDependencies() : " + pkg + " : "  + e);
           }
  -
  -        if( buildList.size() > 0)
  +        
  +        // The the multi project dep list this code is lopping
  +        // off the package stated as the target. Need a flag to
  +        // indicated whether you want the target included or
  +        // or. For a multi-project build like maven you need
  +        // the target because you actually want to build the
  +        // target. For the JJAR task you don't want the target
  +        // because you're just downloading JARs.
  +        if( excludeTarget && buildList.size() > 0)
  +        {
               buildList.remove( buildList.size() - 1 );
  +        }
   
           return buildList;
       }
   
  -
       /**
        *  Generates a dependency list for a set of packages.
        *
        *  @param packages List of strings, each string is a package name
        *  @return list of dependencies, in order
  +     */
  +    public List getDependencies(List packages)
  +    {
  +        return getDependencies(packages, true);
  +    }
  +
  +    /**
  +     *  Generates a dependency list for a set of packages
  +     *  where there is the option to exclude/include the
  +     *  target packages.
  +     *
  +     *  @param packages List of strings, each string is a package name
  +     *  @param excludeTarget boolean to exclude target
  +     *  @return List list of dependencies, in order
        */
  -    public List getDependencies( List packages )
  +    public List getDependencies( List packages, boolean excludeTarget )
       {
           HashMap h = new HashMap();
           ArrayList l = new ArrayList();
  @@ -176,7 +215,7 @@
           {
               String pkg = (String) i.next();
   
  -            List deps = getDependencies( pkg );
  +            List deps = getDependencies( pkg, excludeTarget );
   
               for (Iterator ii = deps.iterator(); ii.hasNext(); )
               {
  
  
  

Reply via email to