Skip to content

Commit eeee978

Browse files
ScrapCodespwendell
authored andcommitted
[SPARK-1820] Make GenerateMimaIgnore @DeveloperAPI annotation aware.
We add all the classes annotated as `DeveloperApi` to `~/.mima-excludes`. Author: Prashant Sharma <[email protected]> Author: nikhil7sh <[email protected]> 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
1 parent b7e28fa commit eeee978

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import java.util.jar.JarFile
2323
import scala.collection.mutable
2424
import scala.collection.JavaConversions._
2525
import scala.reflect.runtime.universe.runtimeMirror
26+
import scala.reflect.runtime.{universe => unv}
2627

2728
/**
2829
* A tool for generating classes to be excluded during binary checking with MIMA. It is expected
@@ -42,7 +43,7 @@ object GenerateMIMAIgnore {
4243
private def classesPrivateWithin(packageName: String): Set[String] = {
4344

4445
val classes = getClasses(packageName)
45-
val privateClasses = mutable.HashSet[String]()
46+
val ignoredClasses = mutable.HashSet[String]()
4647

4748
def isPackagePrivate(className: String) = {
4849
try {
@@ -70,8 +71,21 @@ object GenerateMIMAIgnore {
7071
}
7172
}
7273

74+
def isDeveloperApi(className: String) = {
75+
try {
76+
val clazz = mirror.classSymbol(Class.forName(className, false, classLoader))
77+
clazz.annotations.exists(_.tpe =:= unv.typeOf[org.apache.spark.annotation.DeveloperApi])
78+
} catch {
79+
case _: Throwable => {
80+
println("Error determining Annotations: " + className)
81+
false
82+
}
83+
}
84+
}
85+
7386
for (className <- classes) {
7487
val directlyPrivateSpark = isPackagePrivate(className)
88+
val developerApi = isDeveloperApi(className)
7589

7690
/* Inner classes defined within a private[spark] class or object are effectively
7791
invisible, so we account for them as package private. */
@@ -83,9 +97,11 @@ object GenerateMIMAIgnore {
8397
false
8498
}
8599
}
86-
if (directlyPrivateSpark || indirectlyPrivateSpark) privateClasses += className
100+
if (directlyPrivateSpark || indirectlyPrivateSpark || developerApi) {
101+
ignoredClasses += className
102+
}
87103
}
88-
privateClasses.flatMap(c => Seq(c, c.replace("$", "#"))).toSet
104+
ignoredClasses.flatMap(c => Seq(c, c.replace("$", "#"))).toSet
89105
}
90106

91107
def main(args: Array[String]) {

0 commit comments

Comments
 (0)