tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tveron...@apache.org
Subject svn commit: r1592210 - in /tomee/tomee/trunk/tomee/tomee-deb: ./ src/main/groovy/org/apache/tomee/deb/ src/main/groovy/org/apache/tomee/deb/jira/ src/main/resources/
Date Sat, 03 May 2014 14:02:07 GMT
Author: tveronezi
Date: Sat May  3 14:02:06 2014
New Revision: 1592210

URL: http://svn.apache.org/r1592210
Log:
Creating changelog from the jira rest api. Things to notice:
* Lintian is picky about typos. We need to be careful about it in the issue summaries.
* Only released versions will show up in the change log. We need the release date value. 

Added:
    tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/
    tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/ChangeLogBuilder.groovy
    tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/IssueLog.groovy
    tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/VersionIssues.groovy
    tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog_entry.template
Modified:
    tomee/tomee/trunk/tomee/tomee-deb/pom.xml
    tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/PackageBuilder.groovy
    tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog.template

Modified: tomee/tomee/trunk/tomee/tomee-deb/pom.xml
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-deb/pom.xml?rev=1592210&r1=1592209&r2=1592210&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-deb/pom.xml (original)
+++ tomee/tomee/trunk/tomee/tomee-deb/pom.xml Sat May  3 14:02:06 2014
@@ -57,13 +57,18 @@
     </repositories>
     <dependencies>
         <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.maven</groupId>
             <artifactId>maven-core</artifactId>
+
             <version>3.2.1</version>
         </dependency>
         <dependency>
             <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-ant</artifactId>
+            <artifactId>groovy-all</artifactId>
             <version>2.2.1</version>
         </dependency>
         <dependency>
@@ -72,6 +77,11 @@
             <version>${commons.compress}</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.2</version>
+        </dependency>
+        <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
             <version>${commons.io}</version>
@@ -133,11 +143,6 @@
             <artifactId>openejb-hsql</artifactId>
             <version>${openejb.version}</version>
         </dependency>
-        <dependency>
-            <groupId>com.atlassian.jira</groupId>
-            <artifactId>jira-rest-java-client-core</artifactId>
-            <version>2.0.0-m26</version>
-        </dependency>
     </dependencies>
     <build>
         <plugins>
@@ -252,7 +257,8 @@
                                     <classifier>plus</classifier>
                                 </artifact>
                                 <artifact>
-                                    <file>${project.build.directory}/deb/apache-tomee-jaxrs-${project.version}.deb</file>
+                                    <file>${project.build.directory}/deb/apache-tomee-jaxrs-${project.version}.deb
+                                    </file>
                                     <type>deb</type>
                                     <classifier>jaxrs</classifier>
                                 </artifact>
@@ -263,12 +269,15 @@
                                     <classifier>webprofile</classifier>
                                 </artifact>
                                 <artifact>
-                                    <file>${project.build.directory}/deb/apache-tomee-plume-${project.version}.deb</file>
+                                    <file>${project.build.directory}/deb/apache-tomee-plume-${project.version}.deb
+                                    </file>
                                     <type>deb</type>
                                     <classifier>plume</classifier>
                                 </artifact>
                                 <artifact>
-                                    <file>${project.build.directory}/deb/apache-tomee-lib-tomcat-${project.version}.deb</file>
+                                    <file>
+                                        ${project.build.directory}/deb/apache-tomee-lib-tomcat-${project.version}.deb
+                                    </file>
                                     <type>deb</type>
                                     <classifier>lib-tomcat</classifier>
                                 </artifact>

Modified: tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/PackageBuilder.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/PackageBuilder.groovy?rev=1592210&r1=1592209&r2=1592210&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/PackageBuilder.groovy
(original)
+++ tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/PackageBuilder.groovy
Sat May  3 14:02:06 2014
@@ -18,9 +18,6 @@
 
 package org.apache.tomee.deb
 
-import com.atlassian.jira.rest.client.api.domain.Issue
-import com.atlassian.jira.rest.client.auth.AnonymousAuthenticationHandler
-import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory
 import groovy.io.FileType
 import groovy.text.GStringTemplateEngine
 import org.apache.commons.codec.digest.DigestUtils
@@ -29,14 +26,13 @@ import org.apache.commons.compress.archi
 import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream
 import org.apache.commons.compress.compressors.gzip.GzipParameters
 import org.apache.maven.project.MavenProject
+import org.apache.tomee.deb.jira.ChangeLogBuilder
 
 import java.text.SimpleDateFormat
-import java.util.concurrent.TimeUnit
 import java.util.zip.Deflater
 
 class PackageBuilder {
 
-    static final JIRA_SRV = 'https://issues.apache.org/jira'
     static final TOMCAT_EXPLODED_DIR = 'tomcat-exploded'
     static final TOMCAT_PACKAGE_NAME = 'lib-tomcat'
 
@@ -52,64 +48,11 @@ class PackageBuilder {
         project = myProject
     }
 
-    def getJiraData = {
-        def restClient = null
-        try {
-            def factory = new AsynchronousJiraRestClientFactory()
-            restClient = factory.create(new URI(JIRA_SRV), new AnonymousAuthenticationHandler())
-            String version = project.version
-            version = version.replaceAll('-SNAPSHOT$', '')
-            def query = "project = TOMEE AND issuetype in standardIssueTypes() AND affectedVersion
in (${version}) AND status in (Resolved, Closed)"
-            return restClient.searchClient.searchJql(query).get(1, TimeUnit.MINUTES)
-        } catch (e) {
-            e.printStackTrace()
-            return null
-        }
-        finally {
-            restClient?.close()
-        }
+    def buildChangelogContent = {
+        def builder = new ChangeLogBuilder()
+        builder.buildChangelogContent('TOMEE')
     }.memoize() // execute it just once per instance
 
-    List<String> buildChangelogContent(String classifier) {
-        def results = []
-        String version = project.version
-        version = version.replaceAll('-SNAPSHOT$', '')
-        def templateFile = this.class.getResource('/changelog.template')
-        getJiraData()?.issues?.each { Issue issue ->
-            def urgency
-            switch (issue.priority.name) {
-                case 'Blocker':
-                    urgency = 'critical'
-                    break
-                case 'Critical':
-                    urgency = 'emergency'
-                    break
-                case 'Major':
-                    urgency = 'high'
-                    break
-                case 'Minor':
-                    urgency = 'medium'
-                    break
-                default: //Trivial
-                    urgency = 'low'
-                    break
-            }
-            def maintainer = issue.assignee ?: issue.reporter
-            def template = new GStringTemplateEngine().createTemplate(templateFile).make([
-                    classifier          : classifier,
-                    tomeeVersion        : version,
-                    urgency             : urgency,
-                    issueTitle          : "[${issue.issueType.name}] ${issue.summary}",
-                    issueID             : issue.key,
-                    issueMaintainer     : maintainer.name,
-                    issueMaintainerEmail: maintainer.emailAddress,
-                    issueFixDate        : issue.updateDate.toString('EEE, d MMM yyyy HH:mm:ss
Z')
-            ])
-            results << template.toString()
-        }
-        results
-    }
-
     private void gz(String file, String gzipFile) {
         new File(file).withInputStream { fis ->
             new File(gzipFile).withOutputStream { fos ->
@@ -123,16 +66,14 @@ class PackageBuilder {
         }
     }
 
-    void buildChangelog(File docDir, String classifier) {
-        def issues = buildChangelogContent(classifier)
-        if (!issues) {
+    void buildChangelog(File docDir) {
+        String content = buildChangelogContent()
+        if (!content) {
             return
         }
         def changelogFile = new File(docDir, 'changelog.Debian')
         changelogFile.withWriter { BufferedWriter writer ->
-            issues.each { String issue ->
-                writer.writeLine(issue)
-            }
+            writer.writeLine(content)
         }
         def changelogFileGz = new File(changelogFile.parent, 'changelog.Debian.gz')
         gz(changelogFile.absolutePath, changelogFileGz.absolutePath)
@@ -157,6 +98,7 @@ class PackageBuilder {
             fileset(dir: outputDir.absolutePath, includes: '**/*.bat')
             fileset(dir: outputDir.absolutePath, includes: '**/*.original')
             fileset(dir: outputDir.absolutePath, includes: '**/*.tmp')
+            fileset(dir: outputDir.absolutePath, includes: '**/LICENSE') // lintian does
not like it.
         }
         // Moving the default tomee webapp to /usr/share/tomee-${classifier}
         new File(outputDir, 'webapps/tomee').renameTo(new File(outputDir, 'tomee-webapp'))
@@ -317,7 +259,7 @@ class PackageBuilder {
             fileset(file: new File(distributionTomeeDir, 'RELEASE-NOTES').absolutePath)
             fileset(file: new File(distributionTomeeDir, 'RUNNING.txt').absolutePath)
         }
-        buildChangelog(docDir, classifier)
+        buildChangelog(docDir)
         new File(dataDir, "var/log/tomee-${classifier}").mkdirs()
         new File(dataDir, "var/lib/tomee-${classifier}/conf").mkdirs()
         new File(dataDir, "var/lib/tomee-${classifier}/work").mkdirs()
@@ -482,7 +424,7 @@ class PackageBuilder {
         maskCodelessJars(packageName, dataDir.absolutePath)
         def docDir = new File(dataDir, "usr/share/doc/tomee-${packageName}")
         docDir.mkdirs()
-        buildChangelog(docDir, packageName)
+        buildChangelog(docDir)
         writeTemplate(
                 new File(docDir, 'copyright'),
                 '/copyright.template',

Added: tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/ChangeLogBuilder.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/ChangeLogBuilder.groovy?rev=1592210&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/ChangeLogBuilder.groovy
(added)
+++ tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/ChangeLogBuilder.groovy
Sat May  3 14:02:06 2014
@@ -0,0 +1,142 @@
+/**
+ *
+ * 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.
+ */
+
+package org.apache.tomee.deb.jira
+
+import groovy.json.JsonSlurper
+import groovy.text.GStringTemplateEngine
+import org.apache.commons.lang3.StringUtils
+
+import java.text.SimpleDateFormat
+
+class ChangeLogBuilder {
+    static final JIRA_SRV = 'https://issues.apache.org/jira/rest/api/2/search?jql=' +
+            'project+in+(${projectName})+AND+' +
+            'type+in+(Bug,+Improvement)+AND+' +
+            'resolutiondate+is+not+EMPTY+AND+' +
+            'fixVersion+is+not+EMPTY+' +
+            'ORDER+BY+fixVersion+ASC&' +
+            'startAt=${startAt}&maxResults=${maxResults}&' +
+            'fields=issuetype,priority,fixVersions,summary,resolutiondate'
+
+    static final JIRA_DT_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
+    static final JIRA_RELEASE_DT_FORMAT = new SimpleDateFormat('yyyy-MM-dd')
+    static final LOG_RELEASE_DT_FORMAT = new SimpleDateFormat('EEE, d MMM yyyy HH:mm:ss Z')
+
+
+    Set<VersionIssues> getLogs(String projectName) {
+        Map<String, VersionIssues> versionsMap = [:]
+        def slupper = new JsonSlurper()
+        def total = 1
+        def startAt = 0
+        def getIssues = {
+            def url = new GStringTemplateEngine().createTemplate(JIRA_SRV).make([
+                    projectName: projectName,
+                    startAt    : startAt,
+                    maxResults : 50
+            ]).toString()
+            def json = slupper.parseText(new URL(url).text)
+            total = json.total
+            startAt += json.maxResults
+            json.issues
+        }
+        while (total > startAt) {
+            getIssues().each { issue ->
+                def bean = new IssueLog(
+                        key: issue.key,
+                        summary: issue.fields.summary,
+                        issueType: issue.fields.issuetype.name,
+                        priority: issue.fields.priority.name,
+                        resolutionDate: JIRA_DT_FORMAT.parse(issue.fields.resolutiondate
as String)
+                )
+                issue.fields.fixVersions.each { fixVersion ->
+                    String versionName = fixVersion.name as String
+                    if (versionName.toLowerCase().contains('trunk') || !fixVersion.releaseDate)
{
+                        return // not released yet
+                    }
+                    Date releaseDate = JIRA_RELEASE_DT_FORMAT.parse(fixVersion.releaseDate
as String)
+                    if (!versionsMap.containsKey(versionName)) {
+                        versionsMap.put(versionName, new VersionIssues(
+                                version: versionName,
+                                releaseDate: releaseDate
+                        ))
+                    }
+                    versionsMap.get(versionName).issues << bean
+                }
+            }
+        }
+        new TreeSet<VersionIssues>(versionsMap.values())
+    }
+
+    String buildChangelogContent(String projectName) {
+        Set<VersionIssues> logs = getLogs(projectName)
+        def tplEngine = new GStringTemplateEngine()
+        def logTemplate = tplEngine.createTemplate(this.class.getResource('/changelog.template'))
+        def logEntryTemplate = tplEngine.createTemplate(this.class.getResource('/changelog_entry.template'))
+        def resultWriter = new StringWriter()
+        def resultBufWriter = new BufferedWriter(resultWriter)
+        logs.each { VersionIssues versionIssues ->
+            def versionUrgency = 'low'
+            def entryWriter = new StringWriter()
+            def entryBufWriter = new BufferedWriter(entryWriter)
+            versionIssues.issues.each { IssueLog issueLog ->
+                entryBufWriter.writeLine(logEntryTemplate.make([
+                        issueTitle: StringUtils.abbreviate(issueLog.summary, 76),
+                        issueID   : issueLog.key
+                ]).toString())
+                switch (issueLog.priority) {
+                    case 'Blocker':
+                        versionUrgency = 'critical'
+                        break
+                    case 'Critical':
+                        if (versionUrgency != 'critical') {
+                            versionUrgency = 'emergency'
+                        }
+                        break
+                    case 'Major':
+                        if (versionUrgency != 'critical' && versionUrgency != 'emergency')
{
+                            versionUrgency = 'high'
+                        }
+                        break
+                    case 'Minor':
+                        if (versionUrgency != 'critical' && versionUrgency != 'emergency'
&& versionUrgency != 'high') {
+                            versionUrgency = 'medium'
+                        }
+                        break
+                    default: //Trivial
+                        // no-op
+                        break
+                }
+            }
+            entryBufWriter.close()
+            entryWriter.close()
+
+            resultBufWriter.writeLine(logTemplate.make([
+                    projectName: projectName,
+                    version    : versionIssues.version,
+                    urgency    : versionUrgency,
+                    fixDate    : LOG_RELEASE_DT_FORMAT.format(versionIssues.releaseDate),
+                    issues     : entryWriter.toString()
+            ]).toString())
+        }
+        resultBufWriter.close()
+        resultWriter.close()
+        resultWriter.toString().trim()
+    }
+
+}

Added: tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/IssueLog.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/IssueLog.groovy?rev=1592210&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/IssueLog.groovy
(added)
+++ tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/IssueLog.groovy
Sat May  3 14:02:06 2014
@@ -0,0 +1,27 @@
+/**
+ *
+ * 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.
+ */
+
+package org.apache.tomee.deb.jira
+
+class IssueLog {
+    String key
+    String summary
+    String issueType
+    String priority
+    Date resolutionDate
+}

Added: tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/VersionIssues.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/VersionIssues.groovy?rev=1592210&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/VersionIssues.groovy
(added)
+++ tomee/tomee/trunk/tomee/tomee-deb/src/main/groovy/org/apache/tomee/deb/jira/VersionIssues.groovy
Sat May  3 14:02:06 2014
@@ -0,0 +1,53 @@
+/**
+ *
+ * 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.
+ */
+
+package org.apache.tomee.deb.jira
+
+class VersionIssues implements Comparable<VersionIssues> {
+    String version
+    Date releaseDate
+    List<IssueLog> issues = []
+
+    private String normalizeVersion(String version) {
+        String versionNumber = (version =~ /[[0-9]+\.]+[0-9]/)[0]
+        def lowerCase = version.toLowerCase().substring(versionNumber.length())
+        if (lowerCase.contains('alpha')) {
+            return "${versionNumber}-0-${lowerCase}"
+        }
+        if (lowerCase.contains('beta')) {
+            return "${versionNumber}-1-${lowerCase}"
+        }
+        return "${versionNumber}-2-${lowerCase}"
+    }
+
+    @Override
+    int compareTo(VersionIssues other) {
+        return -1 * normalizeVersion(version).compareTo(normalizeVersion(other.version))
+    }
+
+    boolean equals(o) {
+        if (this.is(o)) return true
+        if (getClass() != o.class) return false
+        if (version != (o as VersionIssues).version) return false
+        return true
+    }
+
+    int hashCode() {
+        return version.hashCode()
+    }
+}

Modified: tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog.template
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog.template?rev=1592210&r1=1592209&r2=1592210&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog.template (original)
+++ tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog.template Sat May  3 14:02:06
2014
@@ -1,6 +1,4 @@
-tomee-${classifier} (${tomeeVersion}) stable; urgency=${urgency}
+${projectName} (${version}) stable; urgency=${urgency}
 
-  * ${issueTitle}
-    https://issues.apache.org/jira/browse/${issueID}
-
- -- ${issueMaintainer} <${issueMaintainerEmail}>  ${issueFixDate}
\ No newline at end of file
+${issues}
+ -- devlist <dev@tomee.apache.org>  ${fixDate}

Added: tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog_entry.template
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog_entry.template?rev=1592210&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog_entry.template (added)
+++ tomee/tomee/trunk/tomee/tomee-deb/src/main/resources/changelog_entry.template Sat May
 3 14:02:06 2014
@@ -0,0 +1,2 @@
+  * ${issueTitle}
+    https://issues.apache.org/jira/browse/${issueID}
\ No newline at end of file



Mime
View raw message