|
27 | 27 | import org.gradle.api.internal.DefaultNamedDomainObjectList; |
28 | 28 | import org.gradle.util.ConfigureUtil; |
29 | 29 |
|
| 30 | +import java.io.File; |
30 | 31 | import java.util.Arrays; |
| 32 | +import java.util.Collections; |
31 | 33 | import java.util.HashMap; |
32 | 34 | import java.util.HashSet; |
33 | 35 | import java.util.Map; |
@@ -57,10 +59,20 @@ public void execute(RecommendationProvider r) { |
57 | 59 | public RecommendationProviderContainer(Project project) { |
58 | 60 | super(RecommendationProvider.class, null, new RecommendationProviderNamer()); |
59 | 61 | this.project = project; |
60 | | - this.mavenBomProvider = new MavenBomRecommendationProvider(this.project, DependencyRecommendationsPlugin.NEBULA_RECOMMENDER_BOM, this.reasons); |
| 62 | + this.mavenBomProvider = getMavenBomRecommendationProvider(); |
61 | 63 | this.add(this.mavenBomProvider); |
62 | 64 | } |
63 | 65 |
|
| 66 | + private MavenBomRecommendationProvider getMavenBomRecommendationProvider() { |
| 67 | + MavenBomRecommendationProvider mavenBomRecommendationProvider; |
| 68 | + if(DependencyRecommendationsPlugin.CORE_BOM_SUPPORT_ENABLED) { |
| 69 | + mavenBomRecommendationProvider = new CoreBomSupportProvider(this.project, DependencyRecommendationsPlugin.NEBULA_RECOMMENDER_BOM, this.reasons); |
| 70 | + } else { |
| 71 | + mavenBomRecommendationProvider = new MavenBomRecommendationProvider(this.project, DependencyRecommendationsPlugin.NEBULA_RECOMMENDER_BOM, this.reasons); |
| 72 | + } |
| 73 | + return mavenBomRecommendationProvider; |
| 74 | + } |
| 75 | + |
64 | 76 | private static class RecommendationProviderNamer implements Namer<RecommendationProvider> { |
65 | 77 | public String determineName(RecommendationProvider r) { |
66 | 78 | return r.getName(); |
@@ -224,4 +236,22 @@ private static void ensureCoreBomSupportNotEnabled(String feature) { |
224 | 236 | throw new GradleException("dependencyRecommender." + feature + " is not available with 'systemProp.nebula.features.coreBomSupport=true'"); |
225 | 237 | } |
226 | 238 | } |
| 239 | + |
| 240 | + //This is to prevent resolving files from nebulaRecommenderBom configuration |
| 241 | + private static class CoreBomSupportProvider extends MavenBomRecommendationProvider { |
| 242 | + public CoreBomSupportProvider(Project project, String configName, Set<String> reasons) { |
| 243 | + super(project, configName, reasons); |
| 244 | + } |
| 245 | + |
| 246 | + @Override |
| 247 | + public String getName() { |
| 248 | + return ""; |
| 249 | + } |
| 250 | + |
| 251 | + @Override |
| 252 | + Set<File> getFilesOnConfiguration() { |
| 253 | + return Collections.emptySet(); |
| 254 | + } |
| 255 | + } |
| 256 | + |
227 | 257 | } |
0 commit comments