|
|
|
@ -98,21 +98,33 @@ public class AutoConfigurationPlugin implements Plugin<Project> { |
|
|
|
.add(AutoConfigurationPlugin.AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME, task.getOutputFile(), |
|
|
|
.add(AutoConfigurationPlugin.AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME, task.getOutputFile(), |
|
|
|
(artifact) -> artifact.builtBy(task)); |
|
|
|
(artifact) -> artifact.builtBy(task)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
project.getPlugins().withType(ArchitecturePlugin.class, (architecturePlugin) -> { |
|
|
|
project.getPlugins() |
|
|
|
project.getTasks().named("checkArchitectureMain", ArchitectureCheck.class).configure((task) -> { |
|
|
|
.withType(ArchitecturePlugin.class, (plugin) -> configureArchitecturePluginTasks(project)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void configureArchitecturePluginTasks(Project project) { |
|
|
|
|
|
|
|
project.getTasks().configureEach((task) -> { |
|
|
|
|
|
|
|
if ("checkArchitectureMain".equals(task.getName()) && task instanceof ArchitectureCheck architectureCheck) { |
|
|
|
|
|
|
|
configureCheckArchitectureMain(project, architectureCheck); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void configureCheckArchitectureMain(Project project, ArchitectureCheck architectureCheck) { |
|
|
|
SourceSet main = project.getExtensions() |
|
|
|
SourceSet main = project.getExtensions() |
|
|
|
.getByType(JavaPluginExtension.class) |
|
|
|
.getByType(JavaPluginExtension.class) |
|
|
|
.getSourceSets() |
|
|
|
.getSourceSets() |
|
|
|
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); |
|
|
|
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); |
|
|
|
File resourcesDirectory = main.getOutput().getResourcesDir(); |
|
|
|
File resourcesDirectory = main.getOutput().getResourcesDir(); |
|
|
|
task.dependsOn(main.getProcessResourcesTaskName()); |
|
|
|
architectureCheck.dependsOn(main.getProcessResourcesTaskName()); |
|
|
|
task.getInputs().files(resourcesDirectory).optional().withPathSensitivity(PathSensitivity.RELATIVE); |
|
|
|
architectureCheck.getInputs() |
|
|
|
task.getRules() |
|
|
|
.files(resourcesDirectory) |
|
|
|
|
|
|
|
.optional() |
|
|
|
|
|
|
|
.withPathSensitivity(PathSensitivity.RELATIVE); |
|
|
|
|
|
|
|
architectureCheck.getRules() |
|
|
|
.add(allClassesAnnotatedWithAutoConfigurationShouldBeListedInAutoConfigurationImports( |
|
|
|
.add(allClassesAnnotatedWithAutoConfigurationShouldBeListedInAutoConfigurationImports( |
|
|
|
autoConfigurationImports(project, resourcesDirectory))); |
|
|
|
autoConfigurationImports(project, resourcesDirectory))); |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ArchRule allClassesAnnotatedWithAutoConfigurationShouldBeListedInAutoConfigurationImports( |
|
|
|
private ArchRule allClassesAnnotatedWithAutoConfigurationShouldBeListedInAutoConfigurationImports( |
|
|
|
|