mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-26 20:09:02 +00:00
Annotated the generated code by helpmojo with NullSafe suppressions
See gh-46587
This commit is contained in:
+16
-1
@@ -97,6 +97,7 @@ import org.springframework.core.CollectionFactory;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
public class MavenPluginPlugin implements Plugin<Project> {
|
||||
|
||||
@@ -377,13 +378,27 @@ public class MavenPluginPlugin implements Plugin<Project> {
|
||||
Path outputLocation = getOutputDir().getAsFile().get().toPath().resolve(relativePath);
|
||||
try {
|
||||
Files.createDirectories(outputLocation.getParent());
|
||||
Files.writeString(outputLocation, edit.getFormattedContent());
|
||||
String content = edit.getFormattedContent();
|
||||
content = addNullAwaySuppression(content);
|
||||
Files.writeString(outputLocation, content);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new TaskExecutionException(this, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private String addNullAwaySuppression(String content) {
|
||||
String[] lines = content.split("\n");
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String line : lines) {
|
||||
if (line.startsWith("public class ")) {
|
||||
result.append("@SuppressWarnings(\"NullAway\")").append("\n");
|
||||
}
|
||||
result.append(line).append("\n");
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class MavenRepositoryComponentMetadataRule implements ComponentMetadataRule {
|
||||
|
||||
Reference in New Issue
Block a user