Skip to content

Commit 88dc121

Browse files
committed
Do not report breaking changes for new classes
1 parent a316f7c commit 88dc121

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

gradle/plugins/japicmp/src/main/kotlin/junitbuild/japicmp/UnacceptedIncompatibilityRule.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package junitbuild.japicmp
22

3+
import japicmp.model.JApiBehavior
34
import japicmp.model.JApiClass
45
import japicmp.model.JApiCompatibility
6+
import japicmp.model.JApiField
57
import japicmp.model.JApiImplementedInterface
68
import me.champeau.gradle.japicmp.report.Violation
79
import me.champeau.gradle.japicmp.report.stdrules.AbstractRecordingSeenMembers
@@ -20,10 +22,22 @@ class UnacceptedIncompatibilityRule(params: Map<String, String>): AbstractRecord
2022
// The changes about the interface's methods will be reported already
2123
return null
2224
}
25+
if (isInNewClass(element)) {
26+
return null
27+
}
2328
return if (!element.isBinaryCompatible) {
2429
Violation.notBinaryCompatible(element, severitySource.determineSeverity(element))
2530
} else if (!element.isSourceCompatible) {
2631
Violation.any(element, severitySource.determineSeverity(element), "Is not source compatible")
2732
} else null
2833
}
34+
35+
private fun isInNewClass(element: JApiCompatibility): Boolean {
36+
return when (element) {
37+
is JApiClass -> element.oldClass.isEmpty
38+
is JApiBehavior -> isInNewClass(element.getjApiClass())
39+
is JApiField -> isInNewClass(element.getjApiClass())
40+
else -> false
41+
}
42+
}
2943
}

0 commit comments

Comments
 (0)