hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1553654 - in /httpcomponents/project-release-tools/trunk: build.gradle buildSrc/src/main/groovy/Svn.groovy buildSrc/src/main/groovy/SvnBulkOp.groovy
Date Fri, 27 Dec 2013 09:50:09 GMT
Author: olegk
Date: Fri Dec 27 09:50:09 2013
New Revision: 1553654

URL: http://svn.apache.org/r1553654
Log:
Added svnmucc like utility method for bulk SVN operations; added release dist promotion task

Added:
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnBulkOp.groovy
Modified:
    httpcomponents/project-release-tools/trunk/build.gradle
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy

Modified: httpcomponents/project-release-tools/trunk/build.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/build.gradle?rev=1553654&r1=1553653&r2=1553654&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/build.gradle (original)
+++ httpcomponents/project-release-tools/trunk/build.gradle Fri Dec 27 09:50:09 2013
@@ -73,6 +73,7 @@ File rcTagFile             = new File(pr
 File rcRevisionFile        = new File(project.buildDir, 'rc-revision.txt')
 File distRevisionFile      = new File(project.buildDir, 'dist-revision.txt')
 File releaseRevisionFile   = new File(project.buildDir, 'release-revision.txt')
+File distRelRevisionFile   = new File(project.buildDir, 'dist-release-revision.txt')
 File nextVerFile           = new File(project.buildDir, 'next-ver.txt')
 File nextVerRevisionFile   = new File(project.buildDir, 'next-ver-revision.txt')
 
@@ -111,7 +112,7 @@ task restartRelease(dependsOn: checkoutS
     doLast {
         Svn.revert(checkoutSnapshot.localDir)
         [releaseVerFile, releaseTagFile, rcQualifierFile, rcTagFile, rcRevisionFile,
-                releaseRevisionFile, distRevisionFile, nextVerFile,
+                releaseRevisionFile, distRevisionFile, distRelRevisionFile, nextVerFile,
                 nextVerRevisionFile].each { File file ->
             GFileUtils.deleteQuietly(file)
         }
@@ -555,6 +556,57 @@ if (rcTagFile.exists() && rcRevisionFile
         }
     }
 
+    task promoteDist(dependsOn: checkoutRC) {
+        group = 'Release'
+        description = "Promotes dist packages."
+        inputs.files files(releaseVerFile, rcQualifierFile)
+        outputs.files file(distRelRevisionFile)
+        doLast {
+            Pom pom = Mvn.parsePom(checkoutRC.localDir)
+            String releaseVer = releaseVerFile.text.trim()
+            String rcQualifier = rcQualifierFile.text.trim()
+            String name = getProductName(pom.artifactId)
+            String rcName = name.toLowerCase(Locale.US)
+            String rcFullName = "${rcName}-${pom.version}-${rcQualifier}"
+            String releaseNotes = "RELEASE_NOTES-${pom.major}.${pom.minor}.x.txt"
+
+            String root = "$HC_DIST_STAGING"
+            if (!root.endsWith('/')) {
+                root = root + '/'
+            }
+            root = root - 'dev/httpcomponents/'
+
+            List<SvnBulkOp> bulkOps = []
+            bulkOps.add(new SvnBulkOp.Rm(new File("release/httpcomponents/${rcName}/${releaseNotes}")))
+
+            Configuration cfg = configurations.archives
+            cfg.artifacts.each { PublishArtifact artifact ->
+                File src = new File("dev/httpcomponents/${rcFullName}/${artifact.file.name}")
+                File dst
+                switch(artifact.classifier) {
+                    case ~/^(osgi-)?bin/:
+                        dst = new File("release/httpcomponents/${rcName}/binary/${artifact.file.name}")
+                        break
+                    case "src":
+                        dst = new File("release/httpcomponents/${rcName}/source/${artifact.file.name}")
+                        break
+                    default:
+                        dst = new File("release/httpcomponents/${rcName}/${artifact.file.name}")
+                        break
+                }
+                bulkOps.add(new SvnBulkOp.CpFile(dst, src))
+                bulkOps.add(new SvnBulkOp.Rm(src))
+
+            }
+
+            bulkOps.add(new SvnBulkOp.Rm(new File("dev/httpcomponents/${rcFullName}")))
+
+            long revision = Svn.mucc(new URI(root), bulkOps, "${name} ${releaseVer} release
dist")
+
+            distRelRevisionFile.text = revision
+        }
+    }
+
 }
 
 if (releaseTagFile.exists() && releaseRevisionFile.exists()) {
@@ -620,8 +672,8 @@ if (releaseTagFile.exists() && releaseRe
         description = "Completes releases."
         doLast {
             [releaseVerFile, releaseTagFile, rcQualifierFile, rcTagFile, rcRevisionFile,
-                    releaseRevisionFile, distRevisionFile, nextVerFile,
-                    nextVerRevisionFile].each { File file ->
+                    releaseRevisionFile, distRevisionFile, distRelRevisionFile,
+                    nextVerFile, nextVerRevisionFile].each { File file ->
                 GFileUtils.deleteQuietly(file)
             }
         }

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy?rev=1553654&r1=1553653&r2=1553654&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy Fri Dec
27 09:50:09 2013
@@ -36,6 +36,9 @@ import org.tmatesoft.svn.core.SVNURL
 import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager
 import org.tmatesoft.svn.core.internal.wc17.SVNWCContext
 import org.tmatesoft.svn.core.internal.wc2.compat.SvnCodec
+import org.tmatesoft.svn.core.io.ISVNEditor
+import org.tmatesoft.svn.core.io.SVNRepository
+import org.tmatesoft.svn.core.io.SVNRepositoryFactory
 import org.tmatesoft.svn.core.wc.SVNRevision
 import org.tmatesoft.svn.core.wc.SVNWCUtil
 import org.tmatesoft.svn.core.wc2.ISvnObjectReceiver
@@ -67,6 +70,15 @@ class Svn {
         opfactory
     }
 
+    static SVNRepository getRepository(URI src) {
+        SVNURL url = SVNURL.parseURIEncoded(src.toASCIIString())
+        SVNRepository repo = SVNRepositoryFactory.create(url)
+        ISVNAuthenticationManager authmanager = SVNWCUtil.createDefaultAuthenticationManager()
+        authmanager.setAuthenticationProvider(new SVNConsoleAuthenticationProvider(false))
+        repo.setAuthenticationManager(authmanager)
+        repo
+    }
+
     static void checkout(URI src, File dst) {
         SVNCommandEnvironment env = getSVNCommandEnvironment()
         SvnOperationFactory opfactory = createOperationFactory(env)
@@ -218,4 +230,59 @@ class Svn {
         }
     }
 
+    static long mucc(URI root, List<SvnBulkOp> bulkOps, String message) {
+        SVNRepository repository = Svn.getRepository(root)
+        try {
+            ISVNEditor commitEditor = repository.getCommitEditor(message, null)
+            commitEditor.openRoot(-1)
+            for (SvnBulkOp op in bulkOps) {
+
+                LinkedList<File> parents = new ArrayList<>()
+                File parent = op.path.parentFile
+                while (parent) {
+                    parents.addFirst(parent)
+                    parent = parent.parentFile
+                }
+
+                int revision = op.revision ?: -1
+
+                for (File dir in parents) {
+                    commitEditor.openDir(dir.path, revision)
+                }
+
+                switch (op) {
+                    case SvnBulkOp.Rm:
+                        File entry = op.path
+                        commitEditor.deleteEntry(entry.path, revision)
+                        break;
+                    case SvnBulkOp.Mkdir:
+                        File dir = op.path
+                        commitEditor.addDir(dir.path, null, revision)
+                        commitEditor.closeDir()
+                        break;
+                    case SvnBulkOp.CpDir:
+                        File dir = op.path
+                        File src = op.copyFrom
+                        commitEditor.addDir(dir.path, src.path, revision)
+                        commitEditor.closeDir()
+                        break;
+                    case SvnBulkOp.CpFile:
+                        File file = op.path
+                        File src = op.copyFrom
+                        commitEditor.addFile(file.path, src.path, revision)
+                        break;
+                }
+
+                for (File dir in parents) {
+                    commitEditor.closeDir()
+                }
+            }
+
+            SVNCommitInfo result = commitEditor.closeEdit()
+            result.newRevision
+        } finally {
+            repository.closeSession();
+        }
+    }
+
 }

Added: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnBulkOp.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnBulkOp.groovy?rev=1553654&view=auto
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnBulkOp.groovy (added)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnBulkOp.groovy Fri
Dec 27 09:50:09 2013
@@ -0,0 +1,103 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+class SvnBulkOp {
+
+    final File path;
+    final File copyFrom;
+    final long revision;
+
+    protected SvnBulkOp(File path, File copyFrom, long revision) {
+        this.path = path
+        this.copyFrom = copyFrom
+        this.revision = revision
+    }
+
+    static class Rm extends SvnBulkOp {
+
+        Rm(File path) {
+            super(path, null, -1)
+        }
+
+        Rm(String path) {
+            super(new File(path), null, -1)
+        }
+    }
+
+    static class Mkdir extends SvnBulkOp {
+
+        Mkdir(File path) {
+            super(path, null, -1)
+        }
+
+        Mkdir(String path) {
+            super(new File(path), null, -1)
+        }
+
+    }
+
+    static class CpFile extends SvnBulkOp {
+
+        CpFile(File path, File copyFrom, long revision) {
+            super(path, copyFrom, revision)
+        }
+
+        CpFile(File path, File copyFrom) {
+            super(path, copyFrom, -1)
+        }
+
+        CpFile(String path, String copyFrom, long revision) {
+            super(new File(path), new File(copyFrom), revision)
+        }
+
+        CpFile(String path, String copyFrom) {
+            super(new File(path), new File(copyFrom), -1)
+        }
+
+    }
+
+    static class CpDir extends SvnBulkOp {
+
+        CpDir(File path, File copyFrom, long revision) {
+            super(path, copyFrom, revision)
+        }
+
+        CpDir(File path, File copyFrom) {
+            super(path, copyFrom, -1)
+        }
+
+        CpDir(String path, String copyFrom, long revision) {
+            super(new File(path), new File(copyFrom), revision)
+        }
+
+        CpDir(String path, String copyFrom) {
+            super(new File(path), new File(copyFrom), -1)
+        }
+
+    }
+
+}
\ No newline at end of file



Mime
View raw message