gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r170842 - in /gump/branches/Gump3/pygump/python/gump: engine/objectifier.py model/__init__.py plugins/java/builder.py test/testModel.py
Date Wed, 18 May 2005 23:26:27 GMT
Author: ajack
Date: Wed May 18 16:26:26 2005
New Revision: 170842

URL: http://svn.apache.org/viewcvs?rev=170842&view=rev
Log:
1) Removed Homedir, since <home> isn't an output.
2) Added WorkItem and ResolvablePath.
3) Added project.homedir - a ResolvablePath.
4) Resolve outputs relative to the homedir.
5) Zapped some tests.

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

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=170842&r1=170841&r2=170842&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/objectifier.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/objectifier.py Wed May 18 16:26:26 2005
@@ -27,6 +27,7 @@
 from xml.dom import minidom
 
 from gump.model import *
+from gump.model.util import *
 
 from gump.engine import EngineError
 from gump.engine.modeller import _find_element_text
@@ -216,20 +217,41 @@
         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
+    works = project_definition.getElementsByTagName("work")
+    for work in works:
+        project.add_output(WorkItem(project,_extract_relative_item(project,work)))
 
-def _create_outputs(project, project_definition):
+    # Home Directory (outputs are relative to this)
     homes = project_definition.getElementsByTagName("home")
     if homes.length > 0:
-        home = homes.item(0).getAttribute("directory")
-        project.add_output(Homedir(project,home))
+        project.homedir = _extract_relative_item(project,homes.item(0))
     
+    # Outputs
     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))
-        
+    
     #TODO more outputs
 
 
@@ -384,7 +406,7 @@
             workspace.projects[project.name] = project
 
             _create_commands(project, project_definition)
-            _create_outputs(project, project_definition)
+            _create_artifacts(project, project_definition)
 
         # wire up dependencies only after projects have been created
         for project_definition in project_definitions:

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=170842&r1=170841&r2=170842&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Wed May 18 16:26:26 2005
@@ -19,6 +19,7 @@
 __copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
+        
 class Error(Exception):
     """Generic error thrown for all internal model module exceptions."""
     pass
@@ -270,8 +271,11 @@
                           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):
@@ -284,11 +288,13 @@
         self.module = module
         self.name   = name
         self.path   = path
+        self.homedir = None
         
         self.dependencies=[]
         self.dependees=[]
         self.commands=[]
         self.outputs=[]
+        self.workitems=[]
     
     def add_dependency(self, relationship):
         assert isinstance(relationship, Dependency)
@@ -336,6 +342,10 @@
     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"
@@ -514,7 +524,42 @@
 
 #TODO: more Commands
 
-OUTPUT_ID_HOME = "homedir"
+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.
@@ -534,24 +579,7 @@
     
     def __str__(self):
         return "<Output:%s>" % self.id
-
-class Homedir(Output):
-    """Model a directory containing stuff that can be used by other projects.
-
-    Has the following properties:
-
-        - all the properties an Output has
-        - directory -- the directory that should be exported as this project
-                       its homedirectory
-    """
-    def __init__(self, project, directory):
-        assert isinstance(directory, basestring)
-        Output.__init__(self, project, OUTPUT_ID_HOME)
-        self.directory = directory
     
-    def __str__(self):
-        return "<Homedir:%s>" % self.directory
-
 class Jar(Output):
     """Model a java archive that can be used by other projects.
 

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=170842&r1=170841&r2=170842&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py Wed May 18 16:26:26 2005
@@ -21,8 +21,8 @@
 import sys
 from os.path import abspath, join, isfile
 
-from gump.model import Script, Error, Project, Ant, Dependency, Homedir, Jar
-from gump.model.util import get_project_directory
+from gump.model import Script, Error, Project, Ant, Dependency, WorkItem, Jar
+from gump.model.util import get_project_directory,get_module_directory
 from gump.plugins import AbstractPlugin
 from gump.plugins.builder import BuilderPlugin
 from gump.util.executor import Popen, PIPE, STDOUT
@@ -97,9 +97,11 @@
     def _calculateClasspaths(self, project, ant):
         """Generate the classpath lists"""
         #TODO This ought be under "java" not under "Ant".        
-        
-        #TODO Need "<work> elements
-        
+
+        # Any internal build artifacts
+        for work in project.workitems:
+            self.classpath += ArtifactPath(work.name,output.path.resolve(self.workdir)) 
+            
         # Recurse into dependencies
         visited=[]
         for dependency in project.dependencies:
@@ -113,7 +115,10 @@
 
         # Access the players
         project=dependency.dependency
-        projectpath = get_project_directory(self.workdir,project)
+        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?
@@ -149,16 +154,14 @@
                 if (not ids) or (output.id in ids):   
                     if ids: depend_str += ' ID = ' + output.id
                     
-                    if isinstance(output,Homedir):
-                        path = os.path.join(projectpath,output.directory)
-                    elif isinstance(output,Jar):
+                    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__)
 
-                    self.log.debug('Contribution : %s' % path)
                     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
@@ -200,9 +203,7 @@
     def __init__(self,workdir, log):
         BuilderPlugin.__init__(self, workdir, log, Ant, self._resolve_classpaths)
         
-    def _resolve_classpaths(self, project, ant):           
-        
-        projectpath = get_project_directory(self.workdir,project)
+    def _resolve_classpaths(self, project, ant):                   
         
         self._resolve_classpath(ant.classpath)
         self._resolve_classpath(ant.boot_classpath)

Modified: gump/branches/Gump3/pygump/python/gump/test/testModel.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/test/testModel.py?rev=170842&r1=170841&r2=170842&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testModel.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testModel.py Wed May 18 16:26:26 2005
@@ -38,8 +38,7 @@
 from gump.model import Mkdir
 from gump.model import Rmdir
 from gump.model import Script
-from gump.model import Homedir
-from gump.model import OUTPUT_ID_HOME
+from gump.model import WorkItem
 from gump.model import Jar
 
 class ModelTestCase(TestCase):
@@ -547,27 +546,7 @@
         o = Output(p)
         self.assertEqual(p,o.project)
         self.assertRaises(AssertionError,Output,None)
-        self.assertRaises(AssertionError,Output,"someproject")
-        
-    def test_homedir(self):
-        wname = "blah"
-        w = Workspace(wname)
-        rname = "booh"
-        r = Repository(w,rname)
-        mname = "bweh"
-        m = Module(r,mname)
-        pname = "bwop"
-        p = Project(m,pname)
-        
-        dir = "some/dir"
-        o = Homedir(p,dir)
-        self.assertEqual(p,o.project)
-        self.assertEqual(dir,o.directory)
-        self.assertEqual(OUTPUT_ID_HOME,o.id)
-        self.assertRaises(AssertionError,Homedir,None,dir)
-        self.assertRaises(AssertionError,Homedir,"someproject",dir)
-        self.assertRaises(AssertionError,Homedir,p,None)
-        self.assertRaises(AssertionError,Homedir,p,p)
+        self.assertRaises(AssertionError,Output,"someproject")           
         
     def test_jar(self):
         wname = "blah"



Mime
View raw message