You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ju...@apache.org on 2015/07/07 00:47:55 UTC
kafka git commit: kafka-2248;
Use Apache Rat to enforce copyright headers; patched by Ewen Cheslack-Postava;
reviewed by Gwen Shapira, Joel Joshy and Jun Rao
Repository: kafka
Updated Branches:
refs/heads/trunk 3f8480ccf -> fd612a2d5
kafka-2248; Use Apache Rat to enforce copyright headers; patched by Ewen Cheslack-Postava; reviewed by Gwen Shapira, Joel Joshy and Jun Rao
Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/fd612a2d
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/fd612a2d
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/fd612a2d
Branch: refs/heads/trunk
Commit: fd612a2d50f1ee13009395f082357403c4277164
Parents: 3f8480c
Author: Ewen Cheslack-Postava <me...@ewencp.org>
Authored: Mon Jul 6 15:47:40 2015 -0700
Committer: Jun Rao <ju...@gmail.com>
Committed: Mon Jul 6 15:47:40 2015 -0700
----------------------------------------------------------------------
.rat-excludes | 26 ---
build.gradle | 27 ++-
.../scala/other/kafka/TestOffsetManager.scala | 17 ++
gradle/buildscript.gradle | 19 +-
gradle/license.gradle | 9 -
gradle/rat.gradle | 115 +++++++++++
gradle/resources/rat-output-to-html.xsl | 206 +++++++++++++++++++
kafka-patch-review.py | 17 ++
scala.gradle | 15 ++
topics.json | 4 -
10 files changed, 409 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/.rat-excludes
----------------------------------------------------------------------
diff --git a/.rat-excludes b/.rat-excludes
deleted file mode 100644
index 01d6298..0000000
--- a/.rat-excludes
+++ /dev/null
@@ -1,26 +0,0 @@
-.rat-excludes
-rat.out
-sbt
-sbt.boot.lock
-README*
-.gitignore
-.git
-.svn
-build.properties
-target
-src_managed
-update.log
-clients/target
-core/target
-contrib/target
-project/plugins/target
-project/build/target
-*.iml
-*.csproj
-TODO
-Makefile*
-*.html
-*.xml
-*expected.out
-*.kafka
-
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 30d1cf2..727d7c5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -13,11 +13,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import org.ajoberstar.grgit.Grgit
+
buildscript {
repositories {
mavenCentral()
}
apply from: file('gradle/buildscript.gradle'), to: buildscript
+
+ dependencies {
+ // For Apache Rat plugin to ignore non-Git files, need ancient version for Java 6 compatibility
+ classpath group: 'org.ajoberstar', name: 'grgit', version: '0.2.3'
+ }
}
def slf4jlog4j='org.slf4j:slf4j-log4j12:1.7.6'
@@ -41,8 +48,24 @@ ext {
}
apply from: file('wrapper.gradle')
-apply from: file('gradle/license.gradle')
apply from: file('scala.gradle')
+apply from: file('gradle/rat.gradle')
+
+rat {
+ // Exclude everything under the directory that git should be ignoring via .gitignore or that isn't checked in. These
+ // restrict us only to files that are checked in or are staged.
+ def repo = Grgit.open(project.file('.'))
+ excludes = new ArrayList<String>(repo.clean(ignore: false, directories: true, dryRun: true))
+ // And some of the files that we have checked in should also be excluded from this check
+ excludes.addAll([
+ '**/.git/**',
+ 'gradlew',
+ 'gradlew.bat',
+ '**/README.md',
+ '.reviewboardrc',
+ 'system_test/**',
+ ])
+}
subprojects {
apply plugin: 'java'
@@ -52,8 +75,6 @@ subprojects {
sourceCompatibility = 1.6
- licenseTest.onlyIf { isVerificationRequired(project) }
-
uploadArchives {
repositories {
signing {
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/core/src/test/scala/other/kafka/TestOffsetManager.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/other/kafka/TestOffsetManager.scala b/core/src/test/scala/other/kafka/TestOffsetManager.scala
index 8047da4..e0e46c8 100644
--- a/core/src/test/scala/other/kafka/TestOffsetManager.scala
+++ b/core/src/test/scala/other/kafka/TestOffsetManager.scala
@@ -1,3 +1,20 @@
+/**
+ * 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 other.kafka
import org.I0Itec.zkclient.ZkClient
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/gradle/buildscript.gradle
----------------------------------------------------------------------
diff --git a/gradle/buildscript.gradle b/gradle/buildscript.gradle
index 5e45c06..047632b 100644
--- a/gradle/buildscript.gradle
+++ b/gradle/buildscript.gradle
@@ -1,3 +1,18 @@
+// 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.
+
repositories {
repositories {
// For license plugin.
@@ -6,7 +21,3 @@ repositories {
}
}
}
-
-dependencies {
- classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0'
-}
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/gradle/license.gradle
----------------------------------------------------------------------
diff --git a/gradle/license.gradle b/gradle/license.gradle
deleted file mode 100644
index b4b62eb..0000000
--- a/gradle/license.gradle
+++ /dev/null
@@ -1,9 +0,0 @@
-subprojects {
- apply plugin: 'license'
-
- license {
- header rootProject.file('HEADER')
- // Skip Twitter bootstrap JS and CSS.
- skipExistingHeaders = true
- }
-}
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/gradle/rat.gradle
----------------------------------------------------------------------
diff --git a/gradle/rat.gradle b/gradle/rat.gradle
new file mode 100644
index 0000000..d62b372
--- /dev/null
+++ b/gradle/rat.gradle
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.api.Task
+import org.gradle.api.internal.project.IsolatedAntBuilder
+
+apply plugin: RatPlugin
+
+class RatTask extends DefaultTask {
+ @Input
+ List<String> excludes
+
+ def reportPath = 'build/rat'
+ def stylesheet = 'gradle/resources/rat-output-to-html.xsl'
+ def xmlReport = reportPath + '/rat-report.xml'
+ def htmlReport = reportPath + '/rat-report.html'
+
+ def generateXmlReport(File reportDir) {
+ def antBuilder = services.get(IsolatedAntBuilder)
+ def ratClasspath = project.configurations.rat
+ antBuilder.withClasspath(ratClasspath).execute {
+ ant.taskdef(resource: 'org/apache/rat/anttasks/antlib.xml')
+ ant.report(format: 'xml', reportFile: xmlReport) {
+ fileset(dir: ".") {
+ patternset {
+ excludes.each {
+ exclude(name: it)
+ }
+ }
+ }
+ }
+ }
+ }
+
+ def printUnknownFiles() {
+ def ratXml = new XmlParser().parse(xmlReport)
+ def unknownLicenses = 0
+ ratXml.resource.each { resource ->
+ if (resource.'license-approval'.@name[0] == "false") {
+ println('Unknown license: ' + resource.@name)
+ unknownLicenses++
+ }
+ }
+ if (unknownLicenses > 0) {
+ throw new GradleException("Found " + unknownLicenses + " files with " +
+ "unknown licenses.")
+ }
+ }
+
+ def generateHtmlReport() {
+ def antBuilder = services.get(IsolatedAntBuilder)
+ def ratClasspath = project.configurations.rat
+ antBuilder.withClasspath(ratClasspath).execute {
+ ant.xslt(
+ in: xmlReport,
+ style: stylesheet,
+ out: htmlReport,
+ classpath: ratClasspath)
+ }
+ println('Rat report: ' + htmlReport)
+ }
+
+ @TaskAction
+ def rat() {
+ File reportDir = new File(reportPath)
+ if (!reportDir.exists()) {
+ reportDir.mkdirs()
+ }
+ generateXmlReport(reportDir)
+ printUnknownFiles()
+ generateHtmlReport()
+ }
+}
+
+class RatPlugin implements Plugin<Project> {
+ void apply(Project project) {
+ configureDependencies(project)
+ project.plugins.apply(JavaPlugin);
+ Task ratTask = project.task("rat",
+ type: RatTask,
+ group: 'Build',
+ description: 'Runs Apache Rat checks.')
+ project.tasks[JavaPlugin.TEST_TASK_NAME].dependsOn ratTask
+ }
+
+ void configureDependencies(final Project project) {
+ project.configurations {
+ rat
+ }
+ project.repositories {
+ mavenCentral()
+ }
+ project.dependencies {
+ rat 'org.apache.rat:apache-rat-tasks:0.11'
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/gradle/resources/rat-output-to-html.xsl
----------------------------------------------------------------------
diff --git a/gradle/resources/rat-output-to-html.xsl b/gradle/resources/rat-output-to-html.xsl
new file mode 100644
index 0000000..97ea7a1
--- /dev/null
+++ b/gradle/resources/rat-output-to-html.xsl
@@ -0,0 +1,206 @@
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+<!--***********************************************************
+ *
+ * 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 style sheet converts any rat-report.xml file. -->
+
+<xsl:template match="/">
+
+ <html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <style type="text/css">
+ <!--
+body {margin-top: 0px;font-size: 0.8em;background-color: #F9F7ED;}
+
+h1 {color:red;}
+h2 {color:blue;}
+h3 {color:green;}
+h4 {color:orange;}
+
+/* Table Design */
+
+table,tr,td {text-align:center;font-weight:bold;border:1px solid #000;}
+caption {color:blue;text-align:left;}
+.notes, .binaries, .archives, .standards {width:25%;}
+.notes {background:#D7EDEE;}
+.binaries {background:#D0F2F4;}
+.archives {background:#ABE7E9;}
+.standards {background:#A0F0F4;}
+.licenced, .generated {width:50%;}
+.licenced {background:#C6EBDD;}
+.generated {background:#ABE9D2;}
+.java_note {background:#D6EBC6;}
+.generated_note {background:#C9E7A9;}
+.unknown {width:100%;background:#E92020;}
+.unknown-zero {color:#00CC00;}
+.center{text-align:center;margin:0 auto;}
+-->
+ </style>
+ </head>
+ <body>
+ <xsl:apply-templates/>
+ <xsl:call-template name="generated"/>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="rat-report">
+
+ <h1>Rat Report</h1>
+ <p>This HTML version (yes, it is!) is generated from the RAT xml reports using Saxon9B. All the outputs required are displayed below, similar to the .txt version.
+ This is obviously a work in progress; and a prettier, easier to read and manage version will be available soon</p>
+<div class="center">
+<table id="rat-reports summary" cellspacing="0" summary="A snapshot summary of this rat report">
+<caption>
+Table 1: A snapshot summary of this rat report.
+</caption>
+ <tr>
+ <td colspan="1" class="notes">Notes: <xsl:value-of select="count(descendant::type[attribute::name="notice"])"/></td>
+ <td colspan="1" class="binaries">Binaries: <xsl:value-of select="count(descendant::type[attribute::name="binary"])"/></td>
+ <td colspan="1" class="archives">Archives: <xsl:value-of select="count(descendant::type[attribute::name="archive"])"/></td>
+ <td colspan="1" class="standards">Standards: <xsl:value-of select="count(descendant::type[attribute::name="standard"])"/></td>
+ </tr>
+ <tr>
+ <td colspan="2" class="licenced">Apache Licensed: <xsl:value-of select="count(descendant::header-type[attribute::name="AL "])"/></td>
+ <td colspan="2" class="generated">Generated Documents: <xsl:value-of select="count(descendant::header-type[attribute::name="GEN "])"/></td>
+ </tr>
+ <tr>
+ <td colspan="2" class="java_note">Note: JavaDocs are generated and so license header is optional</td>
+ <td colspan="2" class="generated_note">Note: Generated files do not require license headers</td>
+ </tr>
+ <tr>
+<xsl:choose>
+ <xsl:when test="count(descendant::header-type[attribute::name="?????"]) > 0">
+ <td colspan="4" class="unknown"><xsl:value-of select="count(descendant::header-type[attribute::name="?????"])"/> Unknown Licenses - or files without a license.</td>
+ </xsl:when>
+ <xsl:otherwise>
+ <td colspan="4" class="unknown-zero"><xsl:value-of select="count(descendant::header-type[attribute::name="?????"])"/> Unknown Licenses - or files without a license.</td>
+ </xsl:otherwise>
+</xsl:choose>
+ </tr>
+</table>
+</div>
+<hr/>
+ <h3>Unapproved Licenses:</h3>
+
+ <xsl:for-each select="descendant::resource[license-approval/@name="false"]">
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="@name"/><br/>
+ <xsl:text>
+</xsl:text>
+</xsl:for-each>
+<hr/>
+
+<h3>Archives:</h3>
+
+<xsl:for-each select="descendant::resource[type/@name="archive"]">
+ + <xsl:value-of select="@name"/>
+ <br/>
+ </xsl:for-each>
+ <hr/>
+
+ <p>
+ Files with Apache License headers will be marked AL<br/>
+ Binary files (which do not require AL headers) will be marked B<br/>
+ Compressed archives will be marked A<br/>
+ Notices, licenses etc will be marked N<br/>
+ </p>
+
+ <xsl:for-each select="descendant::resource">
+ <xsl:choose>
+ <xsl:when test="license-approval/@name="false"">!</xsl:when>
+ <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="type/@name="notice"">N </xsl:when>
+ <xsl:when test="type/@name="archive"">A </xsl:when>
+ <xsl:when test="type/@name="binary"">B </xsl:when>
+ <xsl:when test="type/@name="standard""><xsl:value-of select="header-type/@name"/></xsl:when>
+ <xsl:otherwise>!!!!!</xsl:otherwise>
+ </xsl:choose>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="@name"/><br/>
+ <xsl:text>
+ </xsl:text>
+ </xsl:for-each>
+ <hr/>
+
+ <h3>Printing headers for files without AL header...</h3>
+
+ <xsl:for-each select="descendant::resource[header-type/@name="?????"]">
+
+ <h4><xsl:value-of select="@name"/></h4>
+ <xsl:value-of select="header-sample"/>
+ <hr/>
+</xsl:for-each>
+<br/>
+
+ <!-- <xsl:apply-templates select="resource"/>
+ <xsl:apply-templates select="header-sample"/>
+ <xsl:apply-templates select="header-type"/>
+ <xsl:apply-templates select="license-family"/>
+ <xsl:apply-templates select="license-approval"/>
+ <xsl:apply-templates select="type"/> -->
+
+</xsl:template>
+
+<xsl:template match="resource">
+ <div>
+ <h3>Resource: <xsl:value-of select="@name"/></h3>
+ <xsl:apply-templates/>
+ </div>
+</xsl:template>
+
+<xsl:template match="header-sample">
+ <xsl:if test="normalize-space(.) != ''">
+ <h4>First few lines of non-compliant file</h4>
+ <p>
+ <xsl:value-of select="."/>
+ </p>
+ </xsl:if>
+ <h4>Other Info:</h4>
+</xsl:template>
+
+<xsl:template match="header-type">
+ Header Type: <xsl:value-of select="@name"/>
+ <br/>
+</xsl:template>
+
+<xsl:template match="license-family">
+ License Family: <xsl:value-of select="@name"/>
+ <br/>
+</xsl:template>
+
+<xsl:template match="license-approval">
+ License Approval: <xsl:value-of select="@name"/>
+ <br/>
+</xsl:template>
+
+<xsl:template match="type">
+ Type: <xsl:value-of select="@name"/>
+ <br/>
+</xsl:template>
+
+<xsl:template name="generated">
+</xsl:template>
+</xsl:transform>
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/kafka-patch-review.py
----------------------------------------------------------------------
diff --git a/kafka-patch-review.py b/kafka-patch-review.py
index b5a2e95..94873c3 100644
--- a/kafka-patch-review.py
+++ b/kafka-patch-review.py
@@ -1,4 +1,21 @@
#!/usr/bin/env python
+#
+# 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.
import argparse
import sys
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/scala.gradle
----------------------------------------------------------------------
diff --git a/scala.gradle b/scala.gradle
index cabb59c..5eb2a65 100644
--- a/scala.gradle
+++ b/scala.gradle
@@ -1,3 +1,18 @@
+// 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.
+
if (!hasProperty('scalaVersion')) {
ext.scalaVersion = '2.10.5'
}
http://git-wip-us.apache.org/repos/asf/kafka/blob/fd612a2d/topics.json
----------------------------------------------------------------------
diff --git a/topics.json b/topics.json
deleted file mode 100644
index ff011ed..0000000
--- a/topics.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{"topics":
- [{"topic": "foo"}],
- "version":1
- }