hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1517580 - in /httpcomponents/project-release-tools/trunk: buildSrc/build.gradle buildSrc/src/main/groovy/HCPlugin.groovy buildSrc/src/main/groovy/HCProject.groovy buildSrc/src/main/groovy/HCSitePlugin.groovy site.gradle
Date Mon, 26 Aug 2013 15:54:12 GMT
Author: olegk
Date: Mon Aug 26 15:54:12 2013
New Revision: 1517580

URL: http://svn.apache.org/r1517580
Log:
Re-write parent of released artefacts prior to generating website content

Modified:
    httpcomponents/project-release-tools/trunk/buildSrc/build.gradle
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCPlugin.groovy
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy
    httpcomponents/project-release-tools/trunk/site.gradle

Modified: httpcomponents/project-release-tools/trunk/buildSrc/build.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/build.gradle?rev=1517580&r1=1517579&r2=1517580&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/build.gradle (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/build.gradle Mon Aug 26 15:54:12 2013
@@ -33,9 +33,11 @@ repositories {
 
 dependencies {
     compile gradleApi()
-    compile localGroovy()
-    compile group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: '1.2+'
+    compile group: 'org.codehaus.groovy', name: 'groovy', version: '2.1.6'
+    compile group: 'org.codehaus.groovy', name: 'groovy-xml', version: '2.1.6'
     compile group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.7+'
     compile group: 'org.tmatesoft.svnkit', name: 'svnkit-cli', version: '1.7+'
+    compile group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: '1.2+'
+    compile group: 'org.jdom', name: 'jdom', version: '2.0+'
     compile group: 'org.apache.maven', name: 'maven-artifact', version: '3.0+'
 }

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCPlugin.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCPlugin.groovy?rev=1517580&r1=1517579&r2=1517580&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCPlugin.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCPlugin.groovy Mon
Aug 26 15:54:12 2013
@@ -57,7 +57,7 @@ class HCPlugin implements Plugin<Project
         if (!HC_RC) {
             throw new InvalidUserDataException("HC_RC not set")
         }
-        HCProject rc = new HCProject(new URI(HC_RC), project)
+        HCProject rc = HCProject.create(new URI(HC_RC), project.buildDir)
         project.extensions.add('rc', rc)
 
         String rcQualifier = project.getProperties().get('HC_RC_QUALIFIER')

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy?rev=1517580&r1=1517579&r2=1517580&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy Mon
Aug 26 15:54:12 2013
@@ -1,3 +1,9 @@
+import org.jdom2.Document
+import org.jdom2.Element
+import org.jdom2.Namespace
+import org.jdom2.input.SAXBuilder
+import org.jdom2.output.XMLOutputter
+
 /*
  * ====================================================================
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -25,22 +31,16 @@
  *
  */
 
-import org.gradle.api.Project
-
 class HCProject {
 
     final URI repo
     final File localDir
     final Pom pom
 
-    public HCProject(URI repo, Project project) {
+    private HCProject(URI repo, File localDir, Pom pom) {
         this.repo = repo
-        this.localDir = findLocalDir(repo, project.buildDir)
-        if (!localDir.exists()) {
-            println("Checking out from SVN repository ${repo}")
-            Svn.checkout(repo, localDir)
-        }
-        this.pom = Mvn.parsePom(localDir)
+        this.localDir = localDir
+        this.pom = pom
     }
 
     private static File findLocalDir(URI repo, File buildDir) {
@@ -58,4 +58,65 @@ class HCProject {
         }
     }
 
+    static HCProject create(URI repo, File buildDir) {
+        File localDir = findLocalDir(repo, buildDir)
+        if (!localDir.exists()) {
+            println("Checking out from SVN repository ${repo}")
+            Svn.checkout(repo, localDir)
+        }
+        Pom pom = Mvn.parsePom(localDir)
+        return new HCProject(repo, localDir, pom)
+    }
+
+    static HCProject createAndRewite(URI repo, File buildDir, HCProject parent) {
+        File localDir = findLocalDir(repo, buildDir)
+        if (!localDir.exists()) {
+            println("Checking out from SVN repository ${repo}")
+            Svn.checkout(repo, localDir)
+        }
+
+        File pomFile = new File(localDir, 'pom.xml')
+        SAXBuilder parser = new SAXBuilder()
+        Document doc = parser.build(pomFile)
+
+        Namespace ns = Namespace.getNamespace("http://maven.apache.org/POM/4.0.0");
+        Element rootEl = doc.rootElement
+        Element parentEl = rootEl.getChild('parent', ns)
+        if (parentEl != null) {
+
+            Element groupIdEl = parentEl.getChild('groupId', ns)
+            if (!groupIdEl) {
+                groupIdEl = new Element('groupId', ns)
+                parentEl.addContent(groupIdEl)
+            }
+            groupIdEl.setText(parent.pom.groupId)
+
+            Element artifactIdEl = parentEl.getChild('artifactId', ns)
+            if (!artifactIdEl) {
+                artifactIdEl = new Element('artifactId', ns)
+                parentEl.addContent(artifactIdEl)
+            }
+            artifactIdEl.setText(parent.pom.artifactId)
+
+            Element versionEl = parentEl.getChild('version', ns)
+            if (!versionEl) {
+                versionEl = new Element("version", ns);
+                parentEl.addContent(versionEl)
+            }
+            versionEl.setText(parent.pom.version)
+
+            parentEl.removeChild('relativePath', ns)
+
+            XMLOutputter xmlOutputter = new XMLOutputter()
+            Writer writer = pomFile.newWriter('UTF-8')
+            try {
+                xmlOutputter.output(doc, writer)
+            } finally {
+                writer.close()
+            }
+        }
+        Pom pom = Mvn.parsePom(localDir)
+        return new HCProject(repo, localDir, pom)
+    }
+
 }

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy?rev=1517580&r1=1517579&r2=1517580&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy
(original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy
Mon Aug 26 15:54:12 2013
@@ -56,7 +56,7 @@ class HCSitePlugin implements Plugin<Pro
         }
         URI websiteURI = new URI(HC_PROJECT_SITE)
 
-        HCProject website = new HCProject(new URI(HC_PROJECT_SITE), project)
+        HCProject website = HCProject.create(new URI(HC_PROJECT_SITE), project.buildDir)
         project.extensions.add('website', website)
 
         String HC_PUBLISHED_RELEASES = project.getProperties().get('HC_PUBLISHED_RELEASES')
@@ -65,7 +65,13 @@ class HCSitePlugin implements Plugin<Pro
 
         List<HCProject> publishedReleases = []
         for (URI uri: uris) {
-            publishedReleases.add(new HCProject(uri, project))
+            HCProject release
+            if (uri.isAbsolute()) {
+                release = HCProject.createAndRewite(uri, project.buildDir, website)
+            } else {
+                release = HCProject.create(uri, project.buildDir)
+            }
+            publishedReleases.add(release)
         }
         project.extensions.add('publishedReleases', publishedReleases)
     }

Modified: httpcomponents/project-release-tools/trunk/site.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/site.gradle?rev=1517580&r1=1517579&r2=1517580&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/site.gradle (original)
+++ httpcomponents/project-release-tools/trunk/site.gradle Mon Aug 26 15:54:12 2013
@@ -35,8 +35,7 @@ for (HCProject release: publishedRelease
 println "========================================================"
 
 task generate << {
-    Svn.update(website.localDir)
-    mvn.exec(website.localDir, 'clean', 'site')
+    mvn.exec(website.localDir, 'clean', 'install', 'site')
     for (HCProject release: publishedReleases) {
         mvn.exec(release.localDir, 'clean', 'site')
     }



Mime
View raw message