You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2013/07/12 20:40:56 UTC

svn commit: r1502650 - in /httpcomponents/project-release-tools/trunk: ./ buildSrc/src/main/groovy/

Author: olegk
Date: Fri Jul 12 18:40:55 2013
New Revision: 1502650

URL: http://svn.apache.org/r1502650
Log:
Added release bundle generation script; site generation moved to a separate script; fixed script configuration phase

Added:
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HC.groovy
      - copied, changed from r1498954, httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Pom.groovy
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Line.groovy
      - copied, changed from r1498954, httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy
    httpcomponents/project-release-tools/trunk/rc.gradle
    httpcomponents/project-release-tools/trunk/site.gradle
Removed:
    httpcomponents/project-release-tools/trunk/build.gradle
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Pom.groovy
Modified:
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Mvn.groovy
    httpcomponents/project-release-tools/trunk/gradle.properties.template

Copied: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HC.groovy (from r1498954, httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Pom.groovy)
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HC.groovy?p2=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HC.groovy&p1=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Pom.groovy&r1=1498954&r2=1502650&rev=1502650&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Pom.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HC.groovy Fri Jul 12 18:40:55 2013
@@ -1,33 +1,54 @@
-/*
- * ====================================================================
- * 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 Pom {
-    String groupId
-    String artifactId
-    String version
-    List<String> modules
-}
+/*
+ * ====================================================================
+ * 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 HCProject {
+    Pom pom
+    File localDir
+    URI repo
+
+}
+
+static File checkout(URI location, File buildDir) {
+    File dst
+    if (!location.absolute) {
+        dst = new File(location.toString())
+    } else {
+        String l = location.getPath()
+        if (l.startsWith('/repos/asf/httpcomponents/')) {
+            l = l - '/repos/asf/httpcomponents/'
+        }
+        if (l.endsWith('/')) {
+            l = l.substring(0, l.length() - 1)
+        }
+        dst = new File(buildDir, l.replace('/', '-'))
+        if (!dst.exists()) {
+            dst.mkdirs()
+            Svn.checkout(location, dst)
+        }
+    }
+    return dst
+}

Copied: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Line.groovy (from r1498954, 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/Line.groovy?p2=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Line.groovy&p1=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy&r1=1498954&r2=1502650&rev=1502650&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Line.groovy Fri Jul 12 18:40:55 2013
@@ -1,32 +1,44 @@
-/*
- * ====================================================================
- * 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 HCProject {
-    Pom pom
-    File localDir
-    URI repo
-}
+/*
+ * ====================================================================
+ * 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/>.
+ *
+ */
+
+import org.apache.tools.ant.filters.FixCrLfFilter
+
+class Line {
+
+    static Class<? extends FilterReader> filter() {
+        FixCrLfFilter.class
+    }
+
+    static Map<String, Object> delim(String s) {
+        ['eol': FixCrLfFilter.CrLf.newInstance(s)]
+    }
+
+    static String CRLF  = 'crlf'
+    static String LF    = 'lf'
+    static String ASIS  = 'asis'
+
+}

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Mvn.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Mvn.groovy?rev=1502650&r1=1502649&r2=1502650&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Mvn.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Mvn.groovy Fri Jul 12 18:40:55 2013
@@ -27,6 +27,36 @@
 
 import org.gradle.api.Project
 
+class PomArtifact {
+    String groupId
+    String id
+    String version
+}
+
+class Pom {
+
+    PomArtifact parent
+    PomArtifact artifact
+    List<String> modules
+
+    String getGroupId() {
+        if (artifact.groupId) {
+            artifact.groupId
+        } else {
+            parent ? parent.groupId : null
+        }
+    }
+
+    String getArtifactId() {
+        artifact.id
+    }
+
+    String getVersion() {
+        artifact.version
+    }
+
+}
+
 class Mvn {
 
     final Project project
@@ -49,11 +79,21 @@ class Mvn {
 
     Pom parsePom(File dir) {
         File pomFile = new File(dir, 'pom.xml')
-        def pomModel = new XmlSlurper().parse(pomFile)
         Pom result = new Pom()
-        result.groupId = pomModel.groupId
-        result.artifactId = pomModel.artifactId
-        result.version = pomModel.version
+        def pomModel = new XmlSlurper().parse(pomFile)
+        def el = pomModel['parent']
+        if (el) {
+            PomArtifact pomParent = new PomArtifact()
+            pomParent.groupId = el.groupId
+            pomParent.id = el.artifactId
+            pomParent.version = el.version
+            result.parent = pomParent
+        }
+        PomArtifact artifact = new PomArtifact()
+        artifact.groupId = pomModel.groupId
+        artifact.id = pomModel.artifactId
+        artifact.version = pomModel.version
+        result.artifact = artifact
         result.modules = pomModel.modules.module*.text()
         return result
     }

Modified: httpcomponents/project-release-tools/trunk/gradle.properties.template
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/gradle.properties.template?rev=1502650&r1=1502649&r2=1502650&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/gradle.properties.template (original)
+++ httpcomponents/project-release-tools/trunk/gradle.properties.template Fri Jul 12 18:40:55 2013
@@ -7,3 +7,5 @@ HC_PUBLISHED_RELEASES=\
   http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/ \
   http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/ \
   http://svn.apache.org/repos/asf/httpcomponents/httpasyncclient/trunk/
+
+HC_RC=http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/

Added: httpcomponents/project-release-tools/trunk/rc.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/rc.gradle?rev=1502650&view=auto
==============================================================================
--- httpcomponents/project-release-tools/trunk/rc.gradle (added)
+++ httpcomponents/project-release-tools/trunk/rc.gradle Fri Jul 12 18:40:55 2013
@@ -0,0 +1,184 @@
+/*
+ * ====================================================================
+ * 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/>.
+ *
+ */
+
+repositories {
+    mavenLocal()
+}
+
+if (!MAVEN_HOME) {
+    throw InvalidUserDataException("MAVEN_HOME not set")
+}
+File mvnHomeDir = file(MAVEN_HOME)
+if (!mvnHomeDir.exists()) {
+    throw InvalidUserDataException("Maven not found at ${mvnHomeDir}")
+}
+Mvn mvn = new Mvn(project, mvnHomeDir)
+
+if (!HC_RC) {
+    throw InvalidUserDataException("HC_RC not set")
+}
+URI rcURI = new URI(HC_RC)
+File rcDir = HC.checkout(rcURI, project.buildDir)
+Pom rcPom = mvn.parsePom(rcDir)
+HCProject rc = new HCProject(pom: rcPom, localDir: rcDir, repo: rcURI)
+
+Configuration binCfg = project.configurations.create('rc')
+rc.pom.modules.each { String submodule ->
+    // Exclude OSGi bundle
+    if (!submodule.endsWith('-osgi')) {
+        project.dependencies.add(
+                binCfg.name,
+                ['group': rc.pom.groupId, 'name': submodule, 'version': rc.pom.version])
+    }
+}
+
+task generate << {
+    logger.info("Generating RC artifacts ${rc.pom.artifactId}:${rc.pom.version}")
+    mvn.exec(rc.localDir,
+            'clean', 'install', 'site', 'javadoc:aggregate')
+}
+
+task bundle << {
+    logger.info("Building release bundles ${rc.pom.artifactId}:${rc.pom.version}")
+
+    File binWinDir = new File(project.buildDir, 'bin-win')
+    File binUxDir = new File(project.buildDir, 'bin-ux')
+    File osgiWinDir = new File(project.buildDir, 'bin-osgi-win')
+    File osgiUxDir = new File(project.buildDir, 'bin-osgi-ux')
+    File srcWinDir = new File(project.buildDir, 'src-win')
+    File srcUxDir = new File(project.buildDir, 'src-ux')
+
+    files(binWinDir, binUxDir, osgiWinDir, osgiUxDir, srcWinDir, srcUxDir).each { File dir ->
+        if (dir.exists()) {
+            GFileUtils.cleanDirectory(dir)
+        }
+    }
+
+    copy {
+        with docs(rc, Line.CRLF), atrifacts(configurations.rc)
+        into binWinDir
+    }
+    copy {
+        with docs(rc, Line.LF), atrifacts(configurations.rc)
+        into binUxDir
+    }
+    copy {
+        with docs(rc, Line.CRLF), osgiBundle(rc)
+        into osgiWinDir
+    }
+    copy {
+        with docs(rc, Line.LF), osgiBundle(rc)
+        into osgiUxDir
+    }
+    copy {
+        with sources(rc, Line.CRLF)
+        into srcWinDir
+    }
+    copy {
+        with sources(rc, Line.LF)
+        into srcUxDir
+    }
+
+}
+
+CopySpec docs(HCProject hcProject, String delim) {
+    CopySpec spec = copySpec {
+        from (hcProject.localDir) {
+            include 'README.txt'
+            include 'LICENSE.txt'
+            include 'NOTICE.txt'
+            include 'RELEASE_NOTES.txt'
+            filter(Line.delim(delim), Line.filter())
+        }
+        from ("${hcProject.localDir}/target/site/apidocs") {
+            into 'javadoc'
+        }
+        from ("${hcProject.localDir}/target/site/tutorial") {
+            into 'tutorial'
+        }
+    }
+    hcProject.pom.modules.each { String submodule ->
+        spec.from ("${hcProject.localDir}/${submodule}/target/site/examples") {
+            into 'examples'
+            filter(Line.delim(delim), Line.filter())
+        }
+    }
+    spec
+}
+
+CopySpec atrifacts(Configuration cfg) {
+    CopySpec spec = copySpec {
+        into 'lib'
+    }
+    cfg.resolvedConfiguration.resolvedArtifacts.each { ResolvedArtifact artifact ->
+        spec.from(artifact.file.absolutePath) {
+            include artifact.file.name
+        }
+    }
+    spec
+}
+
+CopySpec osgiBundle(HCProject hcProject) {
+    CopySpec spec = copySpec {
+        into '.'
+    }
+    hcProject.pom.modules.each { String submodule ->
+        if (submodule.endsWith('-osgi')) {
+            spec.from("${hcProject.localDir}/${submodule}/target") {
+                include "*.jar"
+                exclude "*-sources.jar"
+                exclude "*-javadoc.jar"
+            }
+        }
+    }
+    spec
+}
+
+CopySpec sources(HCProject hcProject, String delim) {
+    copySpec {
+        from (hcProject.localDir) {
+            include '**/src/**'
+            include '**/*.txt'
+            include '**/*.xml'
+            exclude '**/resources/**'
+            exclude '**/bin/**'
+            exclude '**/target/**'
+            exclude '**/build/**'
+            exclude '**/lib/**'
+            exclude '**/.*/**'
+            filter(Line.delim(delim), Line.filter())
+        }
+        from (hcProject.localDir) {
+            include '**/resources/**'
+            exclude '**/bin/**'
+            exclude '**/target/**'
+            exclude '**/build/**'
+            exclude '**/lib/**'
+            exclude '**/.*/**'
+        }
+    }
+}

Added: httpcomponents/project-release-tools/trunk/site.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/site.gradle?rev=1502650&view=auto
==============================================================================
--- httpcomponents/project-release-tools/trunk/site.gradle (added)
+++ httpcomponents/project-release-tools/trunk/site.gradle Fri Jul 12 18:40:55 2013
@@ -0,0 +1,150 @@
+/*
+ * ====================================================================
+ * 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/>.
+ *
+ */
+
+if (!MAVEN_HOME) {
+    throw InvalidUserDataException("MAVEN_HOME not set")
+}
+File mvnHomeDir = file(MAVEN_HOME)
+if (!mvnHomeDir.exists()) {
+    throw InvalidUserDataException("Maven not found at ${mvnHomeDir}")
+}
+Mvn mvn = new Mvn(project, mvnHomeDir)
+
+if (!HC_SITE_STAGING) {
+    throw InvalidUserDataException("HC_SITE_STAGING not set")
+}
+URI stagingURI = new URI(HC_SITE_STAGING)
+File staging = HC.checkout(stagingURI, project.buildDir)
+
+if (!HC_PROJECT_SITE) {
+    throw InvalidUserDataException("HC_PROJECT_SITE not set")
+}
+URI websiteURI = new URI(HC_PROJECT_SITE)
+File websiteDir = HC.checkout(websiteURI, project.buildDir)
+Pom websitePom = mvn.parsePom(websiteDir)
+HCProject website = new HCProject(pom: websitePom, localDir: websiteDir, repo: websiteURI)
+
+List<URI> uris = HC_PUBLISHED_RELEASES ?
+    HC_PUBLISHED_RELEASES.split(/[ \t]+/).collect { new URI(it) } : []
+
+List<HCProject> publishedReleases = []
+for (URI uri: uris) {
+    File releaseDir = HC.checkout(uri, project.buildDir)
+    Pom releasePom = mvn.parsePom(releaseDir)
+    publishedReleases.add(new HCProject(pom: releasePom, localDir: releaseDir, repo: uri))
+}
+
+task clean << {
+    if (project.buildDir.exists()) {
+        GFileUtils.cleanDirectory(project.buildDir)
+    }
+}
+
+task generate << {
+    logger.info("Generating website content ${website.pom.artifactId}:${website.pom.version}")
+    Svn.update(website.localDir)
+    mvn.exec(website.localDir, 'clean', 'site')
+    for (HCProject release: publishedReleases) {
+        logger.info("Generating published release content ${release.pom.artifactId}:${release.pom.version}")
+        mvn.exec(release.localDir, 'clean', 'site')
+    }
+}
+
+task stage << {
+    logger.info("Staging website content ${website.pom.artifactId}:${website.pom.version}")
+
+    copy {
+        into staging
+        with siteContent(website)
+    }
+
+    for (HCProject release: publishedReleases) {
+        logger.info("Staging published release content ${release.pom.artifactId}:${release.pom.version}")
+
+        def releaseStaging = "${staging}/${release.pom.artifactId}-${release.pom.version}"
+        copy {
+            into releaseStaging
+            with siteContent(release)
+        }
+        release.pom.modules.each { String submodule ->
+            copy {
+                into "${releaseStaging}/${submodule}"
+                with siteContent(file("${release.localDir}/${submodule}"))
+            }
+        }
+        fixLinks(release, file(releaseStaging))
+    }
+}
+
+void fixLinks(HCProject hcProject, File dstDir) {
+
+    // Deal with crappy links generated by Maven Site Plugin
+    project.fileTree(dir: dstDir, include: '*.html').each {
+        File f ->
+            Html.rewriteLinks(f, { URI href ->
+                if (!href.isAbsolute()) {
+                    def m1 = href.path =~ /^..(\/..\/scp:\/people.apache.org\/www)?\/hc.apache.org\//
+                    if (m1.find()) {
+                        return new URI(m1.replaceFirst('../'))
+                    }
+                }
+                return href
+            })
+    }
+
+    hcProject.pom.modules.each { String submodule ->
+        project.fileTree(dir: new File(dstDir, submodule), include: '*.html').each {
+            File f ->
+                Html.rewriteLinks(f, { URI href ->
+                    if (!href.isAbsolute()) {
+                        def m1 = href.path =~ /^..\/..(\/..\/scp:\/people.apache.org\/www)?\/hc.apache.org\//
+                        if (m1.find()) {
+                            return new URI(m1.replaceFirst('../../'))
+                        }
+                    }
+                    return href
+                })
+        }
+    }
+
+}
+
+CopySpec siteContent(File dir) {
+    copySpec {
+        from ("${dir}/target/site") {
+            exclude '**/*.html'
+        }
+        from ("${dir}/target/site") {
+            include '**/*.html'
+            filter(Line.filter())
+        }
+    }
+}
+
+CopySpec siteContent(HCProject hcProject) {
+    siteContent(hcProject.localDir)
+}