File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
buildSrc/src/main/java/org/springframework/boot/build/mavenplugin Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 97
97
*
98
98
* @author Andy Wilkinson
99
99
* @author Phillip Webb
100
+ * @author Moritz Halbritter
100
101
*/
101
102
public class MavenPluginPlugin implements Plugin <Project > {
102
103
@@ -377,13 +378,27 @@ private void save(File output, FileEdit edit) {
377
378
Path outputLocation = getOutputDir ().getAsFile ().get ().toPath ().resolve (relativePath );
378
379
try {
379
380
Files .createDirectories (outputLocation .getParent ());
380
- Files .writeString (outputLocation , edit .getFormattedContent ());
381
+ String content = edit .getFormattedContent ();
382
+ content = addNullAwaySuppression (content );
383
+ Files .writeString (outputLocation , content );
381
384
}
382
385
catch (Exception ex ) {
383
386
throw new TaskExecutionException (this , ex );
384
387
}
385
388
}
386
389
390
+ private String addNullAwaySuppression (String content ) {
391
+ String [] lines = content .split ("\n " );
392
+ StringBuilder result = new StringBuilder ();
393
+ for (String line : lines ) {
394
+ if (line .startsWith ("public class " )) {
395
+ result .append ("@SuppressWarnings(\" NullAway\" )" ).append ("\n " );
396
+ }
397
+ result .append (line ).append ("\n " );
398
+ }
399
+ return result .toString ();
400
+ }
401
+
387
402
}
388
403
389
404
public static class MavenRepositoryComponentMetadataRule implements ComponentMetadataRule {
You can’t perform that action at this time.
0 commit comments