17
17
package org .springframework .build ;
18
18
19
19
import io .spring .javaformat .gradle .SpringJavaFormatPlugin ;
20
- import io .spring .javaformat .gradle .tasks .Format ;
20
+ import io .spring .nohttp .gradle .NoHttpExtension ;
21
+ import io .spring .nohttp .gradle .NoHttpPlugin ;
21
22
import org .gradle .api .Plugin ;
22
23
import org .gradle .api .Project ;
23
24
import org .gradle .api .artifacts .DependencySet ;
26
27
import org .gradle .api .plugins .quality .CheckstyleExtension ;
27
28
import org .gradle .api .plugins .quality .CheckstylePlugin ;
28
29
30
+ import java .nio .file .Path ;
31
+ import java .util .List ;
32
+
29
33
/**
30
34
* {@link Plugin} that applies conventions for checkstyle.
31
35
* @author Brian Clozel
@@ -38,6 +42,9 @@ public class CheckstyleConventions {
38
42
*/
39
43
public void apply (Project project ) {
40
44
project .getPlugins ().withType (JavaBasePlugin .class , (java ) -> {
45
+ if (project .getRootProject () == project ) {
46
+ configureNoHttpPlugin (project );
47
+ }
41
48
project .getPlugins ().apply (CheckstylePlugin .class );
42
49
project .getTasks ().withType (Checkstyle .class ).forEach (checkstyle -> checkstyle .getMaxHeapSize ().set ("1g" ));
43
50
CheckstyleExtension checkstyle = project .getExtensions ().getByType (CheckstyleExtension .class );
@@ -50,4 +57,20 @@ public void apply(Project project) {
50
57
});
51
58
}
52
59
60
+ private static void configureNoHttpPlugin (Project project ) {
61
+ project .getPlugins ().apply (NoHttpPlugin .class );
62
+ NoHttpExtension noHttp = project .getExtensions ().getByType (NoHttpExtension .class );
63
+ noHttp .setAllowlistFile (project .file ("src/nohttp/allowlist.lines" ));
64
+ noHttp .getSource ().exclude ("**/test-output/**" , "**/.settings/**" ,
65
+ "**/.classpath" , "**/.project" );
66
+ List <String > buildFolders = List .of ("bin" , "build" , "out" );
67
+ project .allprojects (subproject -> {
68
+ Path rootPath = project .getRootDir ().toPath ();
69
+ Path projectPath = rootPath .relativize (subproject .getProjectDir ().toPath ());
70
+ for (String buildFolder : buildFolders ) {
71
+ noHttp .getSource ().exclude (projectPath .resolve (buildFolder ).resolve ("**" ).toString ());
72
+ }
73
+ });
74
+ }
75
+
53
76
}
0 commit comments