gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1658305 - in /gump/live/python/gump/core/build: __init__.py builder.py gradle.py
Date Mon, 09 Feb 2015 04:55:12 GMT
Author: bodewig
Date: Mon Feb  9 04:55:11 2015
New Revision: 1658305

URL: http://svn.apache.org/r1658305
Log:
first attempt at a gradle builder

Added:
    gump/live/python/gump/core/build/gradle.py
      - copied, changed from r1658167, gump/live/python/gump/core/build/mvn.py
Modified:
    gump/live/python/gump/core/build/__init__.py
    gump/live/python/gump/core/build/builder.py

Modified: gump/live/python/gump/core/build/__init__.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/core/build/__init__.py?rev=1658305&r1=1658304&r2=1658305&view=diff
==============================================================================
--- gump/live/python/gump/core/build/__init__.py (original)
+++ gump/live/python/gump/core/build/__init__.py Mon Feb  9 04:55:11 2015
@@ -23,6 +23,6 @@ __license__   = "http://www.apache.org/l
 
 
 # tell Python what modules make up the gump.test package
-__all__ = ["builder", "ant","script","maven", "java","nant","configure","make"]
+__all__ = ["builder", "ant","script","maven", "java","nant","configure","make","gradle"]
 
     

Modified: gump/live/python/gump/core/build/builder.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/core/build/builder.py?rev=1658305&r1=1658304&r2=1658305&view=diff
==============================================================================
--- gump/live/python/gump/core/build/builder.py (original)
+++ gump/live/python/gump/core/build/builder.py Mon Feb  9 04:55:11 2015
@@ -48,6 +48,7 @@ from gump.core.config import dir, defaul
 
 from gump.core.build.script import ScriptBuilder
 from gump.core.build.ant import AntBuilder
+from gump.core.build.gradle import GradleBuilder
 from gump.core.build.nant import NAntBuilder
 from gump.core.build.maven import Maven1Builder
 from gump.core.build.mvn import MavenBuilder
@@ -80,6 +81,7 @@ class GumpBuilder(gump.core.run.gumprun.
         gump.core.run.gumprun.RunSpecific.__init__(self,run)
         
         self.ant=AntBuilder(run)
+        self.gradle=GradleBuilder(run)
         self.nant=NAntBuilder(run)
         self.maven=Maven1Builder(run)
         self.mvn=MavenBuilder(run)
@@ -144,6 +146,8 @@ class GumpBuilder(gump.core.run.gumprun.
                     self.maven.buildProject(project, languageHelper, stats)
                 elif project.hasMvn():
                     self.mvn.buildProject(project, languageHelper, stats)
+                elif project.hasGradle():
+                    self.gradle.buildProject(project, languageHelper, stats)
                 elif project.hasConfigure():
                     self.configure.buildProject(project, languageHelper, stats)
                 elif project.hasMake():
@@ -492,5 +496,7 @@ class GumpBuilder(gump.core.run.gumprun.
             self.maven.preview(project,  languageHelper, stats)
         elif project.hasMvn():
             self.mvn.preview(project, languageHelper, stats);
+        elif project.hasGradle():
+            self.gradle.preview(project, languageHelper, stats);
         else:
             print 'No builder for project: ' + project.getName()

Copied: gump/live/python/gump/core/build/gradle.py (from r1658167, gump/live/python/gump/core/build/mvn.py)
URL: http://svn.apache.org/viewvc/gump/live/python/gump/core/build/gradle.py?p2=gump/live/python/gump/core/build/gradle.py&p1=gump/live/python/gump/core/build/mvn.py&r1=1658167&r2=1658305&rev=1658305&view=diff
==============================================================================
--- gump/live/python/gump/core/build/mvn.py (original)
+++ gump/live/python/gump/core/build/gradle.py Mon Feb  9 04:55:11 2015
@@ -7,9 +7,9 @@
 # The ASF licenses this file to You 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.
@@ -19,11 +19,10 @@
 import os.path
 
 from gump import log
-from gump.actor.mvnrepoproxy.proxycontrol import PROXY_CONFIG
-from gump.core.model.builder import MVN_VERSION2, MVN_VERSION3
+#from gump.actor.mvnrepoproxy.proxycontrol import PROXY_CONFIG
 from gump.core.model.workspace import CommandWorkItem, \
     REASON_BUILD_FAILED, REASON_BUILD_TIMEDOUT, REASON_PREBUILD_FAILED, \
-    STATE_FAILED, STATE_SUCCESS,  WORK_TYPE_BUILD
+    STATE_FAILED, STATE_SUCCESS, WORK_TYPE_BUILD
 from gump.core.run.gumprun import RunSpecific
 from gump.util.file import FILE_TYPE_CONFIG
 from gump.util.process.command import Cmd, CMD_STATE_SUCCESS, \
@@ -37,125 +36,109 @@ from time import strftime
 # Classes
 ###############################################################################
 
-def write_mirror_entry(props, prefix, mirror_of, port):
-    props.write("""
-    <mirror>
-      <id>gump-%s</id>
-      <name>Apache Gump proxying %s</name>
-      <url>http://localhost:%s%s</url>
-      <mirrorOf>%s</mirrorOf>
-    </mirror>""" % (mirror_of, mirror_of, port, prefix, mirror_of) )
-
-def locateMavenProjectFile(project):
-    """Return Maven project file location"""
-    basedir = project.mvn.getBaseDirectory() or project.getBaseDirectory()
-    return os.path.abspath(os.path.join(basedir, 'pom.xml'))
-
-def locateMavenSettings(project):
-    #
-    # Where to put this:
-    #
-    basedir = project.mvn.getBaseDirectory() or project.getBaseDirectory()
-    return os.path.abspath(os.path.join(basedir, 'gump_mvn_settings.xml'))
+#def write_mirror_entry(props, prefix, mirror_of, port):
+#    props.write("""
+#    <mirror>
+#      <id>gump-%s</id>
+#      <name>Apache Gump proxying %s</name>
+#      <url>http://localhost:%s%s</url>
+#      <mirrorOf>%s</mirrorOf>
+#    </mirror>""" % (mirror_of, mirror_of, port, prefix, mirror_of) )
+
+def locateGradleProjectFile(project):
+    """Return Gradle project file location"""
+    basedir = project.gradle.getBaseDirectory() or project.getBaseDirectory()
+    return os.path.abspath(os.path.join(basedir, 'build.gradle'))
+
+#def locateMavenSettings(project):
+#    #
+#    # Where to put this:
+#    #
+#    basedir = project.mvn.getBaseDirectory() or project.getBaseDirectory()
+#    return os.path.abspath(os.path.join(basedir, 'gump_mvn_settings.xml'))
 
-def getMavenProperties(project):
+def getGradleProperties(project):
     """ Get properties for a project """
     properties = Parameters()
-    for property in project.getMvn().getProperties():
-        properties.addPrefixedNamedParameter('-D', property.name, \
+    for property in project.getGradle().getProperties():
+        properties.addPrefixedNamedParameter('-P', property.name, \
                                                  property.value, '=')
     return properties
 
-def getMavenCommand(project, executable = 'mvn'):
-    """ Build an Maven command for this project """
-    maven = project.mvn
+def getGradleCommand(project, executable='gradle'):
+    """ Build a Gradle command for this project """
+    gradle = project.gradle
 
-    # The maven goal (or none == maven default goal)
-    goal = maven.getGoal()
+    # The gradle task (or none == gradle default task)
+    task = gradle.getTask()
 
     # Optional 'verbose' or 'debug'
-    verbose = maven.isVerbose()
-    debug = maven.isDebug()
+    verbose = gradle.isVerbose()
+    debug = gradle.isDebug()
 
     #
     # Where to run this:
     #
-    basedir = maven.getBaseDirectory() or project.getBaseDirectory()
+    basedir = gradle.getBaseDirectory() or project.getBaseDirectory()
 
-    # Run Maven...
+    # Run Gradle...
     cmd = Cmd(executable, 'build_' + project.getModule().getName() + '_' + \
                 project.getName(), basedir)
 
-    cmd.addParameter('--batch-mode')
-
     #
-    # Allow maven-level debugging...
+    # Allow gradle-level debugging...
     #
-    if project.getWorkspace().isDebug() or project.isDebug() or debug: 
+    if project.getWorkspace().isDebug() or project.isDebug() or debug:
         cmd.addParameter('--debug')
     if project.getWorkspace().isVerbose() \
-            or project.isVerbose() or verbose: 
-        cmd.addParameter('--exception') 
+            or project.isVerbose() or verbose:
+        cmd.addParameter('--info')
 
-    props = getMavenProperties(project)
+    props = getGradleProperties(project)
     cmd.addNamedParameters(props)
 
-    cmd.addParameter('--settings')
-    cmd.addParameter(locateMavenSettings(project))
+    #cmd.addParameter('--settings')
+    #cmd.addParameter(locateGradleSettings(project))
 
-    profile = maven.getProfile()
-    if profile:
-        cmd.addPrefixedParameter('-P', profile)
-
-    # End with the goal...
-    if goal: 
-        for goalParam in goal.split(','):
-            cmd.addParameter(goalParam)
+    # End with the task...
+    if task:
+        for taskParam in task.split(','):
+            cmd.addParameter(taskParam)
 
     return cmd
 
 def needsSeparateLocalRepository(project):
-    return project.mvn.needsSeparateLocalRepository()
+    return project.gradle.needsSeparateLocalRepository()
 
-class MavenBuilder(RunSpecific):
+class GradleBuilder(RunSpecific):
 
     def __init__(self, run):
         RunSpecific.__init__(self, run)
 
     def buildProject(self, project, languageHelper, stats):
         """
-        Build a Maven 2.x/3.x project
+        Build a Gradle project
         """
 
         workspace = self.run.getWorkspace()
 
-        log.debug('Run Maven on Project: #[' + `project.getPosition()` + '] '\
+        log.debug('Run Gradle on Project: #[' + `project.getPosition()` + '] '\
                   + project.getName())
 
-        self.performPreBuild(project, languageHelper, stats)
+        #self.performPreBuild(project, languageHelper, stats)
 
         if project.okToPerformWork():
 
             #
             # Get the appropriate build command...
             #
-            home = None
-            if project.getMvn().getVersion() == MVN_VERSION2:
-                home = self.run.env.m2_home
-            elif project.getMvn().getVersion() == MVN_VERSION3:
-                home = self.run.env.m3_home
-
-            if home:
-                cmd = getMavenCommand(project, home + '/bin/mvn')
-                cmd.addEnvironment('M2_HOME', home)
-            else:
-                cmd = getMavenCommand(project)
+            cmd = getGradleCommand(project)
 
             if cmd:
                 # Get/set JVM properties
                 jvmargs = languageHelper.getJVMArgs(project)
                 if jvmargs and len(jvmargs.items()) > 0:
-                    cmd.addEnvironment('MAVEN_OPTS',
+                    cmd.addEnvironment('GRADLE_OPTS',
                                        jvmargs.formatCommandLine())
 
                 # Execute the command ....
@@ -177,116 +160,116 @@ class MavenBuilder(RunSpecific):
                     project.changeState(STATE_SUCCESS)
 
         if project.wasBuilt():
-            pomFile = locateMavenProjectFile(project) 
-            if os.path.exists(pomFile):
-                project.addDebug('Maven POM in: ' + pomFile) 
-                catFileToFileHolder(project, pomFile, FILE_TYPE_CONFIG)
- 
+            gradleFile = locateGradleProjectFile(project)
+            if os.path.exists(gradleFile):
+                project.addDebug('Gradle build in: ' + gradleFile)
+                catFileToFileHolder(project, gradleFile, FILE_TYPE_CONFIG)
 
-    # Do this even if not ok
-    def performPreBuild(self, project, languageHelper, _stats):
 
-        # Maven requires a build.properties to be generated...
-        if project.okToPerformWork():
-            try:
-                settingsFile = self.generateMvnSettings(project, languageHelper)
-                project.addDebug('(Apache Gump generated) Apache Maven Settings in: ' + \
-                                     settingsFile)
-
-                try:
-                    catFileToFileHolder(project, settingsFile,
-                        FILE_TYPE_CONFIG,
-                        os.path.basename(settingsFile))
-                except:
-                    log.error('Display Settings [ ' + settingsFile + \
-                                  '] Failed', exc_info = 1)
-
-            except Exception, details:
-                message = 'Generate Maven Settings Failed:' + str(details)
-                log.error(message, exc_info = 1)
-                project.addError(message)
-                project.changeState(STATE_FAILED, REASON_PREBUILD_FAILED)
+    # Do this even if not ok
+    #def performPreBuild(self, project, languageHelper, _stats):
+    #
+    #    # Gradle requires a build.properties to be generated...
+    #    if project.okToPerformWork():
+    #        try:
+    #            settingsFile = self.generateMvnSettings(project, languageHelper)
+    #            project.addDebug('(Apache Gump generated) Apache Gradle Settings in: ' +
\
+    #                                 settingsFile)
+    #
+    #            try:
+    #                catFileToFileHolder(project, settingsFile,
+    #                    FILE_TYPE_CONFIG,
+    #                    os.path.basename(settingsFile))
+    #            except:
+    #                log.error('Display Settings [ ' + settingsFile + \
+    #                              '] Failed', exc_info = 1)
+    #
+    #        except Exception, details:
+    #            message = 'Generate Gradle Settings Failed:' + str(details)
+    #            log.error(message, exc_info = 1)
+    #            project.addError(message)
+    #            project.changeState(STATE_FAILED, REASON_PREBUILD_FAILED)
 
     def preview(self, project, _languageHelper, _stats):
-        command = getMavenCommand(project) 
+        command = getGradleCommand(project)
         command.dump()
 
-    def generateMvnSettings(self, project, _languageHelper):
-        """Set repository for a Maven project"""
-
-        settingsFile = locateMavenSettings(project)
-        # Ensure containing directory exists, or make it.
-        settingsdir = os.path.dirname(settingsFile)
-        if not os.path.exists(settingsdir):
-            project.addInfo('Making directory for Maven settings: [' \
-                                + settingsdir + ']')
-            os.makedirs(settingsdir)
-
-        if os.path.exists(settingsFile):
-            project.addWarning('Overriding Maven settings: [' + settingsFile \
-                                   + ']')
-
-        if needsSeparateLocalRepository(project):
-            localRepositoryDir = self.locateLocalRepo(project)
-        else:
-            localRepositoryDir = os.path.abspath(\
-                os.path.join(self.run.getWorkspace()
-                             .getLocalRepositoryDirectory(), "shared")
-                )
-
-        props = open(settingsFile, 'w')
-
-        props.write(("""<?xml version="1.0"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You 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.
--->
-<!--
-# DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT

-#
-# File Automatically Generated by Gump, see http://gump.apache.org/
-#
-# Generated For : %s
-# Generated At  : %s
-#
-#
-# DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT
--->
-<settings>
-  <localRepository>%s</localRepository>""")
-                    % (project.getName(), strftime('%Y-%m-%d %H:%M:%S'),
-                       localRepositoryDir))
-        if not self.run.getEnvironment().noMvnRepoProxy:
-            props.write("<mirrors>")
-            for (name, prefix, _url) in PROXY_CONFIG:
-                write_mirror_entry(props, prefix, name, \
-                                       self.run.getWorkspace().mvnRepoProxyPort)
-            props.write("</mirrors>")
-
-        props.write("</settings>")
-
-        return settingsFile
-
-    def locateLocalRepo(self, project):
-        #
-        # Where to put the local repository
-        #
-        name = project.mvn.getLocalRepositoryName()
-        if not name:
-            name = project.getName() + ".mvnlocalrepo"
-        return os.path.abspath(os.path.join(self.run.getWorkspace()\
-                                                .getLocalRepositoryDirectory(),
-                                            name
-                                            ))
+#    def generateMvnSettings(self, project, _languageHelper):
+#        """Set repository for a Gradle project"""
+#
+#        settingsFile = locateGradleSettings(project)
+#        # Ensure containing directory exists, or make it.
+#        settingsdir = os.path.dirname(settingsFile)
+#        if not os.path.exists(settingsdir):
+#            project.addInfo('Making directory for Gradle settings: [' \
+#                                + settingsdir + ']')
+#            os.makedirs(settingsdir)
+#
+#        if os.path.exists(settingsFile):
+#            project.addWarning('Overriding Gradle settings: [' + settingsFile \
+#                                   + ']')
+#
+#        if needsSeparateLocalRepository(project):
+#            localRepositoryDir = self.locateLocalRepo(project)
+#        else:
+#            localRepositoryDir = os.path.abspath(\
+#                os.path.join(self.run.getWorkspace()
+#                             .getLocalRepositoryDirectory(), "shared")
+#                )
+#
+#        props = open(settingsFile, 'w')
+#
+#        props.write(("""<?xml version="1.0"?>
+#<!--
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You 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.
+#-->
+#<!--
+## DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT
+##
+## File Automatically Generated by Gump, see http://gump.apache.org/
+##
+## Generated For : %s
+## Generated At  : %s
+##
+##
+## DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT
+#-->
+#<settings>
+#  <localRepository>%s</localRepository>""")
+#                    % (project.getName(), strftime('%Y-%m-%d %H:%M:%S'),
+#                       localRepositoryDir))
+#        if not self.run.getEnvironment().noMvnRepoProxy:
+#            props.write("<mirrors>")
+#            for (name, prefix, _url) in PROXY_CONFIG:
+#                write_mirror_entry(props, prefix, name, \
+#                                       self.run.getWorkspace().mvnRepoProxyPort)
+#            props.write("</mirrors>")
+#
+#        props.write("</settings>")
+#
+#        return settingsFile
+#
+#    def locateLocalRepo(self, project):
+#        #
+#        # Where to put the local repository
+#        #
+#        name = project.mvn.getLocalRepositoryName()
+#        if not name:
+#            name = project.getName() + ".mvnlocalrepo"
+#        return os.path.abspath(os.path.join(self.run.getWorkspace()\
+#                                                .getLocalRepositoryDirectory(),
+#                                            name
+#                                            ))



Mime
View raw message