gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r209309 - in /gump/branches/Gump3/pygump/python/gump: config.py engine/__init__.py engine/objectifier.py model/__init__.py model/util.py plugins/builder.py plugins/java/builder.py
Date Tue, 05 Jul 2005 19:36:39 GMT
Author: leosimons
Date: Tue Jul  5 12:36:32 2005
New Revision: 209309

URL: http://svn.apache.org/viewcvs?rev=209309&view=rev
Log:
Rework and dramatically simply classpath management. See

http://mail-archives.apache.org/mod_mbox/gump-general/200505.mbox/%3c0e0201c55c01f1b1420401a8c0@sybase.com%3e

for background, as well as

http://issues.apache.org/jira/browse/GUMP-117

and 

http://issues.apache.org/jira/browse/GUMP-118


and

http://mail-archives.apache.org/mod_mbox/gump-general/200505.mbox/%3cBEBB728C.3D48E%25mail@leosimons.com%3e
http://mail-archives.apache.org/mod_mbox/gump-general/200505.mbox/%3cBEBB77D8.3D49A%25mail@leosimons.com%3e

for more extensive discussion.

Basically, the old implementation delayed calculation of lots of paths instead of doing it
in the objectification stage. Doing it there makes a *lot* of the pain go away. Other changes
include simplification of the classpath calculation algorithm (and moving it into a utility
method), code formatting, making a Work directory into an Output, getting rid of all the 'artifact'
model objects, not swalling exceptions in the plugins, etc. Most of those change see lots
of discussion in the linked mailing list threads.

Modified:
    gump/branches/Gump3/pygump/python/gump/config.py
    gump/branches/Gump3/pygump/python/gump/engine/__init__.py
    gump/branches/Gump3/pygump/python/gump/engine/objectifier.py
    gump/branches/Gump3/pygump/python/gump/model/__init__.py
    gump/branches/Gump3/pygump/python/gump/model/util.py
    gump/branches/Gump3/pygump/python/gump/plugins/builder.py
    gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py

Modified: gump/branches/Gump3/pygump/python/gump/config.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/config.py?rev=209309&r1=209308&r2=209309&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/config.py (original)
+++ gump/branches/Gump3/pygump/python/gump/config.py Tue Jul  5 12:36:32 2005
@@ -285,10 +285,10 @@
     return Normalizer(log)
 
 
-def get_modeller_objectifier(log):
+def get_modeller_objectifier(config, log):
     """Provide a Objectifier implementation."""
     from gump.engine.objectifier import Objectifier
-    return Objectifier(log)
+    return Objectifier(log, config.paths_work)
 
 
 def get_modeller_verifier(config, walker):

Modified: gump/branches/Gump3/pygump/python/gump/engine/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/__init__.py?rev=209309&r1=209308&r2=209309&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/__init__.py Tue Jul  5 12:36:32 2005
@@ -97,7 +97,7 @@
     modeller_log = get_logger(config, _MODELLER_LOGGER_NAME)
     modeller_loader = get_modeller_loader(modeller_log, vfs)
     modeller_normalizer = get_modeller_normalizer(modeller_log)
-    modeller_objectifier = get_modeller_objectifier(modeller_log)
+    modeller_objectifier = get_modeller_objectifier(config, modeller_log)
     modeller_verifier = get_modeller_verifier(config, walker)
     
     mergefile = os.path.join(config.paths_work, _MERGE_FILE_NAME)

Modified: gump/branches/Gump3/pygump/python/gump/engine/objectifier.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/objectifier.py?rev=209309&r1=209308&r2=209309&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/objectifier.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/objectifier.py Tue Jul  5 12:36:32 2005
@@ -33,6 +33,25 @@
 from gump.engine.modeller import _find_element_text
 
 ###
+### Utility
+###
+def _extract_path(workdir, project, element):
+    """ Extract directory relative to module or project, based
+        upon which attribute (parent or nested) is present."""
+    parent = element.getAttribute("parent")
+    nested = element.getAttribute("nested")
+    
+    path = None
+    if parent:
+        path = os.path.join(get_module_directory(workdir, project.module), parent)
+    elif nested:
+        path = os.path.join(get_project_directory(workdir, project), nested)
+    else:
+        raise Error, "Unknown relative path entry (no parent or nested): %s" % (element)
+    return path
+
+
+###
 ### Creation
 ###
 def _create_workspace(workspace_definition):
@@ -170,11 +189,16 @@
     return LocalModule(repository, name, url, description)
 
 
-def _create_project(module, project_definition):
+def _create_project(module, project_definition, workdir):
     name = project_definition.getAttribute("name")
     path = project_definition.getAttribute("path")
     
     project = Project(module, name, path)
+
+    homes = project_definition.getElementsByTagName("home")
+    if homes.length > 0:
+        project.homedir = _extract_path(workdir, project, homes.item(0))
+
     return project
 
 
@@ -221,42 +245,21 @@
         target = cmd.getAttribute("target")
             
         project.add_command(Ant(project, name, target, buildfile))
-        #TODO 
 
-def _extract_relative_item(project, element):
-    """ Extract directory relative to module or project, based
-        upon which attribute  (parent or nested) is present."""
-    parent=element.getAttribute("parent")    
-    nested=element.getAttribute("nested")
-        
-    if parent:
-        rel_item=RelativePath(project.module,parent)
-    elif nested:
-        rel_item=RelativePath(project,nested)
-    else:
-        raise Error, "Unknown relative path entry (no parent or nested): %s" % (element)
-    
-    return rel_item
-        
-def _create_artifacts(project, project_definition):    
-    
-    # Work Items
+def _create_outputs(project, project_definition, workdir):    
+    # Working directories for this project (containing java classes)
     works = project_definition.getElementsByTagName("work")
     for work in works:
-        project.add_output(WorkItem(project,_extract_relative_item(project,work)))
+        path = _extract_path(workdir, project_definition, work)
+        project.add_output(Classdir(project, path))
 
-    # Home Directory (outputs are relative to this)
-    homes = project_definition.getElementsByTagName("home")
-    if homes.length > 0:
-        project.homedir = _extract_relative_item(project,homes.item(0))
-    
-    # Outputs
+    # Jars
     jars = project_definition.getElementsByTagName("jar")
     for jar in jars:
         name = jar.getAttribute("name")
         id = jar.getAttribute("id")
         add_to_bootclass_path = jar.getAttribute("type") == "boot"
-        project.add_output(Jar(project,name,id,add_to_bootclass_path))
+        project.add_output(Jar(project, name, id, add_to_bootclass_path))
     
     #TODO more outputs
 
@@ -354,9 +357,10 @@
     intermediate results during parsing as properties for convenience.
     """
     
-    def __init__(self, log):
+    def __init__(self, log, workdir):
         """Store all settings and dependencies as properties."""
         self.log = log
+        self.workdir = workdir
 
     def get_workspace(self, domtree):
         """Transforms a workspace xml document into object form."""
@@ -430,12 +434,12 @@
             self.log.debug("Converting project definition '%s' into object form." % name)
             try:
                 module = self._find_module_for_project(workspace, project_definition)
-                project = _create_project(module, project_definition)
+                project = _create_project(module, project_definition, self.workdir)
                 project.module.projects[project.name] = project
                 workspace.projects[project.name] = project
     
                 _create_commands(project, project_definition)
-                _create_artifacts(project, project_definition)
+                _create_outputs(project, project_definition, self.workdir)
             except:
                 # TODO: the name of the failing element and ideally the source xml file should
be
                 #       reported somewhere and e.g. e-mailed to the gump admins

Modified: gump/branches/Gump3/pygump/python/gump/model/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/__init__.py?rev=209309&r1=209308&r2=209309&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Tue Jul  5 12:36:32 2005
@@ -311,36 +311,35 @@
         - module       -- the containing module
         - name         -- per-run unique identifier
         - path         -- directory path within the containing module
+        - homedir      -- directory path within this project relative to which
+                          all other directory paths are to be resolved. Defaults
+                          to ".", the project base directory
         - dependencies -- list of Dependency instances describing what other
                           projects this project depends upon
         - dependees    -- list of Dependency instances describing what other
                           projects depend on this project
         - commands     -- ordered list of Commands instances that need to be
                           executed to build this project
-        - homedir      -- None or a ResolvablePath (outputs are relative to this)
         - outputs      -- list of Output instances describing what results a
                           build of this project results in
-        - workitems    -- list of WorkItem instances describing what directories/files
-                          are used during the build of this project.
     """
     #TODO nice string representations of the entire model
     #def __str__(self):
     #    return "<Project: %s>" % self.name
 
-    def __init__(self, module, name, path="."):
+    def __init__(self, module, name, path=".", homedir="."):
         assert isinstance(module, Module)
         assert isinstance(name, basestring)
         
         self.module = module
         self.name   = name
         self.path   = path
-        self.homedir = None
+        self.homedir = homedir
         
         self.dependencies=[]
         self.dependees=[]
         self.commands=[]
         self.outputs=[]
-        self.workitems=[]
     
     def add_dependency(self, relationship):
         assert isinstance(relationship, Dependency)
@@ -388,10 +387,6 @@
     def add_output(self, output):
         assert isinstance(output, Output)
         self.outputs.append(output)
-        
-    def add_work(self,work):
-        assert isinstance(work,WorkItem)
-        selfd.works.append(work)
 
 DEPENDENCY_INHERIT_NONE          = "none"
 DEPENDENCY_INHERIT_RUNTIME       = "runtime"
@@ -570,43 +565,6 @@
 
 #TODO: more Commands
 
-class RelativePath(ModelObject):
-    def __init__(self,model,path):
-        assert isinstance(model, ModelObject)
-        assert isinstance(path, basestring)
-        self.model = model
-        self.path  = path
-        
-    def resolve(self,workdir):
-        from gump.model.util import get_module_directory,get_project_directory
-        if isinstance(self.model,Module):
-            base=get_module_directory(workdir,self.model)
-        elif isinstance(self.model,Project):
-            base=get_project_directory(workdir,self.model)
-        else:
-            pass #TODO Raise?
-        import os.path
-        return os.path.join(base,self.path)
-    
-    def __str__(self):
-        return "RelativePath:%s:%s" % (self.model,self.path)
-
-class WorkItem(ModelObject):
-    """Model a directory containing stuff that can be used by other projects.
-
-    Has the following properties:
-
-        - project -- the containing project.
-        - path -- the path to the directory or file.
-    """
-    def __init__(self, project, path):
-        assert isinstance(path, RelativePath)
-        self.project = project
-        self.path = path
-    
-    def __str__(self):
-        return "<WorkItem:%s>" % (self.path)
-
 class Output(ModelObject):
     """Model an output, something a successful project build will yield.
 
@@ -626,18 +584,35 @@
     def __str__(self):
         return "<Output:%s>" % self.id
     
+class Classdir(Output):
+    """Model a directory containing java classes that can be used by other projects.
+
+    Has the following properties:
+
+        - all the properties an Output has except for an 'id'
+        - project -- the containing project.
+        - path -- the *absolute* path to the directory or file.
+    """
+    def __init__(self, project, path):
+        assert isinstance(path, basestring)
+        Output.__init__(self, project)
+        self.path = path
+    
+    def __str__(self):
+        return "<Classdir:%s>" % (self.path)
+
 class Jar(Output):
     """Model a java archive that can be used by other projects.
 
     Has the following properties:
 
         - all the properties an Output has
-        - name -- the path to the jar relative to the project is home
+        - name -- the path to the jar relative to the project its home
                 directory.
         - add_to_bootclass_path -- flag specifying if this jar should be
-                added 
+                added to the bootclasspath
     """
-    def __init__(self, project, name, id = None, add_to_bootclass_path = False ):
+    def __init__(self, project, name, id = None, add_to_bootclass_path = False):
         assert isinstance(name, basestring)
         Output.__init__(self, project, id)
         self.name = name

Modified: gump/branches/Gump3/pygump/python/gump/model/util.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/util.py?rev=209309&r1=209308&r2=209309&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/util.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/util.py Tue Jul  5 12:36:32 2005
@@ -21,12 +21,22 @@
 
 from os.path import abspath
 from os.path import join
+import os
+
+from gump.model import ModelObject, Error, Dependency, CvsModule, SvnModule, ExceptionInfo,
Classdir, Jar
 
-from gump.model import ModelObject, Error, Dependency, CvsModule, SvnModule, ExceptionInfo
 
 UPDATE_TYPE_CHECKOUT="checkout"
 UPDATE_TYPE_UPDATE="update"
 
+def get_jar_path(workdir, jar):
+    """Determine the path to a Jar."""
+    return join(get_project_home_directory(workdir, jar.project),jar.name)
+
+def get_project_home_directory(workdir, project):
+    """Determine the home directory for a project."""
+    return join(get_project_directory(workdir, project),project.homedir)
+
 def get_project_directory(workdir, project):
     """Determine the base directory for a project."""
     return join(get_module_directory(workdir, project.module),project.path)
@@ -157,3 +167,79 @@
     if not hasattr(model_object, 'exceptions'):
         model_object.exceptions = []
     model_object.exceptions.append(ExceptionInfo(type, value, traceback))
+
+        
+def calculate_classpath(workdir, project, recurse=True, runtimeonly=False):
+    """This ugly beast of a method looks at a project and its dependencies and
+    builds a classpath and a bootclasspath based on its <work/> directives
+    and its <depend/> directives."""
+    classpath = []
+    bootclasspath = []
+
+    # Ant requires to be told about a compiler
+    if os.environ.has_key('JAVA_HOME'):
+        classpath.append(os.path.join(os.environ['JAVA_HOME'],'lib','tools.jar'))
+    
+    # Any internal build outputs
+    for classdir in [output for output in project.outputs if isinstance(output, Classdir)]:
+        classpath.append(classdir.path)
+    
+    # Build outputs from dependencies
+    for relationship in project.dependencies:
+        dependency = relationship.dependency
+        
+        # keep track of visited outputs so we don't
+        # process them twice
+        visited_outputs = []
+        
+        for info in relationship.dependencyInfo:
+            if runtimeonly and not info.runtime:
+                continue
+
+            filter_by_id = info.specific_output_ids and len(info.specific_output_ids) >
0
+        
+            for output in [o for o in dependency.outputs if o not in visited_outputs]:
+                visited_outputs.append(o)
+                
+                # exclude unspecified outputs
+                if filter_by_id and not output.id in info.specific_output_ids:
+                        continue
+
+                # calculate path to this output
+                path = None
+                if isinstance(output, Classdir):
+                    path = output.path
+                if isinstance(output, Jar):
+                    path = get_jar_path(workdir,output)
+                
+                # actually add the path
+                if output.add_to_bootclass_path:
+                    bootclasspath.append(path)
+                else:
+                    classpath.append(path)
+                    
+                # now the fun begins. If we're doing inheritance, we're
+                # going to recurse. If we're not doing "jars" or "outputs"
+                # inheritance, we're going to do it once. Otherwise, we'll
+                # keep doing it until we're no longer doing "jars"
+                # inheritance. Sheesh!
+                # Oh, and finally, there's another special case for inheriting
+                # only the "runtime" dependencies.
+                if recurse:
+                    if info.inherit == DEPENDENCY_INHERIT_ALL or info.inherit == DEPENDENCY_INHERIT_HARD:
+                        (inheritedclasspath, inheritedbootclasspath) = get_classpath(workdir,
dependency, recurse=False)
+                        classpath.extend(inheritedclasspath)
+                        bootclasspath.extend(inheritedbootclasspath)
+                    
+                    if info.inherit == DEPENDENCY_INHERIT_JARS:
+                        (inheritedclasspath, inheritedbootclasspath) = get_classpath(workdir,
dependency, recurse=True)
+                        classpath.extend(inheritedclasspath)
+                        bootclasspath.extend(inheritedbootclasspath)
+                    
+                    if info.inherit == DEPENDENCY_INHERIT_RUNTIME:
+                        (inheritedclasspath, inheritedbootclasspath) = get_classpath(workdir,
dependency, recurse=False, runtimeonly=True)
+                        classpath.extend(inheritedclasspath)
+                        bootclasspath.extend(inheritedbootclasspath)
+                        
+    
+    return (classpath, bootclasspath)
\ No newline at end of file

Modified: gump/branches/Gump3/pygump/python/gump/plugins/builder.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/builder.py?rev=209309&r1=209308&r2=209309&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/builder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/builder.py Tue Jul  5 12:36:32 2005
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+"""Provides an abstract plugin for Command processing with subclasses."""
+
 __copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
@@ -27,32 +29,36 @@
 from gump.util.executor import Popen, PIPE, STDOUT
 
 class BuilderPlugin(AbstractPlugin):
-    """Execute all commands for all projects."""
+    """Abstract class for creating plugins that handle the execution of Commands.
+
+    To create a subclass, override __init__, then call it from the subclass with
+    the method to call."""
     def __init__(self, workdir, log, cmd_clazz, method):
+        """Create a new builder. Arguments:
+        
+          -- workdir = the directory in which to perform the command
+          -- log = the Logger instance for debugging
+          -- cmd_clazz = the Command subclass the plugin handles
+          -- method = the python method (which must be a class method on
+             the subclass) to call. It will be provided with a Project
+             instance and with the relevant Command instance to process"""
         self.workdir = workdir
         self.log = log
         self.cmd_clazz = cmd_clazz
         self.method = method             
 
     def visit_project(self, project):
-        """ Dispatch for each matching command (matching by class type) """        
+        """Dispatch for each matching command (matching by class type) """        
         assert isinstance(project, Project)
         self.log.debug("Visit %s looking for %s" % (project,self.cmd_clazz))
         for command in [command for command in project.commands if isinstance(command,self.cmd_clazz)]:
-            try:        
-                self.log.debug("Perform %s on %s" % (command, project))
-                self.method(project, command)
-            except Exception:
-                self.log.exception("Command %s Failed..." % (command))
-                #TODO Ought we create a BuilderErrorHandler for this?
-                # Annotate failure
-                # command.build_log = ':TODO: Serialize Exception trace into here?';
-                command.build_exit_status=1
+            self.log.debug("Perform %s on %s" % (command, project))
+            self.method(project, command)
             
 class ScriptBuilderPlugin(BuilderPlugin):
     """Execute all "script" commands for all projects."""
     def __init__(self, workdir, log):
-        BuilderPlugin.__init__( self, workdir, log, Script, self._do_script)  
+        BuilderPlugin.__init__(self, workdir, log, Script, self._do_script)  
         
     def _do_script(self, project, script):
         # NOTE: no support for basedir="", an undocumented feature in gump2        

Modified: gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py?rev=209309&r1=209308&r2=209309&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py Tue Jul  5 12:36:32 2005
@@ -17,215 +17,29 @@
 __copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
+"""Provides plugins for handling java-based Commands such as <ant/>."""
+
 import os
 import sys
 from os.path import abspath, join, isfile
 
-from gump.model import Script, Error, Project, Ant, Dependency, WorkItem, Jar
-from gump.model.util import get_project_directory,get_module_directory
+from gump.model import Script, Error, Project, Ant, Dependency, Classdir, Jar, DEPENDENCY_INHERIT_ALL,
DEPENDENCY_INHERIT_HARD, DEPENDENCY_INHERIT_JARS
+from gump.model.util import get_project_directory,get_module_directory,get_jar_path,calculate_classpath
 from gump.plugins import AbstractPlugin
 from gump.plugins.builder import BuilderPlugin
 from gump.util.executor import Popen, PIPE, STDOUT
 
 
-
-class ArtifactPath(object):
-    """
-    Represents an artifact within a path
-    
-    Has the following properties:
-
-        - id -- the identifier for this artifact path.
-        - path -- the path to the file.
-        - description -- the description of this artifact path"""
-    def __init__(self,id,path,description=None):
-        self.id=id
-        self.path = path
-        self.description=description
-        
-    def __eq__(self,other):
-        return (self.path == other.path)
-    
-    def __str__(self):
-        return self.path
-        
-class Classpath(object):
-    """Represents a list of artifacts
-
-    Has the following properties:
-        
-        - id -- identifier
-        - parts -- an array of ArtifactPath objects
-        - state -- state of Artifacts:
-                    unknown
-                    complete
-                    stale (some from repository)
-                    incomplete (some missing)"""
-    def __init__(self, id):
-        self.id = id
-        self.parts = []
-        self.state='unknown'
-    
-    def __nonzero__(self) :
-        if self.parts: return True
-        return False
-    
-    def __len__(self):
-        return len(self.parts)
-    
-    def __add__(self,other):
-        if not isinstance(other,ArtifactPath):
-             other=ArtifactPath("Unknown",other,"Unspecified")
-        if not other in self.parts:
-            self.parts.append(other)
-        return self
-    
-    def __str__(self):
-        return self.join(os.pathsep)
-    
-    def join(self,sep):
-        import string
-        return string.join([ part.path for part in self.parts ], sep)
-    
 class ClasspathPlugin(BuilderPlugin):
-    """Generate build attributes (e.g. CLASSAPATH) for a builder."""
+    """Generate the java build attributes (e.g. CLASSPATH) for the Ant command."""
     def __init__(self, workdir, log):
-        BuilderPlugin.__init__(self, workdir, log, Ant, self._forge_classpaths)
-        
-    def _forge_classpaths(self, project, ant):               
-
-        # Stub them out...
-        ant.classpath=Classpath('Standard')
-        ant.boot_classpath=Classpath('Boot')
-        
-        # Flesh them out...
-        self._calculateClasspaths(project,ant)
-
-    def _calculateClasspaths(self, project, ant):
-        """Generate the classpath lists"""
-        #TODO This ought be under "java & Ant" not under "Ant".        
-
-        # Ant requires to be told about a compiler, so (for now)
-        # we'll hardcode CLASSPATH to add $JAVA_HOME/lib/tools.jar
-        # IFF $JAVA_HOME exists.
-        if os.environ.has_key('JAVA_HOME'):
-            ant.classpath += ArtifactPath('Java Tools (e.g. Compiler)',os.path.join(os.environ['JAVA_HOME'],'lib','tools.jar'))
+        BuilderPlugin.__init__(self, workdir, log, Ant, self.set_classpath)
         
-        # Any internal build artifacts
-        for work in project.workitems:
-            ant.classpath += ArtifactPath(work.name,output.path.resolve(self.workdir)) 
-            
-        # Recurse into dependencies
-        visited=[]
-        for dependency in project.dependencies:
-            self._calculateDependencyContributions(ant,dependency,1,visited)
-            
-    def _calculateDependencyContributions(self,ant,dependency,depth,visited):        
-        assert isinstance(dependency, Dependency)
-        
-        #TODO Check NO_CLASSPATH if dependency.dependencyInfo
-        if dependency in visited: return
-
-        # Access the players
-        project=dependency.dependency
-        projectpath=get_project_directory(self.workdir,project)
-        if project.homedir:
-            projectpath = project.homedir.resolve(self.workdir)
-        self.log.debug('Project HomeDir : %s' % projectpath)
-        
-        #TODO Do we need a filter here? Are all dependency infos
-        # appropriate, or not?
-        for info in [info for info in dependency.dependencyInfo]:           
-                    
-            # The dependency drivers...
-            #
-            # runtime (i.e. this is a runtime dependency)
-            # inherit (i.e. inherit stuff from a dependency)
-            # ids (i.e. what output ids to select)
-            #
-            runtime=info.runtime
-            inherit=info.inherit
-            ids=info.specific_output_ids
-      
-            # Explain..
-            depend_str=''
-            if inherit: 
-                if depend_str: depend_str += ', '
-                depend_str += 'Inherit:'+dependency.inherit
-            if runtime: 
-                if depend_str: depend_str += ', '
-                depend_str += 'Runtime'
-            
-            # Append Outputs for this project
-            #    (respect ids --- none means 'all)
-            project_ids=[]
-            for output in project.outputs:
-                # Store for double checking
-                if output.id: project_ids.append(output.id)
+    def set_classpath(self, project, command):
+        (classpath, bootclasspath) = calculate_classpath(self.workdir, project)
+        command.classpath = classpath
+        command.boot_classpath = bootclasspath
                 
-                # If 'all' or in ids list:
-                if (not ids) or (output.id in ids):   
-                    if ids: depend_str += ' ID = ' + output.id
-                    
-                    if isinstance(output,Jar):
-                        path = os.path.join(projectpath,output.name)
-                    else:
-                        raise Error, "Unknown Output Type for %s: %s" % (self.__class__.__name__,
output.__class__.__name__)
-
-                    artifact_path=ArtifactPath(output.id,path,depend_str) 
-                    self.log.debug('Contribution : %s' % artifact_path)
-                    
-                    # Add to CLASSPATH (or BOOTCLASSPATH)
-                    if not isinstance(output,Jar) or not output.add_to_bootclass_path:
-                        ant.classpath += artifact_path
-                    else:
-                        ant.boot_classpath += artifact_path
-
-        # Double check IDs (to reduce stale IDs in metadata)
-        if ids:
-            for id in ids:
-                if not id in project_ids:
-                    self.log.warn("Invalid ID [" + id + "] for dependency on [" + project.name
+ "]")
-
-        visited.append(dependency)  
-        
-        # Append sub-projects outputs, if inherited
-        for subdependency in project.dependencies:        
-            #
-            # 	For the main project we working on, we care about it's request for inheritence
-            #	but we don't recursively inherit. (i.e. we only do this at recursion depth
1).
-            #
-            #   If the dependency is set to 'all' (or 'hard') we inherit all dependencies.
-            # 	If the dependency is set to 'runtime' we inherit all runtime dependencies.
-            #
-            #	INHERIT_OUTPUTS (aka INHERIT_JARS) is more sticky, and we track that down (and
down, ...).
-            #
-            for subinfo in subdependency.dependencyInfo:
-                if   (  ( ( 1 == depth ) and \
-                        (inherit in [ 'all', 'hard' ]) \
-                    or \
-                          (inherit == 'runtime' and subdependency.isRuntime()) ) \
-                    or \
-                        ( inherit in [ 'outputs' ] ) ) :      
-                    self._calculateDependencyContributions(ant,subdependency,depth+1,visited)
-                    
-        
-class ArtifactPlugin(BuilderPlugin):
-    """Resolve all entries in the CLASSPATH|BOOT_CLASSPATH checking for existence. 
-    When absent see if recent copies can be acquired from a repository."""
-    def __init__(self,workdir, log):
-        BuilderPlugin.__init__(self, workdir, log, Ant, self._resolve_classpaths)
-        
-    def _resolve_classpaths(self, project, ant):                   
-        
-        self._resolve_classpath(ant.classpath)
-        self._resolve_classpath(ant.boot_classpath)
-        
-    def _resolve_classpath(classpath):        
-        for artifact_path in ant.classpath:
-            if not os.path.exists(artifact_path.path):
-                #TODO Go find from Repository...
-                classpath.state='incomplete'
         
 class AntPlugin(BuilderPlugin):
     """Execute all "ant" commands for all projects."""
@@ -239,8 +53,6 @@
     def _do_ant(self, project, ant):                
         projectpath = get_project_directory(self.workdir,project)
         
-        
-        #TODO get proper classpath
         self.log.debug('CLASSPATH %s' % ant.classpath)
         self.log.debug('BOOTCLASSPATH %s' % ant.boot_classpath)
         



Mime
View raw message