gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r572412 - /gump/trunk/python/gump/core/build/mvn.py
Date Mon, 03 Sep 2007 20:01:46 GMT
Author: bodewig
Date: Mon Sep  3 13:01:46 2007
New Revision: 572412

URL: http://svn.apache.org/viewvc?rev=572412&view=rev
Log:
Make each mvn build use a local repository of its own

Modified:
    gump/trunk/python/gump/core/build/mvn.py

Modified: gump/trunk/python/gump/core/build/mvn.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/build/mvn.py?rev=572412&r1=572411&r2=572412&view=diff
==============================================================================
--- gump/trunk/python/gump/core/build/mvn.py (original)
+++ gump/trunk/python/gump/core/build/mvn.py Mon Sep  3 13:01:46 2007
@@ -27,6 +27,7 @@
 """
 
 import os.path
+import shutil
 import sys
 
 from gump import log
@@ -66,6 +67,8 @@
                 
         log.debug('Run Maven2 on Project: #[' + `project.getPosition()` + '] ' + project.getName())
         
+        self.performPreBuild(project, languageHelper, stats)
+
         if project.okToPerformWork():
 
             #
@@ -94,10 +97,20 @@
                     
         if project.wasBuilt():
             pomFile=self.locateMavenProjectFile(project) 
-            if os.path.exists(pomFile):                               
+            if os.path.exists(pomFile):                      
                 project.addDebug('Maven POM in: ' + pomFile) 
-                catFileToFileHolder(project, pomFile, FILE_TYPE_CONFIG) 
-  
+                catFileToFileHolder(project, pomFile, FILE_TYPE_CONFIG)
+
+            localRepo = self.locateLocalRepo(project)
+            if os.path.exists(localRepo):
+                project.addInfo("Removing local repository %s" % (localRepo))
+                try:
+                    shutil.rmtree(localRepo, True)
+                except (IOError, os.error), why:
+                    project.addWarning("Error removing [%s] - %s."
+                                       % (localRepo, why))
+ 
+
     #
     # Build an Maven command for this project
     #        
@@ -125,22 +138,6 @@
         cmd=Cmd('mvn','build_'+project.getModule().getName()+'_'+project.getName(),\
             basedir,{'CLASSPATH':classpath})
             
-        # Set this as a system property. Setting it here helps JDK1.4+
-        # AWT implementations cope w/o an X11 server running (e.g. on
-        # Linux)
-        # cmd.addPrefixedParameter('-D','java.awt.headless','true','=')
-    
-        #
-        # Add BOOTCLASSPATH
-        #
-        #if bootclasspath:
-        #    cmd.addPrefixedParameter('-X','bootclasspath/p',bootclasspath,':')
-            
-        #if jvmargs:
-        #    cmd.addParameters(jvmargs)
-            
-        # cmd.addParameter('org.apache.maven.cli.App')  
-    
         #
         # Allow maven-level debugging...
         #
@@ -166,6 +163,9 @@
         #
         #cmd.addPrefixedParameter('-D','build.sysclasspath','only','=')
     
+        cmd.addParameter('--settings')
+        cmd.addParameter(self.locateMvnSettings(project))
+
         # End with the goal...
         if goal: 
             for goalParam in goal.split(','):
@@ -185,7 +185,84 @@
         basedir = project.mvn.getBaseDirectory() or project.getBaseDirectory()
         return os.path.abspath(os.path.join(basedir,'pom.xml'))  
         
+    # 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('(Gump generated) Maven2 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 Maven2 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=self.getMavenCommand(project,languageHelper) 
         command.dump()
             
+    def generateMvnSettings(self, project, languageHelper):
+        """Set repository for a Maven2 project"""
+        
+        settingsFile = self.locateMvnSettings(project)
+        # Ensure containing directory exists, or make it.
+        settingsdir = os.path.dirname(settingsFile)
+        if not os.path.exists(settingsdir):
+            project.addInfo('Making directory for Maven2 settings: ['+settingsdir+']')
+            os.makedirs(settingsdir)
+        
+        if os.path.exists(settingsFile):
+            project.addWarning('Overriding Maven2 settings: ['+settingsFile+']')
+    
+        
+        props=open(settingsFile,'w')
+        
+        props.write(("""<?xml version="1.0"?>
+<!--
+# 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>
+  <!--mirrors>
+    <mirror>
+      <id>Gump</id>
+      <name>Gump</name>
+      <url>http://localhost:8192/maven2</url>
+      <mirrorOf>central</mirrorOf>
+    </mirror>
+  </mirrors-->
+</settings>""")	% (project.getName(), time.strftime('%Y-%m-%d %H:%M:%S'),
+                   self.locateLocalRepo(project)) )
+        return settingsFile
+
+    def locateMvnSettings(self, 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 locateLocalRepo(self, project):
+        #
+        # Where to put the local repository
+        #
+        return os.path.abspath(os.path.join(self.run.getWorkspace().getBaseDirectory(),
+                                            project.getName() + ".mvnlocalrepo"))



Mime
View raw message