You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@gump.apache.org by aj...@apache.org on 2004/08/31 17:33:07 UTC
svn commit: rev 37254 - in gump/trunk/python: . gump/build gump/document/xdocs gump/java gump/language gump/model gump/run gump/runner gump/test
Author: ajack
Date: Tue Aug 31 08:33:05 2004
New Revision: 37254
Added:
gump/trunk/python/gump/build/nant.py
gump/trunk/python/gump/language/
- copied from rev 37209, gump/trunk/python/gump/java/
gump/trunk/python/gump/language/__init__.py
- copied unchanged from rev 37253, gump/trunk/python/gump/java/__init__.py
gump/trunk/python/gump/language/cp.py
- copied, changed from rev 37253, gump/trunk/python/gump/java/cp.py
gump/trunk/python/gump/language/java.py
- copied, changed from rev 37209, gump/trunk/python/gump/java/helper.py
Removed:
gump/trunk/python/gump/java/
gump/trunk/python/gump/language/helper.py
Modified:
gump/trunk/python/ (props changed)
gump/trunk/python/gump/build/builder.py
gump/trunk/python/gump/build/maven.py
gump/trunk/python/gump/document/xdocs/documenter.py
gump/trunk/python/gump/document/xdocs/resolver.py
gump/trunk/python/gump/model/builder.py
gump/trunk/python/gump/model/project.py
gump/trunk/python/gump/run/gumprun.py
gump/trunk/python/gump/runner/runner.py
gump/trunk/python/gump/test/language.py
gump/trunk/python/gump/test/maven.py
Log:
Partial NAnt commit, performed 'cos SVN disallows a dir rename followed by a file rename without a commit in between.
Modified: gump/trunk/python/gump/build/builder.py
==============================================================================
--- gump/trunk/python/gump/build/builder.py (original)
+++ gump/trunk/python/gump/build/builder.py Tue Aug 31 08:33:05 2004
@@ -47,6 +47,7 @@
from gump.build.script import ScriptBuilder
from gump.build.ant import AntBuilder
+from gump.build.nant import NAntBuilder
from gump.build.maven import MavenBuilder
from gump.utils import dump, display, getIndent, logResourceUtilization, \
@@ -66,8 +67,6 @@
import gump.integration.depot
-import gump.java.helper
-
###############################################################################
# Classes
@@ -79,6 +78,7 @@
gump.run.gumprun.RunSpecific.__init__(self,run)
self.ant=AntBuilder(run)
+ self.nant=NAntBuilder(run)
self.maven=MavenBuilder(run)
self.script=ScriptBuilder(run)
@@ -134,6 +134,8 @@
self.script.buildProject(project, languageHelper, stats)
elif project.hasAnt():
self.ant.buildProject(project, languageHelper, stats)
+ elif project.hasNAnt():
+ self.nant.buildProject(project, languageHelper, stats)
elif project.hasMaven():
self.maven.buildProject(project, languageHelper, stats)
@@ -495,6 +497,8 @@
self.script.preview(project, languageHelper, stats)
elif project.hasAnt():
self.ant.preview(project, languageHelper, stats)
+ elif project.hasNAnt():
+ self.nant.preview(project, languageHelper, stats)
elif project.hasMaven():
self.maven.preview(project, languageHelper, stats)
else:
Modified: gump/trunk/python/gump/build/maven.py
==============================================================================
--- gump/trunk/python/gump/build/maven.py (original)
+++ gump/trunk/python/gump/build/maven.py Tue Aug 31 08:33:05 2004
@@ -252,7 +252,7 @@
# :TODO: write...
for annotatedPath in classpath.getPathParts():
- if isinstance(annotatedPath,gump.java.cp.AnnotatedPath):
+ if isinstance(annotatedPath,gump.language.path.AnnotatedPath):
props.write(('# Contributor: %s\nmaven.jar.%s=%s\n') % \
( annotatedPath.getContributor(),
annotatedPath.getId(),
Added: gump/trunk/python/gump/build/nant.py
==============================================================================
--- (empty file)
+++ gump/trunk/python/gump/build/nant.py Tue Aug 31 08:33:05 2004
@@ -0,0 +1,187 @@
+#!/usr/bin/python
+
+
+# Copyright 2003-2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+__revision__ = "$Rev: 36667 $"
+__date__ = "$Date: 2004-08-20 08:55:45 -0600 (Fri, 20 Aug 2004) $"
+__copyright__ = "Copyright (c) 1999-2004 Apache Software Foundation"
+__license__ = "http://www.apache.org/licenses/LICENSE-2.0"
+
+
+"""
+ A NAnt builder (uses nant to build projects)
+"""
+
+import os.path
+import sys
+
+from gump import log
+from gump.run.gumprun import *
+from gump.core.config import dir, default, basicConfig
+
+import gump.build.builder
+
+from gump.utils.note import Annotatable
+from gump.utils.work import *
+
+from gump.utils.tools import *
+
+from gump.model.workspace import *
+from gump.model.module import Module
+from gump.model.project import Project
+from gump.model.depend import ProjectDependency
+from gump.model.stats import *
+from gump.model.state import *
+
+class NAntBuilder(gump.run.gumprun.RunSpecific):
+
+ def __init__(self,run):
+ """
+ The NAnt Builder is a Java Builder
+ """
+ gump.run.gumprun.RunSpecific.__init__(self,run)
+
+ def buildProject(self,project,language,stats):
+ """
+ Build a project using NAnt, based off the <nant metadata.
+
+ Note: switch on -verbose|-debug based of the stats for this
+ project, i.e. how long in a state of failure.
+ """
+
+ workspace=self.run.getWorkspace()
+
+ log.info('Run NAnt on Project: #[' + `project.getPosition()` + '] : ' + project.getName())
+
+ # Get the appropriate build command...
+ cmd=self.getNAntCommand(project, language, self.run.getEnvironment().getJavaCommand())
+
+ if cmd:
+ # Execute the command ....
+ cmdResult=execute(cmd,workspace.tmpdir)
+
+ # Update context with the fact that this work was done
+ work=CommandWorkItem(WORK_TYPE_BUILD,cmd,cmdResult)
+ project.performedWork(work)
+ project.setBuilt(1)
+
+ # Update context state based of the result
+ if not cmdResult.state==CMD_STATE_SUCCESS:
+ reason=REASON_BUILD_FAILED
+ if cmdResult.state==CMD_STATE_TIMED_OUT:
+ reason=REASON_BUILD_TIMEDOUT
+ project.changeState(STATE_FAILED,reason)
+ else:
+ # For now, things are going good...
+ project.changeState(STATE_SUCCESS)
+
+ def getNAntCommand(self,project,language):
+ """
+ Build an ANT command for this project, based on the <nant metadata
+ select targets and build files as appropriate.
+ """
+
+ # The original model information...
+ nant=project.nant
+ # The nant target (or none == nant default target)
+ target= nant.getTarget()
+
+ # The nant build file (or none == build.xml)
+ buildfile = nant.getBuildFile()
+
+ # Optional 'verbose' or 'debug'
+ verbose=nant.isVerbose()
+ debug=nant.isDebug()
+
+ # Where to run this:
+ basedir = nant.getBaseDirectory() or project.getBaseDirectory()
+
+ # Build a classpath (based upon dependencies)
+ #(classpath,bootclasspath)=language.getClasspaths(project)
+
+ # Get properties
+ properties=self.getNAntProperties(project)
+
+ # Get system properties
+ sysproperties=self.getNAntSysProperties(project)
+
+ # Run java on apache NAnt...
+ cmd=Cmd(javaCommand,'build_'+project.getModule().getName()+'_'+project.getName(),
+ basedir,{'CLASSPATH':classpath})
+
+ # These are workspace + project system properties
+ cmd.addNamedParameters(sysproperties)
+
+ # Add BOOTCLASSPATH
+ #if bootclasspath:
+ # cmd.addPrefixedParameter('-X','bootclasspath/p',bootclasspath,':')
+
+ # Get/set JVM properties
+ #jvmargs=language.getJVMArgs(project)
+ #if jvmargs:
+ # cmd.addParameters(jvmargs)
+
+ # The NAnt interface
+ cmd.addParameter('org.apache.tools.ant.Main')
+
+ # Allow ant-level debugging...
+ if project.getWorkspace().isDebug() or project.isDebug() or debug:
+ cmd.addParameter('-debug')
+ if project.getWorkspace().isVerbose() or project.isVerbose() or verbose:
+ cmd.addParameter('-verbose')
+
+ # Some builds might wish for this information
+ # :TODO: Grant greater access to Gump variables from
+ # within.
+ mergeFile=project.getWorkspace().getMergeFile()
+ if mergeFile:
+ cmd.addPrefixedParameter('-D','gump.merge',str(mergeFile),'=')
+
+ # These are from the project and/or workspace
+ # These are 'normal' properties.
+ cmd.addNamedParameters(properties)
+
+ # Pass the buildfile
+ if buildfile: cmd.addParameter('-f',buildfile)
+
+ # End with the target (or targets)...
+ if target:
+ for targetParam in target.split():
+ cmd.addParameter(targetParam)
+
+ return cmd
+
+ def getNAntProperties(self,project):
+ """ Get properties for a project """
+ properties=Parameters()
+ for property in project.getWorkspace().getProperties()+project.getNAnt().getProperties():
+ properties.addPrefixedNamedParameter('-D',property.name,property.value,'=')
+ return properties
+
+ def getNAntSysProperties(self,project):
+ """ Get sysproperties for a project """
+ properties=Parameters()
+ for property in project.getWorkspace().getSysProperties()+project.getNAnt().getSysProperties():
+ properties.addPrefixedNamedParameter('-D',property.name,property.value,'=')
+ return properties
+
+ def preview(self,project,language,stats):
+ """
+ Preview what an NAnt build would look like.
+ """
+ command=self.getNAntCommand(project,language)
+ command.dump()
+
\ No newline at end of file
Modified: gump/trunk/python/gump/document/xdocs/documenter.py
==============================================================================
--- gump/trunk/python/gump/document/xdocs/documenter.py (original)
+++ gump/trunk/python/gump/document/xdocs/documenter.py Tue Aug 31 08:33:05 2004
@@ -1810,6 +1810,9 @@
if project.hasAnt():
self.documentProperties(miscSection, project.getAnt(), 'Ant Properties')
+ elif project.hasNAnt():
+ self.documentProperties(miscSection, project.getNAnt(), 'NAnt Properties')
+ # :TODO: Maven?
javaHelper=self.run.getJavaHelper()
(classpath,bootclasspath)=javaHelper.getClasspathObjects(project)
@@ -1962,7 +1965,7 @@
pathTable=pathSection.createTable(['Path Entry','Contributor','Instigator','Id','Annotation'])
paths=0
for path in classpath.getPathParts():
- if isinstance(path,gump.java.cp.AnnotatedPath):
+ if isinstance(path,gump.language.path.AnnotatedPath):
pathStr=path.getPath()
contributor=path.getContributor()
instigator=path.getInstigator()
Modified: gump/trunk/python/gump/document/xdocs/resolver.py
==============================================================================
--- gump/trunk/python/gump/document/xdocs/resolver.py (original)
+++ gump/trunk/python/gump/document/xdocs/resolver.py Tue Aug 31 08:33:05 2004
@@ -42,7 +42,7 @@
from gump.model.workspace import Workspace
from gump.model.module import Module
from gump.model.project import Project
-from gump.model.builder import Ant,Maven,Script
+from gump.model.builder import Ant,NAnt,Maven,Script
from gump.model.object import *
from gump.model.state import *
@@ -181,6 +181,7 @@
isinstance(object, FileReference):
index=None
elif isinstance(object, Ant) or \
+ isinstance(object, NAnt) or \
isinstance(object, Maven) or \
isinstance(object, Script) :
index='Build'
Copied: gump/trunk/python/gump/language/cp.py (from rev 37253, gump/trunk/python/gump/java/cp.py)
==============================================================================
--- gump/trunk/python/gump/java/cp.py (original)
+++ gump/trunk/python/gump/language/cp.py Tue Aug 31 08:33:05 2004
@@ -16,7 +16,7 @@
"""
- Classpaths
+ Paths (e.g. Java Classpaths, CSharp Assembly Paths, etc.)
"""
@@ -88,7 +88,7 @@
def getPath(self):
return self.path
-class Classpath(Annotatable):
+class ArtifactPath(Annotatable):
def __init__(self,name):
Annotatable.__init__(self)
self.name=name
@@ -111,8 +111,8 @@
for part in split(parts,os.pathsep):
self.addPathPart(part)
- def importClasspath(self,cp):
- for part in cp.getPathParts():
+ def importPath(self,p):
+ for part in p.getPathParts():
self.addPathPart(part)
def getPathParts(self):
@@ -121,7 +121,7 @@
#
# Convert path and AnnotatedPath to simple paths.
#
- def getSimpleClasspathList(self):
+ def getSimplePathList(self):
""" Return simple string list """
simple=[]
for p in self.parts:
@@ -132,5 +132,7 @@
return simple
def getFlattened(self):
- return os.pathsep.join(self.getSimpleClasspathList())
-
\ No newline at end of file
+ return os.pathsep.join(self.getSimplePathList())
+
+class Classpath(ArtifactPath): pass
+class AssemblyPath(ArtifactPath): pass
\ No newline at end of file
Copied: gump/trunk/python/gump/language/java.py (from rev 37209, gump/trunk/python/gump/java/helper.py)
==============================================================================
--- gump/trunk/python/gump/java/helper.py (original)
+++ gump/trunk/python/gump/language/java.py Tue Aug 31 08:33:05 2004
@@ -75,7 +75,7 @@
Return a system classpath (to include $JAVA_HOME/lib/tools.jar'
for a compiler).
"""
- sysClasspath=gump.java.cp.Classpath('System Classpath')
+ sysClasspath=gump.language.path.Classpath('System Classpath')
javaHome=self.run.getEnvironment().getJavaHome()
syscp=os.path.join(os.path.join(javaHome,'lib'),'tools.jar')
sysClasspath.importFlattenedParts(syscp)
@@ -98,7 +98,7 @@
# Start with the system classpath (later remove this)
classpath=self.getBaseClasspath()
- bootclasspath=gump.java.cp.Classpath('Boot Classpath')
+ bootclasspath=gump.language.path.Classpath('Boot Classpath')
# Add this project's work directories (these go into
# CLASSPATH, never BOOTCLASSPATH)
@@ -106,7 +106,7 @@
for work in project.getWorks():
path=work.getResolvedPath()
if path:
- classpath.addPathPart(gump.java.cp.AnnotatedPath('',path,project,None,'Work Entity'))
+ classpath.addPathPart(gump.language.path.AnnotatedPath('',path,project,None,'Work Entity'))
else:
log.error("<work element with neither 'nested' nor 'parent' attribute on " \
+ project.getName() + " in " + project.getModule().getName())
@@ -158,8 +158,8 @@
print str(depth) + ") Perform : " + `dependency`
#
- classpath=gump.java.cp.Classpath('Classpath for ' + `dependency`)
- bootclasspath=gump.java.cp.Classpath('Bootclasspath for ' + `dependency`)
+ classpath=gump.language.path.Classpath('Classpath for ' + `dependency`)
+ bootclasspath=gump.language.path.Classpath('Bootclasspath for ' + `dependency`)
# Context for this dependecy project...
project=dependency.getProject()
@@ -200,7 +200,7 @@
# If 'all' or in ids list:
if (not ids) or (jar.getId() in ids):
if ids: dependStr += ' Id = ' + jar.getId()
- path=gump.java.cp.AnnotatedPath(jar.getId(),jar.path,project,dependency.getOwnerProject(),dependStr)
+ path=gump.language.path.AnnotatedPath(jar.getId(),jar.path,project,dependency.getOwnerProject(),dependStr)
# Add to CLASSPATH
if not jar.getType() == 'boot':
Modified: gump/trunk/python/gump/model/builder.py
==============================================================================
--- gump/trunk/python/gump/model/builder.py (original)
+++ gump/trunk/python/gump/model/builder.py Tue Aug 31 08:33:05 2004
@@ -33,9 +33,9 @@
from xml.dom import getDOMImplementation
-# represents an <ant/> element
+# represents a generic build (e.g. <ant/>) element
class Builder(ModelObject, PropertyContainer):
- """ An Ant command (within a project)"""
+ """ A build command (within a project)"""
def __init__(self,dom,project):
ModelObject.__init__(self,dom,project)
PropertyContainer.__init__(self)
@@ -213,16 +213,16 @@
return self.basedir
# represents an <ant/> element
-class Ant(Builder):
+class BaseAnt(Builder):
""" An Ant command (within a project)"""
def __init__(self,dom,project):
- Builder.__init__(self,dom,project)
+ Builder.__init__(self,dom,project)
# Import the target
- self.target=self.getDomAttributeValue('target') # :TODO: Soon add ... ,'gump')
+ self.target=self.getDomAttributeValue('target') # :TODO: Soon add ... ,'gump')
# Import the buildfile
self.buildfile=self.getDomAttributeValue('buildfile') # :TODO: Soon add ... ,'build.xml')
-
+
def hasTarget(self):
if self.target: return True
return False
@@ -246,6 +246,15 @@
if self.hasBuildFile():
output.write(i+'BuildFile: ' + self.getBuildFile() + '\n')
+class Ant(BaseAnt):
+ """ An Ant command (within a project) """
+ pass
+
+# represents a <nant/> element
+class NAnt(Builder):
+ """ A NAnt command (within a project) """
+ pass
+
# represents an <maven/> element
class Maven(Builder):
""" A Maven command (within a project)"""
Modified: gump/trunk/python/gump/model/project.py
==============================================================================
--- gump/trunk/python/gump/model/project.py (original)
+++ gump/trunk/python/gump/model/project.py Tue Aug 31 08:33:05 2004
@@ -29,7 +29,7 @@
AddressPair
from gump.model.stats import Statable, Statistics
from gump.model.property import Property
-from gump.model.builder import Ant,Maven,Script
+from gump.model.builder import Ant,NAnt,Maven,Script
from gump.utils import getIndent
from gump.utils.file import *
from gump.model.depend import *
@@ -133,6 +133,10 @@
if self.ant: return True
return False
+ def hasNAnt(self):
+ if self.nant: return True
+ return False
+
def hasMaven(self):
if self.maven: return True
return False
@@ -144,6 +148,9 @@
def getAnt(self):
return self.ant
+ def getNAnt(self):
+ return self.nant
+
def getMaven(self):
return self.maven
@@ -325,6 +332,13 @@
# Copy over any XML errors/warnings
# :TODO:#1: transferAnnotations(self.xml.ant, self)
+ # Import any <nant part [if not packaged]
+ if self.hasDomChild('nant') and not packaged:
+ self.nant = NAnt(self.getDomChild('nant'),self)
+
+ # Copy over any XML errors/warnings
+ # :TODO:#1: transferAnnotations(self.xml.nant, self)
+
# Import any <maven part [if not packaged]
if self.hasDomChild('maven') and not packaged:
self.maven = Maven(self.getDomChild('maven'),self)
@@ -667,7 +681,7 @@
outputs=[]
for jar in self.getJars():
jarpath=jar.getPath()
- outputs.append(gump.java.cp.AnnotatedPath(jar.getId(),jarpath,self,None,"Project output"))
+ outputs.append(gump.language.path.AnnotatedPath(jar.getId(),jarpath,self,None,"Project output"))
return outputs
def hasOutputs(self):
Modified: gump/trunk/python/gump/run/gumprun.py
==============================================================================
--- gump/trunk/python/gump/run/gumprun.py (original)
+++ gump/trunk/python/gump/run/gumprun.py Tue Aug 31 08:33:05 2004
@@ -108,7 +108,6 @@
self.builder=None
self.updater=None
-
def setBuilder(self,builder):
self.builder=builder
@@ -127,7 +126,12 @@
def getJavaHelper(self):
return self.javaHelper
-
+ def setCSharpHelper(self,csharpHelper):
+ self.csharpHelper=csharpHelper
+
+ def getCSharpHelper(self):
+ return self.csharpHelper
+
def getRunGuid(self):
return self.guid
Modified: gump/trunk/python/gump/runner/runner.py
==============================================================================
--- gump/trunk/python/gump/runner/runner.py (original)
+++ gump/trunk/python/gump/runner/runner.py Tue Aug 31 08:33:05 2004
@@ -58,13 +58,14 @@
# A helper per language/type
- # Note: All are Java right now...
- self.java=gump.java.helper.JavaHelper(run)
+ self.java=gump.language.java.JavaHelper(run)
+ self.java=gump.language.csharp.CSharpHelper(run)
# Stash them for reference...
run.setUpdater(self.updater)
run.setBuilder(self.builder)
- run.setJavaHelper(self.java)
+ run.setJavaHelper(self.java)
+ run.setJavaHelper(self.csharp)
def initialize(self,exitOnError=True):
Modified: gump/trunk/python/gump/test/language.py
==============================================================================
--- gump/trunk/python/gump/test/language.py (original)
+++ gump/trunk/python/gump/test/language.py Tue Aug 31 08:33:05 2004
@@ -28,7 +28,8 @@
import gump.core.config
import gump.build.builder
-import gump.java.helper
+import gump.language.java
+import gump.language.csharp
from gump.model.state import *
from gump.utils import *
@@ -68,7 +69,7 @@
self.module5=self.workspace.getModule('module5')
self.builder=gump.build.builder.GumpBuilder(self.run)
- self.java=gump.java.helper.JavaHelper(self.run)
+ self.java=gump.language.java.JavaHelper(self.run)
def suiteTearDown(self):
self.run=None
Modified: gump/trunk/python/gump/test/maven.py
==============================================================================
--- gump/trunk/python/gump/test/maven.py (original)
+++ gump/trunk/python/gump/test/maven.py Tue Aug 31 08:33:05 2004
@@ -28,7 +28,7 @@
from gump.model.state import *
from gump.build.maven import MavenBuilder
-import gump.java.helper
+import gump.language.java
from gump.utils import *
from gump.test import getWorkedTestRun
@@ -57,7 +57,7 @@
self.assertNotNone('Needed a maven project', self.maven1)
self.mavenBuilder=MavenBuilder(self.run)
- self.javaHelper=gump.java.helper.JavaHelper(self.run)
+ self.javaHelper=gump.language.java.JavaHelper(self.run)
def testMavenProperties(self):
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@gump.apache.org
For additional commands, e-mail: general-help@gump.apache.org