mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-21 16:19:42 +00:00
Merge branch 'detekt-task-relocatability' into 3.5.x
Closes gh-49937
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.build;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -107,7 +108,21 @@ class KotlinConventions {
|
||||
project.getPlugins().apply(DetektPlugin.class);
|
||||
DetektExtension detekt = project.getExtensions().getByType(DetektExtension.class);
|
||||
detekt.getConfig().setFrom(project.getRootProject().file("src/detekt/config.yml"));
|
||||
project.getTasks().withType(Detekt.class).configureEach((task) -> task.setJvmTarget(JVM_TARGET));
|
||||
project.getTasks().withType(Detekt.class).configureEach((task) -> {
|
||||
task.setJvmTarget(JVM_TARGET);
|
||||
normalizeMachineSpecificDefaults(project, task);
|
||||
});
|
||||
}
|
||||
|
||||
// See: https://github.com/detekt/detekt/issues/7170
|
||||
private void normalizeMachineSpecificDefaults(Project project, Detekt task) {
|
||||
task.setBasePath(pathRelativeToRootProject(task.getProject()).toString());
|
||||
}
|
||||
|
||||
private static Path pathRelativeToRootProject(Project project) {
|
||||
Path rootProjectDirectory = project.getIsolated().getRootProject().getProjectDirectory().getAsFile().toPath();
|
||||
Path projectDirectory = project.getLayout().getProjectDirectory().getAsFile().toPath();
|
||||
return projectDirectory.relativize(rootProjectDirectory);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user