2424import org .gradle .api .artifacts .Dependency ;
2525import org .gradle .api .internal .ConfigureByMapAction ;
2626import org .gradle .api .model .ObjectFactory ;
27+ import org .gradle .api .provider .Property ;
28+ import org .gradle .api .provider .SetProperty ;
2729
2830import java .io .File ;
2931import java .lang .reflect .InvocationTargetException ;
@@ -36,13 +38,13 @@ public class RecommendationProviderContainer {
3638
3739 private Project project ;
3840 private NamedDomainObjectList <RecommendationProvider > providers ;
39- private RecommendationStrategies strategy = RecommendationStrategies . ConflictResolved ;
41+ private final Property < RecommendationStrategies > strategy ;
4042 private MavenBomRecommendationProvider mavenBomProvider ;
41- private Boolean strictMode = false ;
42- private Set <String > excludedConfigurations = new HashSet <>() ;
43- private Set <String > excludedConfigurationPrefixes = new HashSet <>() ;
44- private Set <String > reasons = new HashSet <>();
45- private Boolean eagerlyResolve = true ;
43+ private final Property < Boolean > strictMode ;
44+ private final SetProperty <String > excludedConfigurations ;
45+ private final SetProperty <String > excludedConfigurationPrefixes ;
46+ private Set <String > reasons = new HashSet <>(); // Keep as regular Set - it's an output/result collection
47+ private final Property < Boolean > eagerlyResolve ;
4648
4749 // Make strategies available without import
4850 public static final RecommendationStrategies OverrideTransitives = RecommendationStrategies .OverrideTransitives ;
@@ -51,6 +53,20 @@ public class RecommendationProviderContainer {
5153 public RecommendationProviderContainer (Project project ) {
5254 createList (project );
5355 this .project = project ;
56+
57+ // Initialize properties using ObjectFactory for proper Gradle integration
58+ ObjectFactory objects = project .getObjects ();
59+ this .strategy = objects .property (RecommendationStrategies .class )
60+ .convention (RecommendationStrategies .ConflictResolved );
61+ this .strictMode = objects .property (Boolean .class )
62+ .convention (false );
63+ this .excludedConfigurations = objects .setProperty (String .class )
64+ .convention (new HashSet <>());
65+ this .excludedConfigurationPrefixes = objects .setProperty (String .class )
66+ .convention (new HashSet <>());
67+ this .eagerlyResolve = objects .property (Boolean .class )
68+ .convention (true );
69+
5470 this .mavenBomProvider = getMavenBomRecommendationProvider ();
5571 providers .add (this .mavenBomProvider );
5672 }
@@ -214,83 +230,71 @@ public String getRecommendedVersion(String group, String name) {
214230 return null ;
215231 }
216232
217- public RecommendationStrategies getStrategy () {
233+ public Property < RecommendationStrategies > getStrategy () {
218234 return strategy ;
219235 }
220236
221- public void setStrategy (RecommendationStrategies strategy ) {
222- this .strategy = strategy ;
223- }
224-
237+ /**
238+ * @deprecated Use {@link #getStrategy()}.set() instead
239+ */
225240 @ Deprecated
226- public Boolean isStrictMode ( ) {
227- return getStrictMode ( );
241+ public void setStrategy ( RecommendationStrategies value ) {
242+ strategy . set ( value );
228243 }
229244
230- public Boolean getStrictMode () {
245+ public Property < Boolean > getStrictMode () {
231246 return strictMode ;
232247 }
233248
234- public void setStrictMode (Boolean strict ) {
235- strictMode = strict ;
249+ /**
250+ * @deprecated Use {@link #getStrictMode()}.set() instead
251+ */
252+ @ Deprecated
253+ public void setStrictMode (Boolean value ) {
254+ strictMode .set (value );
236255 }
237256
238257 /**
239- * Sets whether BOM configurations should be resolved eagerly during the configuration phase .
240- *
241- * <p>When set to {@code true} (default), BOM configurations will be resolved automatically
242- * during the {@code afterEvaluate} phase to prevent configuration resolution lock conflicts
258+ * Returns the Property controlling whether BOM configurations should be resolved eagerly.
259+ *
260+ * <p>When set to {@code true} (default), BOM configurations will be resolved automatically
261+ * during the {@code afterEvaluate} phase to prevent configuration resolution lock conflicts
243262 * in parallel builds with Gradle 9+.</p>
244- *
263+ *
245264 * <p>When set to {@code false}, external plugins can take control of BOM resolution timing
246- * by calling {@link netflix.nebula.dependency.recommender.util.BomResolutionUtil#eagerlyResolveBoms}
265+ * by calling {@link netflix.nebula.dependency.recommender.util.BomResolutionUtil#eagerlyResolveBoms}
247266 * manually after modifying BOM configurations.</p>
248- *
249- * <p><strong>Usage by External Plugins:</strong></p>
250- * <pre>{@code
251- * // Disable automatic eager resolution
252- * dependencyRecommendations {
253- * setEagerlyResolve(false)
254- *
255- * // Add initial BOMs
256- * mavenBom module: 'com.example:base-bom:1.0.0'
257- * }
258- *
259- * project.afterEvaluate { p ->
260- * def container = p.extensions.getByType(RecommendationProviderContainer)
261- *
262- * // Add additional BOMs dynamically
263- * container.mavenBom(module: 'com.example:dynamic-bom:2.0.0')
264- *
265- * // Manually trigger resolution
266- * BomResolutionUtil.eagerlyResolveBoms(p, container, 'nebulaRecommenderBom')
267- * }
268- * }</pre>
269- *
270- * @param eagerlyResolve {@code true} to enable automatic eager resolution,
271- * {@code false} to disable it and allow manual control
267+ *
268+ * @return Property containing the eagerly resolve flag
272269 * @since 12.7.0
273270 * @see netflix.nebula.dependency.recommender.util.BomResolutionUtil#eagerlyResolveBoms
274271 */
275- public void setEagerlyResolve ( Boolean eagerlyResolve ) {
276- this . eagerlyResolve = eagerlyResolve ;
272+ public Property < Boolean > getEagerlyResolve ( ) {
273+ return eagerlyResolve ;
277274 }
278275
279276 /**
280- * Returns whether BOM configurations should be resolved eagerly during the configuration phase.
281- *
282- * <p>This setting controls whether the dependency recommender plugin automatically resolves
283- * BOM configurations during {@code afterEvaluate}, or whether external plugins should
284- * handle resolution timing manually.</p>
285- *
286- * @return {@code true} if BOMs should be resolved eagerly (default),
277+ * Convenience method to check if BOMs should be resolved eagerly.
278+ *
279+ * @return {@code true} if BOMs should be resolved eagerly (default),
287280 * {@code false} if resolution should be handled manually
288281 * @since 12.7.0
289- * @see #setEagerlyResolve(Boolean)
290- * @see netflix.nebula.dependency.recommender.util.BomResolutionUtil#shouldEagerlyResolveBoms
291282 */
292283 public Boolean shouldEagerlyResolve () {
293- return eagerlyResolve ;
284+ return eagerlyResolve .get ();
285+ }
286+
287+ /**
288+ * Convenience method to set whether BOMs should be resolved eagerly.
289+ *
290+ * @param value {@code true} to enable automatic eager resolution,
291+ * {@code false} to disable it and allow manual control
292+ * @since 12.7.0
293+ * @deprecated Use {@link #getEagerlyResolve()}.set() instead
294+ */
295+ @ Deprecated
296+ public void setEagerlyResolve (Boolean value ) {
297+ eagerlyResolve .set (value );
294298 }
295299
296300 public void excludeConfigurations (String ... names ) {
@@ -301,11 +305,11 @@ public void excludeConfigurationPrefixes(String ... names) {
301305 excludedConfigurationPrefixes .addAll (Arrays .asList (names ));
302306 }
303307
304- public Set <String > getExcludedConfigurations () {
308+ public SetProperty <String > getExcludedConfigurations () {
305309 return excludedConfigurations ;
306310 }
307311
308- public Set <String > getExcludedConfigurationPrefixes () {
312+ public SetProperty <String > getExcludedConfigurationPrefixes () {
309313 return excludedConfigurationPrefixes ;
310314 }
311315
0 commit comments