You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by pw...@apache.org on 2014/05/30 08:20:26 UTC

git commit: [SPARK-1820] Make GenerateMimaIgnore @DeveloperApi annotation aware.

Repository: spark
Updated Branches:
  refs/heads/master b7e28fa45 -> eeee978a3


[SPARK-1820] Make GenerateMimaIgnore @DeveloperApi annotation aware.

We add all the classes annotated as `DeveloperApi` to `~/.mima-excludes`.

Author: Prashant Sharma <pr...@imaginea.com>
Author: nikhil7sh <ni...@gmail.ccom>

Closes #904 from ScrapCodes/SPARK-1820/ignore-Developer-Api and squashes the following commits:

de944f9 [Prashant Sharma] Code review.
e3c5215 [Prashant Sharma] Incorporated patrick's suggestions and fixed the scalastyle build.
9983a42 [nikhil7sh] [SPARK-1820] Make GenerateMimaIgnore @DeveloperApi annotation aware


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/eeee978a
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/eeee978a
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/eeee978a

Branch: refs/heads/master
Commit: eeee978a348ec2a35cc27865cea6357f9db75b74
Parents: b7e28fa
Author: Prashant Sharma <pr...@imaginea.com>
Authored: Thu May 29 23:20:20 2014 -0700
Committer: Patrick Wendell <pw...@gmail.com>
Committed: Thu May 29 23:20:20 2014 -0700

----------------------------------------------------------------------
 .../apache/spark/tools/GenerateMIMAIgnore.scala | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/eeee978a/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala
----------------------------------------------------------------------
diff --git a/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala b/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala
index a433e8e..011db50 100644
--- a/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala
+++ b/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala
@@ -23,6 +23,7 @@ import java.util.jar.JarFile
 import scala.collection.mutable
 import scala.collection.JavaConversions._
 import scala.reflect.runtime.universe.runtimeMirror
+import scala.reflect.runtime.{universe => unv}
 
 /**
  * A tool for generating classes to be excluded during binary checking with MIMA. It is expected
@@ -42,7 +43,7 @@ object GenerateMIMAIgnore {
   private def classesPrivateWithin(packageName: String): Set[String] = {
 
     val classes = getClasses(packageName)
-    val privateClasses = mutable.HashSet[String]()
+    val ignoredClasses = mutable.HashSet[String]()
 
     def isPackagePrivate(className: String) = {
       try {
@@ -70,8 +71,21 @@ object GenerateMIMAIgnore {
       }
     }
 
+    def isDeveloperApi(className: String) = {
+      try {
+        val clazz = mirror.classSymbol(Class.forName(className, false, classLoader))
+        clazz.annotations.exists(_.tpe =:= unv.typeOf[org.apache.spark.annotation.DeveloperApi])
+      } catch {
+        case _: Throwable => {
+          println("Error determining Annotations: " + className)
+          false
+        }
+      }
+    }
+
     for (className <- classes) {
       val directlyPrivateSpark = isPackagePrivate(className)
+      val developerApi = isDeveloperApi(className)
 
       /* Inner classes defined within a private[spark] class or object are effectively
          invisible, so we account for them as package private. */
@@ -83,9 +97,11 @@ object GenerateMIMAIgnore {
           false
         }
       }
-      if (directlyPrivateSpark || indirectlyPrivateSpark) privateClasses += className
+      if (directlyPrivateSpark || indirectlyPrivateSpark || developerApi) {
+        ignoredClasses += className
+      }
     }
-    privateClasses.flatMap(c => Seq(c, c.replace("$", "#"))).toSet
+    ignoredClasses.flatMap(c => Seq(c, c.replace("$", "#"))).toSet
   }
 
   def main(args: Array[String]) {