Upgrade to nullability plugin 0.0.9

This commit also replaces Arch Unit packageInfoShouldBeNullMarked() rule
by either configuring requireExplicitNullMarking = false when the whole
module does not have JSpecify annotations, or explicit @NullUnmarked
when some have and some don't.

See gh-36054
This commit is contained in:
Sébastien Deleuze
2025-12-29 17:08:34 +01:00
parent d36244ee56
commit 46fb7c026c
23 changed files with 61 additions and 15 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ plugins {
id 'com.github.bjornvester.xjc' version '1.8.2' apply false
id 'com.gradleup.shadow' version "9.2.2" apply false
id 'me.champeau.jmh' version '0.7.2' apply false
id 'io.spring.nullability' version '0.0.8' apply false
id 'io.spring.nullability' version '0.0.9' apply false
}
ext {
@@ -49,7 +49,6 @@ import static org.springframework.build.architecture.ArchitectureRules.classesSh
import static org.springframework.build.architecture.ArchitectureRules.javaClassesShouldNotImportKotlinAnnotations;
import static org.springframework.build.architecture.ArchitectureRules.noClassesShouldCallStringToLowerCaseWithoutLocale;
import static org.springframework.build.architecture.ArchitectureRules.noClassesShouldCallStringToUpperCaseWithoutLocale;
import static org.springframework.build.architecture.ArchitectureRules.packageInfoShouldBeNullMarked;
/**
* {@link Task} that checks for architecture problems.
@@ -64,8 +63,7 @@ public abstract class ArchitectureCheck extends DefaultTask {
public ArchitectureCheck() {
getOutputDirectory().convention(getProject().getLayout().getBuildDirectory().dir(getName()));
getProhibitObjectsRequireNonNull().convention(true);
getRules().addAll(packageInfoShouldBeNullMarked(),
classesShouldNotImportForbiddenTypes(),
getRules().addAll(classesShouldNotImportForbiddenTypes(),
javaClassesShouldNotImportKotlinAnnotations(),
allPackagesShouldBeFreeOfTangles(),
noClassesShouldCallStringToLowerCaseWithoutLocale(),
@@ -46,13 +46,6 @@ abstract class ArchitectureRules {
.because("String.toUpperCase(Locale.ROOT) should be used instead");
}
static ArchRule packageInfoShouldBeNullMarked() {
return ArchRuleDefinition.classes()
.that().haveSimpleName("package-info")
.should().beAnnotatedWith("org.jspecify.annotations.NullMarked")
.allowEmptyShould(true);
}
static ArchRule classesShouldNotImportForbiddenTypes() {
return ArchRuleDefinition.noClasses()
.should().dependOnClassesThat()
-4
View File
@@ -105,10 +105,6 @@ tasks.register('javadocJar', Jar) {
from javadoc
}
nullability {
nullAwayVersion = "0.12.15"
}
publishing {
publications {
mavenJava(MavenPublication) {
@@ -7,3 +7,7 @@ dependencies {
testImplementation("jakarta.persistence:jakarta.persistence-api")
testImplementation("jakarta.transaction:jakarta.transaction-api")
}
nullability {
requireExplicitNullMarking = false
}
@@ -1,4 +1,7 @@
/**
* Support for class instrumentation on GlassFish.
*/
@NullUnmarked
package org.springframework.instrument.classloading.glassfish;
import org.jspecify.annotations.NullUnmarked;
@@ -1,4 +1,7 @@
/**
* Support for class instrumentation on JBoss AS 6 and 7.
*/
@NullUnmarked
package org.springframework.instrument.classloading.jboss;
import org.jspecify.annotations.NullUnmarked;
@@ -2,4 +2,7 @@
* Support package for load time weaving based on class loaders,
* as required by JPA providers (but not JPA-specific).
*/
@NullUnmarked
package org.springframework.instrument.classloading;
import org.jspecify.annotations.NullUnmarked;
@@ -1,4 +1,7 @@
/**
* Support for class instrumentation on Tomcat.
*/
@NullUnmarked
package org.springframework.instrument.classloading.tomcat;
import org.jspecify.annotations.NullUnmarked;
@@ -1,4 +1,7 @@
/**
* GraalVM native image features, not part of Spring Framework public API.
*/
@NullUnmarked
package org.springframework.aot.nativex.feature;
import org.jspecify.annotations.NullUnmarked;
@@ -1,4 +1,7 @@
/**
* GraalVM native image substitutions, not part of Spring Framework public API.
*/
@NullUnmarked
package org.springframework.aot.nativex.substitution;
import org.jspecify.annotations.NullUnmarked;
@@ -10,4 +10,7 @@
* <p>As this repackaging happens at the class file level, sources
* and javadocs are not available here.
*/
@NullUnmarked
package org.springframework.asm;
import org.jspecify.annotations.NullUnmarked;
@@ -3,4 +3,7 @@
* <a href="https://github.com/cglib/cglib">CGLIB</a> beans package
* (for internal use only).
*/
@NullUnmarked
package org.springframework.cglib.beans;
import org.jspecify.annotations.NullUnmarked;
@@ -3,4 +3,7 @@
* <a href="https://github.com/cglib/cglib">CGLIB</a> core internal package
* (for internal use only).
*/
@NullUnmarked
package org.springframework.cglib.core.internal;
import org.jspecify.annotations.NullUnmarked;
@@ -3,4 +3,7 @@
* <a href="https://github.com/cglib/cglib">CGLIB</a> core package
* (for internal use only).
*/
@NullUnmarked
package org.springframework.cglib.core;
import org.jspecify.annotations.NullUnmarked;
@@ -7,4 +7,7 @@
* dependencies on CGLIB at the application level or from third-party
* libraries and frameworks.
*/
@NullUnmarked
package org.springframework.cglib;
import org.jspecify.annotations.NullUnmarked;
@@ -3,4 +3,7 @@
* <a href="https://github.com/cglib/cglib">CGLIB</a> proxy package
* (for internal use only).
*/
@NullUnmarked
package org.springframework.cglib.proxy;
import org.jspecify.annotations.NullUnmarked;
@@ -3,4 +3,7 @@
* <a href="https://github.com/cglib/cglib">CGLIB</a> reflect package
* (for internal use only).
*/
@NullUnmarked
package org.springframework.cglib.reflect;
import org.jspecify.annotations.NullUnmarked;
@@ -3,4 +3,7 @@
* <a href="https://github.com/cglib/cglib">CGLIB</a> transform impl package
* (for internal use only).
*/
@NullUnmarked
package org.springframework.cglib.transform.impl;
import org.jspecify.annotations.NullUnmarked;
@@ -3,4 +3,7 @@
* <a href="https://github.com/cglib/cglib">CGLIB</a> transform package
* (for internal use only).
*/
@NullUnmarked
package org.springframework.cglib.transform;
import org.jspecify.annotations.NullUnmarked;
@@ -3,4 +3,7 @@
* <a href="https://github.com/cglib/cglib">CGLIB</a> util package
* (for internal use only).
*/
@NullUnmarked
package org.springframework.cglib.util;
import org.jspecify.annotations.NullUnmarked;
@@ -12,4 +12,7 @@
* <a href="http://objenesis.org/tutorial.html">Objenesis docs</a>
* for details when working with these classes.
*/
@NullUnmarked
package org.springframework.objenesis;
import org.jspecify.annotations.NullUnmarked;
@@ -9,3 +9,7 @@ jar {
manifest.attributes["Can-Retransform-Classes"] = "true"
manifest.attributes["Can-Set-Native-Method-Prefix"] = "false"
}
nullability {
requireExplicitNullMarking = false
}