Skip to content

Commit f9379f4

Browse files
philwebbwilkinsona
authored andcommitted
Apply nohttp check per-project rather than at root
Switch nohttp checks to a convention that is applied per-project rather than at the root. This should help to reduce memory consumption. Closes gh-42332
1 parent 1240c59 commit f9379f4

File tree

4 files changed

+57
-22
lines changed

4 files changed

+57
-22
lines changed

build.gradle

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
11
plugins {
22
id "base"
33
id "org.jetbrains.kotlin.jvm" apply false // https://youtrack.jetbrains.com/issue/KT-30276
4-
id "io.spring.nohttp" version "0.0.11"
54
}
65

76
description = "Spring Boot Build"
87

98
defaultTasks 'build'
109

11-
nohttp {
12-
allowlistFile = project.file("src/nohttp/allowlist.lines")
13-
source.exclude "**/bin/**"
14-
source.exclude "**/build/**"
15-
source.exclude "**/out/**"
16-
source.exclude "**/target/**"
17-
source.exclude "**/.settings/**"
18-
source.exclude "**/.classpath"
19-
source.exclude "**/.project"
20-
source.exclude "spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/docker/export.tar"
21-
}
22-
23-
check {
24-
dependsOn checkstyleNohttp
25-
}
26-
2710
allprojects {
2811
group "org.springframework.boot"
2912

@@ -41,7 +24,3 @@ allprojects {
4124
resolutionStrategy.cacheChangingModulesFor 0, "minutes"
4225
}
4326
}
44-
45-
tasks.named("checkstyleNohttp").configure {
46-
maxHeapSize = "1536m"
47-
}

buildSrc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ dependencies {
5353
implementation("org.springframework:spring-context")
5454
implementation("org.springframework:spring-core")
5555
implementation("org.springframework:spring-web")
56+
implementation("io.spring.nohttp:nohttp-gradle:0.0.11")
5657

5758
testImplementation("org.assertj:assertj-core:${versions.assertj}")
5859
testImplementation("org.hamcrest:hamcrest:${versions.hamcrest}")

buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@ public class ConventionsPlugin implements Plugin<Project> {
4343

4444
@Override
4545
public void apply(Project project) {
46+
new NoHttpConventions().apply(project);
4647
new JavaConventions().apply(project);
4748
new MavenPublishingConventions().apply(project);
4849
new AsciidoctorConventions().apply(project);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2012-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.build;
18+
19+
import io.spring.nohttp.gradle.NoHttpCheckstylePlugin;
20+
import io.spring.nohttp.gradle.NoHttpExtension;
21+
import org.gradle.api.Project;
22+
import org.gradle.api.file.ConfigurableFileTree;
23+
import org.gradle.api.plugins.quality.Checkstyle;
24+
25+
/**
26+
* Conventions that are applied to enforce that no HTTP urls are used.
27+
*
28+
* @author Phillip Webb
29+
*/
30+
public class NoHttpConventions {
31+
32+
void apply(Project project) {
33+
project.getPluginManager().apply(NoHttpCheckstylePlugin.class);
34+
configureNoHttpExtension(project, project.getExtensions().getByType(NoHttpExtension.class));
35+
project.getTasks()
36+
.named(NoHttpCheckstylePlugin.CHECKSTYLE_NOHTTP_TASK_NAME, Checkstyle.class)
37+
.configure((task) -> task.getConfigDirectory().set(project.getRootProject().file("src/nohttp")));
38+
}
39+
40+
private void configureNoHttpExtension(Project project, NoHttpExtension extension) {
41+
extension.setAllowlistFile(project.getRootProject().file("src/nohttp/allowlist.lines"));
42+
ConfigurableFileTree source = extension.getSource();
43+
source.exclude("bin/**");
44+
source.exclude("build/**");
45+
source.exclude("out/**");
46+
source.exclude("target/**");
47+
source.exclude(".settings/**");
48+
source.exclude(".classpath");
49+
source.exclude(".project");
50+
source.exclude(".gradle");
51+
source.exclude("**/docker/export.tar");
52+
}
53+
54+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy