-
Notifications
You must be signed in to change notification settings - Fork 40.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
1240c59
commit f9379f4
Showing
4 changed files
with
57 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
buildSrc/src/main/java/org/springframework/boot/build/NoHttpConventions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2012-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot.build; | ||
|
||
import io.spring.nohttp.gradle.NoHttpCheckstylePlugin; | ||
import io.spring.nohttp.gradle.NoHttpExtension; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.file.ConfigurableFileTree; | ||
import org.gradle.api.plugins.quality.Checkstyle; | ||
|
||
/** | ||
* Conventions that are applied to enforce that no HTTP urls are used. | ||
* | ||
* @author Phillip Webb | ||
*/ | ||
public class NoHttpConventions { | ||
|
||
void apply(Project project) { | ||
project.getPluginManager().apply(NoHttpCheckstylePlugin.class); | ||
configureNoHttpExtension(project, project.getExtensions().getByType(NoHttpExtension.class)); | ||
project.getTasks() | ||
.named(NoHttpCheckstylePlugin.CHECKSTYLE_NOHTTP_TASK_NAME, Checkstyle.class) | ||
.configure((task) -> task.getConfigDirectory().set(project.getRootProject().file("src/nohttp"))); | ||
} | ||
|
||
private void configureNoHttpExtension(Project project, NoHttpExtension extension) { | ||
extension.setAllowlistFile(project.getRootProject().file("src/nohttp/allowlist.lines")); | ||
ConfigurableFileTree source = extension.getSource(); | ||
source.exclude("bin/**"); | ||
source.exclude("build/**"); | ||
source.exclude("out/**"); | ||
source.exclude("target/**"); | ||
source.exclude(".settings/**"); | ||
source.exclude(".classpath"); | ||
source.exclude(".project"); | ||
source.exclude(".gradle"); | ||
source.exclude("**/docker/export.tar"); | ||
} | ||
|
||
} |