geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r506885 - /geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/library/Library.groovy
Date Tue, 13 Feb 2007 06:46:44 GMT
Author: jdillon
Date: Mon Feb 12 22:46:43 2007
New Revision: 506885

URL: http://svn.apache.org/viewvc?view=rev&rev=506885
Log:
Cleaned up, added helpers to handle svn & exec ops, moved watch bits there

Modified:
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/library/Library.groovy

Modified: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/library/Library.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/library/Library.groovy?view=diff&rev=506885&r1=506884&r2=506885
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/library/Library.groovy
(original)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/library/Library.groovy
Mon Feb 12 22:46:43 2007
@@ -52,26 +52,33 @@
         return baseDir.exists()
     }
     
-    private chmod(File dir, String perm) {
-        assert dir
-        assert perm
+    private void exec(String command, List args) {
+        assert command
+        assert args
         
         def watch = new StopWatch()
         watch.start()
         
+        ant.exec(executable: command, failonerror: true) {
+            args.each {
+                arg(value: "$it")
+            }
+        }
+        
+        log.info "Exec operation ($command) completed in: $watch"
+    }
+    
+    private chmod(File dir, String perm) {
+        assert dir
+        assert perm
+        
         log.info "Changing '$perm' for $dir"
         
         //
         // NOTE: Don't use Ant's chmod task, since it ignors dirs
         //
         
-        ant.exec(executable: 'chmod', failonerror: true) {
-            arg(value: '-R')
-            arg(value: perm)
-            arg(file: dir)
-        }
-        
-        log.info "Chmod completed in $watch"
+        exec('chmod', [ '-R', perm, dir ])
     }
     
     def lock() {
@@ -82,27 +89,58 @@
         chmod(baseDir, 'u+w')
     }
     
+    private void svn(String command, List args) {
+        assert command
+        assert args
+        
+        def watch = new StopWatch()
+        watch.start()
+        
+        ant.exec(executable: 'svn', dir: baseDir, failonerror: true) {
+            arg(value: command)
+            arg(value: '--non-interactive')
+            args.each {
+                arg(value: "$it")
+            }
+        }
+        
+        log.info "SVN operation ($command) completed in: $watch"
+    }
+    
+    private String svnGet(String command, List args) {
+        assert command
+        assert args
+        
+        def watch = new StopWatch()
+        watch.start()
+        
+        // Any does not like to replace props, so make a unique one each time
+        def propname = 'svnoutput.' + UUID.randomUUID()
+        
+        ant.exec(executable: 'svn', dir: baseDir, failonerror: true, outputproperty: propname)
{
+            arg(value: command)
+            arg(value: '--non-interactive')
+            args.each {
+                arg(value: "$it")
+            }
+        }
+        
+        log.info "SVN operation ($command) completed in: $watch"
+        
+        return ant.antProject.properties[propname]
+    }
+    
     /**
      * Check out the library.
      */
     def checkout() {
-        def watch = new StopWatch()
-        watch.start()
-        
         log.info "Checking out library from: $sourceURL"
         
         assert !exists()
         
         ant.mkdir(dir: baseDir)
         
-        ant.exec(executable: 'svn', dir: baseDir, failonerror: true) {
-            arg(value: 'checkout')
-            arg(value: '--non-interactive')
-            arg(value: sourceURL)
-            arg(file: baseDir)
-        }
-        
-        log.info "Checkout completed in $watch"
+        svn('checkout', [ sourceURL, baseDir ])
     }
     
     /**
@@ -111,57 +149,30 @@
     def commit(String message) {
         assert message
         
-        def watch = new StopWatch()
-        watch.start()
-        
         log.info "Commiting changes; message: $message"
         
         assert exists()
         
-        ant.exec(executable: 'svn', dir: baseDir, failonerror: true) {
-            arg(value: 'commit')
-            arg(value: '--non-interactive')
-            arg(value: '--message')
-            arg(value: message)
-            arg(file: baseDir)
-        }
-        
-        log.info "Commit completed in $watch"
+        svn('commit', [ '--message', message, baseDir ])
     }
     
     /**
      * Check if the library is the latest revision
      */
     boolean isLatest() {
-        def watch = new StopWatch()
-        watch.start()
-        
         log.info "Checking for changes in: $baseDir"
         
         assert exists()
         
         def lastCommit = { target ->
-            assert target
-            
-            // Any does not like to replace props, so make a unique one each time
-            def propname = 'svnoutput.' + UUID.randomUUID()
-            
-            ant.exec(executable: 'svn', dir: baseDir, failonerror: true, outputproperty:
propname) {
-                arg(value: 'info')
-                arg(value: '--non-interactive')
-                arg(value: '--xml')
-                arg(value: target)
-            }
-            
-            def info = new XmlParser().parseText(ant.antProject.properties[propname])
+            def xml = svnGet('info', [ '--xml', target ])
+            def info = new XmlParser().parseText(xml)
             return info.entry[0].commit[0]
         }
         
         def rcommit = lastCommit(sourceURL)
         def lcommit = lastCommit(baseDir)
         
-        log.info "Is latest check completed in $watch"
-        
         return rcommit.'@revision' == lcommit.'@revision'
     }
     
@@ -169,30 +180,18 @@
      * Update the library.
      */
     def update() {
-        def watch = new StopWatch()
-        watch.start()
-        
         log.info "Updating library in: $baseDir"
         
         assert exists()
         
         // Update the local copy
-        ant.exec(executable: 'svn', dir: baseDir, failonerror: true) {
-            arg(value: 'update')
-            arg(value: '--non-interactive')
-            arg(file: baseDir)
-        }
-        
-        log.info "Update completed in $watch"
+        svn('update', [ baseDir ])
     }
     
     /**
      * Remove the library (local workspace)
      */
     def remove() {
-        def watch = new StopWatch()
-        watch.start()
-        
         log.info "Removing library from: $baseDir"
         
         assert exists()
@@ -202,12 +201,7 @@
         //       and Ant's mechanism can take forever
         //
         
-        ant.exec(executable: 'rm', failonerror: true) {
-            arg(value: '-rf')
-            arg(file: baseDir)
-        }
-        
-        log.info "Remove completed in $watch"
+        exec('rm', [ '-rf', baseDir ])
     }
     
     /**
@@ -216,9 +210,6 @@
     Library copy(File targetDir, String perms) {
         assert targetDir
         
-        def watch = new StopWatch()
-        watch.start()
-        
         log.info "Copying library to: $targetDir; w/perms: $perms"
         
         assert exists()
@@ -233,11 +224,7 @@
         //       and Ant's mechanism can take forever
         //
         
-        ant.exec(executable: 'cp', failonerror: true) {
-            arg(value: '-r')
-            arg(value: "$baseDir/") // make sure to copy the contents
-            arg(file: targetDir)
-        }
+        exec('cp', [ '-r', "$baseDir/", targetDir ])
         
         // If we have some perms, then set them
         if (perms) {
@@ -247,8 +234,6 @@
         // Return new library instance, which is rooted to new dir
         def lib = new Library(sourceURL, targetDir)
         lib.isCopy = true
-        
-        log.info "Copy completed in $watch"
         
         return lib
     }



Mime
View raw message