diff --git a/gradle/config/japicmp/accepted-breaking-changes.txt b/gradle/config/japicmp/accepted-breaking-changes.txt deleted file mode 100644 index 19c25d71f94d..000000000000 --- a/gradle/config/japicmp/accepted-breaking-changes.txt +++ /dev/null @@ -1,2 +0,0 @@ -org.junit.jupiter.params.provider.CsvFileSource#commentCharacter -org.junit.jupiter.params.provider.CsvSource#commentCharacter diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4a91ddd401a1..39830c3ea0a9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -103,7 +103,6 @@ download = { id = "de.undercouch.download", version = "5.6.0" } errorProne = { id = "net.ltgt.errorprone", version = "4.3.0" } foojayResolver = { id = "org.gradle.toolchains.foojay-resolver", version = "1.0.0" } gitPublish = { id = "org.ajoberstar.git-publish", version = "5.1.3" } -japicmp = { id = "me.champeau.gradle.japicmp", version = "0.4.6" } jmh = { id = "me.champeau.jmh", version = "0.7.3" } jreleaser = { id = "org.jreleaser", version = "1.21.0" } # check if workaround in gradle.properties can be removed when updating diff --git a/gradle/plugins/backward-compatibility/build.gradle.kts b/gradle/plugins/backward-compatibility/build.gradle.kts index af1554853013..b7a1788ffc5e 100644 --- a/gradle/plugins/backward-compatibility/build.gradle.kts +++ b/gradle/plugins/backward-compatibility/build.gradle.kts @@ -8,7 +8,6 @@ plugins { dependencies { implementation("junitbuild.base:dsl-extensions") implementation(libs.plugins.download.markerCoordinates) - implementation(libs.plugins.japicmp.markerCoordinates) implementation(libs.jackson.dataformat.yaml) } diff --git a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild.backward-compatibility.gradle.kts b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild.backward-compatibility.gradle.kts index 2bea5fbc2387..3d1d945ed27a 100644 --- a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild.backward-compatibility.gradle.kts +++ b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild.backward-compatibility.gradle.kts @@ -1,23 +1,12 @@ import de.undercouch.gradle.tasks.download.Download import junitbuild.compatibility.BackwardCompatibilityChecksExtension -import junitbuild.compatibility.japicmp.AcceptedViolationSuppressor -import junitbuild.compatibility.japicmp.AcceptedViolationsPostProcessRule -import junitbuild.compatibility.japicmp.BreakingSuperClassChangeRule -import junitbuild.compatibility.japicmp.InternalApiFilter -import junitbuild.compatibility.japicmp.SourceIncompatibleRule import junitbuild.compatibility.roseau.RoseauDiff import junitbuild.extensions.dependencyFromLibs -import junitbuild.extensions.javaModuleName -import me.champeau.gradle.japicmp.JapicmpTask -import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule -import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup -import org.gradle.internal.os.OperatingSystem plugins { java id("de.undercouch.download") - id("me.champeau.gradle.japicmp") } val roseauDependencies = configurations.dependencyScope("roseau") @@ -38,16 +27,6 @@ dependencies { val extension = extensions.create("backwardCompatibilityChecks").apply { enabled.convention(true) - acceptedIncompatibilities.apply { - val acceptedBreakingChangesFile = rootProject.layout.projectDirectory.file("gradle/config/japicmp/accepted-breaking-changes.txt") - if (acceptedBreakingChangesFile.asFile.exists()) { - convention(providers.fileContents(acceptedBreakingChangesFile).asText - .map { it.lineSequence().filter { line -> line.startsWith(project.javaModuleName) }.toList() }) - } else { - empty() - } - finalizeValueOnRead() - } previousVersion.apply { convention(providers.gradleProperty("apiBaselineVersion")) finalizeValueOnRead() @@ -61,7 +40,7 @@ val downloadPreviousReleaseJar by tasks.registering(Download::class) { onlyIf { extension.enabled.get() } val previousVersion = extension.previousVersion.get() src("https://repo1.maven.org/maven2/${project.group.toString().replace(".", "/")}/${project.name}/$previousVersion/${project.name}-$previousVersion.jar") - dest(layout.buildDirectory.dir("japicmp")) + dest(layout.buildDirectory.dir("previousRelease")) overwrite(false) quiet(true) retries(2) @@ -89,48 +68,10 @@ val roseau by tasks.registering(RoseauDiff::class) { reportDir = layout.buildDirectory.dir("reports/roseau") } -val japicmp by tasks.registering(JapicmpTask::class) { - if (gradle.startParameter.isOffline) { - enabled = false - } - onlyIf { extension.enabled.get() } - shouldRunAfter(roseau) - - oldClasspath.from(downloadPreviousReleaseJar.map { it.outputFiles }) - newClasspath.from(tasks.jar) - onlyModified = true - ignoreMissingClasses = true - htmlOutputFile = layout.buildDirectory.file("reports/japicmp/plain-report.html") - addExcludeFilter(InternalApiFilter::class.java) - packageExcludes.add("*.shadow.*") - inputs.property("acceptedIncompatibilities", extension.acceptedIncompatibilities) - richReport { - title = "Compatibility report" - description = extension.previousVersion.map { "and source compatibility compared against $it" } - destinationDir = layout.buildDirectory.dir("reports/japicmp") - addSetupRule(RecordSeenMembersSetup::class.java) - addRule(BreakingSuperClassChangeRule::class.java) - addRule(BinaryIncompatibleRule::class.java) - addRule(SourceIncompatibleRule::class.java) - } -} - val checkBackwardCompatibility by tasks.registering { - dependsOn(roseau, japicmp) + dependsOn(roseau) } tasks.check { dependsOn(checkBackwardCompatibility) } - -afterEvaluate { - val params = mapOf( - "acceptedIncompatibilities" to extension.acceptedIncompatibilities.get().joinToString(",") - ) - japicmp { - richReport { - addViolationTransformer(AcceptedViolationSuppressor::class.java, params) - addPostProcessRule(AcceptedViolationsPostProcessRule::class.java, params) - } - } -} diff --git a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/BackwardCompatibilityChecksExtension.kt b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/BackwardCompatibilityChecksExtension.kt index a75512920b05..3b4984d29849 100644 --- a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/BackwardCompatibilityChecksExtension.kt +++ b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/BackwardCompatibilityChecksExtension.kt @@ -1,7 +1,6 @@ package junitbuild.compatibility import org.gradle.api.provider.Property -import org.gradle.api.provider.SetProperty abstract class BackwardCompatibilityChecksExtension { @@ -9,6 +8,4 @@ abstract class BackwardCompatibilityChecksExtension { abstract val previousVersion: Property - abstract val acceptedIncompatibilities: SetProperty - } diff --git a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/AcceptedViolationSuppressor.kt b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/AcceptedViolationSuppressor.kt deleted file mode 100644 index ca19ecfda2f6..000000000000 --- a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/AcceptedViolationSuppressor.kt +++ /dev/null @@ -1,43 +0,0 @@ -package junitbuild.compatibility.japicmp - -import japicmp.model.JApiBehavior -import japicmp.model.JApiClass -import japicmp.model.JApiCompatibility -import japicmp.model.JApiField -import japicmp.model.JApiImplementedInterface -import me.champeau.gradle.japicmp.report.Severity.accepted -import me.champeau.gradle.japicmp.report.Violation -import me.champeau.gradle.japicmp.report.ViolationTransformer -import java.util.* - -class AcceptedViolationSuppressor(params: Map) : ViolationTransformer { - - val acceptedIncompatibilities = params["acceptedIncompatibilities"]!!.split(',').filter { !it.isEmpty() }.toSet() - - override fun transform(type: String?, violation: Violation): Optional = when { - violation.isRedundant() -> Optional.empty() - violation.isAccepted() -> Optional.of(violation.withSeverity(accepted)) - else -> Optional.of(violation) - } - - private fun Violation.isRedundant(): Boolean = - // The changes about the interface's methods will be reported already - member is JApiImplementedInterface - // Allow new classes to be added - || member.isInNewClass() - // A member of the class breaks binary or source compatibility and will be reported - || (member is JApiClass && member.compatibilityChanges.none { !it.isBinaryCompatible || !it.isSourceCompatible } && !member.isBreakingSuperClassChange()) - - private fun Violation.isAccepted(): Boolean = - acceptedIncompatibilities.contains(member.fullyQualifiedName) - || acceptedIncompatibilities.contains(member.fullyQualifiedClassName) - - private fun JApiCompatibility.isInNewClass(): Boolean { - return when (this) { - is JApiClass -> oldClass.isEmpty - is JApiBehavior -> getjApiClass().isInNewClass() - is JApiField -> getjApiClass().isInNewClass() - else -> false - } - } -} diff --git a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/AcceptedViolationsPostProcessRule.kt b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/AcceptedViolationsPostProcessRule.kt deleted file mode 100644 index 6f44e04dc69e..000000000000 --- a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/AcceptedViolationsPostProcessRule.kt +++ /dev/null @@ -1,32 +0,0 @@ -package junitbuild.compatibility.japicmp - -import me.champeau.gradle.japicmp.report.PostProcessViolationsRule -import me.champeau.gradle.japicmp.report.Severity.accepted -import me.champeau.gradle.japicmp.report.ViolationCheckContextWithViolations - -class AcceptedViolationsPostProcessRule(params: Map) : PostProcessViolationsRule { - - val acceptedViolations = params["acceptedIncompatibilities"]!!.split(',').filter { !it.isEmpty() }.toSet() - - override fun execute(context: ViolationCheckContextWithViolations) { - - val actualViolations = context.violations.asSequence() - .flatMap { it.value.asSequence() } - .filter { it.severity == accepted } - .map { it.member } - .flatMap { - sequenceOf( - it.fullyQualifiedClassName, - it.fullyQualifiedName - ) - } - .toSet() - - val diff = acceptedViolations - actualViolations - - require(diff.isEmpty()) { - "The following elements are listed as 'accepted' but are not actually violations:\n- ${diff.joinToString("\n- ")}" - } - } - -} diff --git a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/BreakingSuperClassChangeRule.kt b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/BreakingSuperClassChangeRule.kt deleted file mode 100644 index 02fd1d77d24a..000000000000 --- a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/BreakingSuperClassChangeRule.kt +++ /dev/null @@ -1,16 +0,0 @@ -package junitbuild.compatibility.japicmp - -import japicmp.model.JApiCompatibility -import me.champeau.gradle.japicmp.report.Violation -import me.champeau.gradle.japicmp.report.stdrules.AbstractRecordingSeenMembers - -// Required due to https://github.com/melix/japicmp-gradle-plugin/issues/56 -class BreakingSuperClassChangeRule : AbstractRecordingSeenMembers() { - - override fun maybeAddViolation(element: JApiCompatibility): Violation? { - return when { - element.isBreakingSuperClassChange() -> Violation.error(element, "Is not binary compatible due to super class change") - else -> null - } - } -} diff --git a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/InternalApiFilter.kt b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/InternalApiFilter.kt deleted file mode 100644 index 63866548f390..000000000000 --- a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/InternalApiFilter.kt +++ /dev/null @@ -1,51 +0,0 @@ -package junitbuild.compatibility.japicmp - -import japicmp.filter.BehaviorFilter -import japicmp.filter.ClassFilter -import japicmp.filter.FieldFilter -import javassist.ClassPool -import javassist.CtBehavior -import javassist.CtClass -import javassist.CtField -import javassist.NotFoundException -import javassist.bytecode.AnnotationsAttribute -import javassist.bytecode.AttributeInfo -import javassist.bytecode.annotation.EnumMemberValue - -class InternalApiFilter : ClassFilter, BehaviorFilter, FieldFilter { - - override fun matches(clazz: CtClass): Boolean = - isInternal(clazz) - || isInternal(getEnclosingClass(clazz.name, clazz.classPool)) - - override fun matches(behavior: CtBehavior) = - isInternal(behavior.methodInfo.getAttribute(AnnotationsAttribute.visibleTag)) - || isInternal(behavior.declaringClass) - - override fun matches(field: CtField) = - isInternal(field.fieldInfo.getAttribute(AnnotationsAttribute.visibleTag)) - || isInternal(field.declaringClass) - - private fun getEnclosingClass(className: String, classPool: ClassPool): CtClass? { - if (className.contains("$")) { - val enclosingClassName = className.substringBeforeLast("$") - return try { - classPool.get(enclosingClassName) - } catch (e: NotFoundException) { - getEnclosingClass(enclosingClassName, classPool) - } - } - return null - } - - private fun isInternal(clazz: CtClass?): Boolean = - isInternal(clazz?.classFile?.getAttribute(AnnotationsAttribute.visibleTag)) - - private fun isInternal(attribute: AttributeInfo?): Boolean { - return (attribute as AnnotationsAttribute?) - ?.annotations - ?.firstOrNull { it.typeName == "org.apiguardian.api.API" } - ?.let { (it.getMemberValue("status") as EnumMemberValue).value == "INTERNAL" } ?: false - } - -} diff --git a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/JApiCompatibilityExtensions.kt b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/JApiCompatibilityExtensions.kt deleted file mode 100644 index b72ae2d68380..000000000000 --- a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/JApiCompatibilityExtensions.kt +++ /dev/null @@ -1,31 +0,0 @@ -package junitbuild.compatibility.japicmp - -import japicmp.model.JApiBehavior -import japicmp.model.JApiClass -import japicmp.model.JApiCompatibility -import japicmp.model.JApiField - -internal val JApiCompatibility.fullyQualifiedName: String - get() = when (this) { - is JApiClass -> fullyQualifiedClassName - is JApiBehavior -> "${fullyQualifiedClassName}#${name}" - is JApiField -> "${fullyQualifiedClassName}#${name}" - else -> throw IllegalArgumentException("Could not determine fully-qualified name for $this") - } - -internal val JApiCompatibility.fullyQualifiedClassName: String - get() = when (this) { - is JApiClass -> fullyQualifiedName - is JApiBehavior -> getjApiClass().fullyQualifiedName - is JApiField -> getjApiClass().fullyQualifiedName - else -> throw IllegalArgumentException("Could not determine fully-qualified class name for $this") - } - -internal fun JApiCompatibility.isBreakingSuperClassChange(): Boolean { - if (this !is JApiClass || superclass.isBinaryCompatible || superclass.compatibilityChanges.isEmpty()) { - return false - } - // breaking change would otherwise be reported - return oldClass.isPresent && newClass.isPresent - -} diff --git a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/SourceIncompatibleRule.kt b/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/SourceIncompatibleRule.kt deleted file mode 100644 index b9f537f65f92..000000000000 --- a/gradle/plugins/backward-compatibility/src/main/kotlin/junitbuild/compatibility/japicmp/SourceIncompatibleRule.kt +++ /dev/null @@ -1,13 +0,0 @@ -package junitbuild.compatibility.japicmp - -import japicmp.model.JApiCompatibility -import me.champeau.gradle.japicmp.report.Violation -import me.champeau.gradle.japicmp.report.stdrules.AbstractRecordingSeenMembers - -class SourceIncompatibleRule : AbstractRecordingSeenMembers() { - - override fun maybeAddViolation(member: JApiCompatibility): Violation? = when { - !member.isSourceCompatible -> Violation.error(member, "Is not source compatible") - else -> null - } -} diff --git a/junit-jupiter-api/junit-jupiter-api.gradle.kts b/junit-jupiter-api/junit-jupiter-api.gradle.kts index 89345e9d6cde..52ae4c77e66d 100644 --- a/junit-jupiter-api/junit-jupiter-api.gradle.kts +++ b/junit-jupiter-api/junit-jupiter-api.gradle.kts @@ -35,9 +35,6 @@ tasks { compileJava { options.compilerArgs.add("-Xlint:-module") // due to qualified exports } - japicmp { - classExcludes.addAll($$"*.AssertionsKt$assert*", $$"*.AssertionsKt$evaluate*") - } jar { bundle { val version = project.version