gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r164531 - in /gump/branches/Gump3/pygump: gump.log.config python/gump/config.py python/gump/engine/modeller.py python/gump/engine/walker.py python/gump/model/__init__.py python/gump/plugins/__init__.py python/gump/plugins/builder.py python/gump/test/testPluginBuilder.py
Date Mon, 25 Apr 2005 03:20:51 GMT
Author: ajack
Date: Sun Apr 24 20:20:50 2005
New Revision: 164531

URL: http://svn.apache.org/viewcvs?rev=164531&view=rev
Log:
Some preliminary work on ClasspathPlugin and AntPlugin.
- 1 unit test fails, but for same reason as before the changes (see e-mail to list)

Modified:
    gump/branches/Gump3/pygump/gump.log.config
    gump/branches/Gump3/pygump/python/gump/config.py
    gump/branches/Gump3/pygump/python/gump/engine/modeller.py
    gump/branches/Gump3/pygump/python/gump/engine/walker.py
    gump/branches/Gump3/pygump/python/gump/model/__init__.py
    gump/branches/Gump3/pygump/python/gump/plugins/__init__.py
    gump/branches/Gump3/pygump/python/gump/plugins/builder.py
    gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py

Modified: gump/branches/Gump3/pygump/gump.log.config
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/gump.log.config?rev=164531&r1=164530&r2=164531&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/gump.log.config (original)
+++ gump/branches/Gump3/pygump/gump.log.config Sun Apr 24 20:20:50 2005
@@ -55,6 +55,12 @@
 propagate=0
 qualname=plugin.logger
 
+[logger_plugin_builder]
+level=DEBUG
+handlers=stdout,filehandler
+propagate=0
+qualname=plugin.builder
+
 [handler_stdout]
 level=DEBUG
 class=StreamHandler

Modified: gump/branches/Gump3/pygump/python/gump/config.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/config.py?rev=164531&r1=164530&r2=164531&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/config.py (original)
+++ gump/branches/Gump3/pygump/python/gump/config.py Sun Apr 24 20:20:50 2005
@@ -113,15 +113,22 @@
 
     from gump.plugins import LoggingPlugin
 
+    
     # by contract, rmdir always needs to go before mkdir!
     from gump.plugins.dirbuilder import RmdirBuilderPlugin
     plugins.append(RmdirBuilderPlugin(config.paths_work))
     from gump.plugins.dirbuilder import MkdirBuilderPlugin
     plugins.append(MkdirBuilderPlugin(config.paths_work))
     
+    buildlog = get_logger(config, "plugin.builder")
+    
     from gump.plugins.builder import ScriptBuilderPlugin
-    plugins.append(ScriptBuilderPlugin(config.paths_work))
-
+    plugins.append(ScriptBuilderPlugin(config.paths_work,buildlog))
+    from gump.plugins.java.builder import ClasspathPlugin
+    plugins.append(ClasspathPlugin(config.paths_work,buildlog))
+    from gump.plugins.java.builder import AntPlugin
+    plugins.append(AntPlugin(config.paths_work,buildlog))
+    
     post_process_plugins = []
     # TODO: append more plugins here...
     post_process_plugins.append(TimerPlugin("run_end"))
@@ -137,9 +144,9 @@
         from gump.plugins.logreporter import LogReporterPlugin
         post_process_plugins.append(LogReporterPlugin(reportlog))
 
-    for plugin in pre_process_plugins: log.debug("Pre : %s " % plugin)
-    for plugin in plugins: log.debug("Proc: %s " % plugin)
-    for plugin in post_process_plugins: log.debug("Post: %s " % plugin)
+    for plugin in pre_process_plugins: log.debug("Preprocessor : %s " % `plugin`)
+    for plugin in plugins: log.debug("Processor    : %s " % `plugin`)
+    for plugin in post_process_plugins: log.debug("Postprocessor: %s " % `plugin`)
 
     return (pre_process_plugins, plugins, post_process_plugins)
 

Modified: gump/branches/Gump3/pygump/python/gump/engine/modeller.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/modeller.py?rev=164531&r1=164530&r2=164531&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/modeller.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/modeller.py Sun Apr 24 20:20:50 2005
@@ -961,6 +961,16 @@
                 args.append((name, value))
                 
             project.add_command(Script(project, name, args))
+            
+        ants = project_definition.getElementsByTagName("ant")
+        for cmd in ants:
+            name = cmd.getAttribute("name")
+            buildfile = cmd.getAttribute("target")
+            target = cmd.getAttribute("target")
+                
+            project.add_command(Ant(project, name, target, buildfile))
+            
+            #TODO 
         
         #TODO more commands
     
@@ -999,12 +1009,18 @@
         except KeyError:
             # we store the name instead. a Verifier should be used later to
             # fix this error.
+            #TODO get_dependency_on_project (below) asserts this is a
+            # Project not a string, causing a big KABOOM!...
             dependency_project = dependency_name
         
-        id = dependency.getAttribute("id")
+        idList = dependency.getAttribute("ids")
+        if idList:
+            ids=idList.split(' ')        
+        else:
+            ids=[]
         
         relationship = project.get_dependency_on_project(dependency_project)
-        relationship.add_dependency_info(DependencyInfo(relationship,optional,runtime,inherit,id))
+        relationship.add_dependency_info(DependencyInfo(relationship,optional,runtime,inherit,ids))
 
 
 class VerificationError(ModellerError):

Modified: gump/branches/Gump3/pygump/python/gump/engine/walker.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/walker.py?rev=164531&r1=164530&r2=164531&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/walker.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/walker.py Sun Apr 24 20:20:50 2005
@@ -52,17 +52,23 @@
         visited_projects = []
 
         visitor._initialize()
+        
+        self.log.debug('Visit W/S : ' + `workspace`)
         visitor._visit_workspace(workspace)
         list = self._topsort_projects(workspace)
         
         for project in list:
             if not project.module in visited_modules:
                 if not project.module.repository in visited_repositories:
+                    self.log.debug('Visit Repo : ' + `project.module.repository`)
                     visitor._visit_repository(project.module.repository)
                     visited_repositories.append(project.module.repository)
+                    
+                self.log.debug('Visit Module : ' + `project.module`)
                 visitor._visit_module(project.module)
                 visited_modules.append(project.module)
             
+            self.log.debug('Visit Project : ' + `project`)
             visitor._visit_project(project)
             visited_projects.append(project)
         

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=164531&r1=164530&r2=164531&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Sun Apr 24 20:20:50 2005
@@ -385,7 +385,7 @@
                         dependency at runtime or just for building
         - inherit    -- option dictating whether this dependency should
                         "cascade" or "propagate in some form
-        - specific_output_id -- option that specifies one output ID from
+        - specific_output_ids -- option that specifies output IDs from
                         the specified project that is depended on
     """
     def __init__(self,
@@ -393,13 +393,13 @@
                  optional = False,
                  runtime  = False,
                  inherit  = DEPENDENCY_INHERIT_NONE,
-                 specific_output_id = None):
+                 specific_output_ids = None):
         assert isinstance(dependency, Dependency)
-        self.dependency         = dependency
-        self.optional           = optional
-        self.runtime            = runtime
-        self.inherit            = inherit
-        self.specific_output_id = specific_output_id
+        self.dependency          = dependency
+        self.optional            = optional
+        self.runtime             = runtime
+        self.inherit             = inherit
+        self.specific_output_ids = specific_output_ids
 
 class Command(ModelObject):
     """Model a command.
@@ -413,8 +413,7 @@
     def __init__(self, project):
         assert isinstance(project, Project)
         self.project = project
-    pass
-
+        
 class Mkdir(Command):
     """Model a mkdir command.
     
@@ -467,6 +466,25 @@
         self.name = name
         self.args = args
 
+class Ant(Command):
+    """Command to run an Ant build.
+
+    Has the following properties:
+        
+        - all the properties a Command has
+        - name -- the name of the script to run
+        - target -- the Ant target
+        - buildfile -- the Ant build file
+    """
+    def __init__(self, project, name, target, buildfile):
+        assert isinstance(name, basestring)
+        assert isinstance(target, basestring)
+        assert isinstance(buildfile, basestring)
+        Command.__init__(self, project)
+        self.name = name
+        self.target = target
+        self.buildfile = buildfile
+
 #TODO: more Commands
 
 OUTPUT_ID_HOME = "homedir"
@@ -516,6 +534,6 @@
         assert isinstance(name, basestring)
         Output.__init__(self, project, id)
         self.name = name
-        self.add_to_bootclass_path = add_to_bootclass_path
+        self.add_to_bootclass_path = add_to_bootclass_path      
 
 #TODO: more outputs

Modified: gump/branches/Gump3/pygump/python/gump/plugins/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/__init__.py?rev=164531&r1=164530&r2=164531&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/__init__.py Sun Apr 24 20:20:50 2005
@@ -154,6 +154,9 @@
         if not callable(self.finalize): return        
         self.finalize()
     
+    def __str__(self):
+        return self.__class__.__name__
+    
 class MulticastPlugin(AbstractPlugin):
     """Core plugin that redirects visit_XXX calls to other plugins."""
     def __init__(self, plugin_list, error_handler=BaseErrorHandler()):

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=164531&r1=164530&r2=164531&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/builder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/builder.py Sun Apr 24 20:20:50 2005
@@ -21,34 +21,38 @@
 import sys
 from os.path import abspath, join, isfile
 
-from gump.model import Script, Error
+from gump.model import Script, Error, Project, Ant, Dependency
 from gump.model.util import get_project_directory
 from gump.plugins import AbstractPlugin
 from gump.util.executor import Popen, PIPE, STDOUT
 
-
 class BuilderPlugin(AbstractPlugin):
     """Execute all commands for all projects."""
-    def __init__(self, workdir, cmd_clazz, method):
+    def __init__(self, workdir, log, cmd_clazz, method):
         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:
+            try:        
+                self.log.debug("Perform %s on %s" % (command, project))
                 self.method(project, command)
-            except:
-                pass # :TODO: Short term
+            except Exception:
+                self.log.exception("Failed...")
 
 class ScriptBuilderPlugin(BuilderPlugin):
     """Execute all "script" commands for all projects."""
-    def __init__(self, workdir):
-        BuilderPlugin.__init__( self, workdir, Script, self._do_script)  
+    def __init__(self, workdir, log):
+        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
+        # NOTE: no support for basedir="", an undocumented feature in gump2        
+        assert isinstance(project, Project)
         projectpath = get_project_directory(self.workdir,project)
         
         scriptfile = abspath(join(projectpath, script.name))
@@ -69,19 +73,3 @@
         script.build_log = cmd.communicate()[0]
         script.build_exit_status = cmd.wait()
 
-
-class AntBuilderPlugin(BuilderPlugin):
-    """Execute all "ant" commands for all projects."""
-    def __init__(self, workdir):
-        BuilderPlugin.__init__(self, workdir, Ant, self._do_ant)
-        
-    def _do_ant(self, project, ant):
-        # NOTE: no support for basedir="", an undocumented feature in gump2
-        projectpath = get_project_directory(self.workdir,project)
-        
-        buildfile = abspath(join(projectpath, script.name))        
-        
-        # :TODO:
-        import pprint
-        pprint.pprint(project)
-        pprint.pprint(ant)

Modified: gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py?rev=164531&r1=164530&r2=164531&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py Sun Apr 24 20:20:50 2005
@@ -29,12 +29,13 @@
 from os.path import isdir
 from os.path import join
 from shutil import rmtree
+from pmock import *
 
 from gump.plugins.builder import ScriptBuilderPlugin
 
 from gump.model import Workspace, Repository, Module, Project, Script, Error
 
-class BuilderTestCase(TestCase):
+class BuilderTestCase(MockTestCase):
     def test_do_script(self):
         basedir = abspath(mkdtemp())
         try:
@@ -55,7 +56,7 @@
             scriptfile.close()
             os.chmod(scriptpath, 0755)
 
-            plugin = ScriptBuilderPlugin(basedir)
+            plugin = ScriptBuilderPlugin(basedir, self.mock())
 
             cmd = Script(p, "dobuild")
             plugin._do_script(cmd.project, cmd)



Mime
View raw message