Skip to content

Commit da88ac8

Browse files
committed
Move NoHttp config to Gradle conventions
See gh-30339
1 parent a66f3e0 commit da88ac8

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

build.gradle

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
plugins {
2-
id 'io.spring.nohttp' version '0.0.11'
32
id 'io.freefair.aspectj' version '8.0.1' apply false
43
// kotlinVersion is managed in gradle.properties
54
id 'org.jetbrains.kotlin.plugin.serialization' version "${kotlinVersion}" apply false
@@ -121,23 +120,5 @@ configure(moduleProjects) { project ->
121120

122121
configure(rootProject) {
123122
description = "Spring Framework"
124-
125-
apply plugin: "io.spring.nohttp"
126123
apply plugin: 'org.springframework.build.api-diff'
127-
128-
nohttp {
129-
source.exclude "**/test-output/**"
130-
allowlistFile = project.file("src/nohttp/allowlist.lines")
131-
def rootPath = file(rootDir).toPath()
132-
def projectDirs = allprojects.collect { it.projectDir } + "${rootDir}/buildSrc"
133-
projectDirs.forEach { dir ->
134-
[ 'bin', 'build', 'out', '.settings' ]
135-
.collect { rootPath.relativize(new File(dir, it).toPath()) }
136-
.forEach { source.exclude "$it/**" }
137-
[ '.classpath', '.project' ]
138-
.collect { rootPath.relativize(new File(dir, it).toPath()) }
139-
.forEach { source.exclude "$it" }
140-
}
141-
}
142-
143124
}

buildSrc/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ ext {
2020

2121
dependencies {
2222
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}"
23-
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
24-
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlinVersion}")
23+
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
24+
implementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlinVersion}"
2525
implementation "me.champeau.gradle:japicmp-gradle-plugin:0.3.0"
2626
implementation "org.gradle:test-retry-gradle-plugin:1.4.1"
27-
implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}")
27+
implementation "io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}"
28+
implementation "io.spring.nohttp:nohttp-gradle:0.0.11"
2829
}
2930

3031
gradlePlugin {

buildSrc/src/main/java/org/springframework/build/CheckstyleConventions.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
package org.springframework.build;
1818

1919
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;
2122
import org.gradle.api.Plugin;
2223
import org.gradle.api.Project;
2324
import org.gradle.api.artifacts.DependencySet;
@@ -26,6 +27,9 @@
2627
import org.gradle.api.plugins.quality.CheckstyleExtension;
2728
import org.gradle.api.plugins.quality.CheckstylePlugin;
2829

30+
import java.nio.file.Path;
31+
import java.util.List;
32+
2933
/**
3034
* {@link Plugin} that applies conventions for checkstyle.
3135
* @author Brian Clozel
@@ -38,6 +42,9 @@ public class CheckstyleConventions {
3842
*/
3943
public void apply(Project project) {
4044
project.getPlugins().withType(JavaBasePlugin.class, (java) -> {
45+
if (project.getRootProject() == project) {
46+
configureNoHttpPlugin(project);
47+
}
4148
project.getPlugins().apply(CheckstylePlugin.class);
4249
project.getTasks().withType(Checkstyle.class).forEach(checkstyle -> checkstyle.getMaxHeapSize().set("1g"));
4350
CheckstyleExtension checkstyle = project.getExtensions().getByType(CheckstyleExtension.class);
@@ -50,4 +57,20 @@ public void apply(Project project) {
5057
});
5158
}
5259

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+
5376
}

0 commit comments

Comments
 (0)