88import java .util .HashSet ;
99import java .util .List ;
1010import java .util .Map ;
11+ import java .util .Optional ;
1112import java .util .Set ;
1213import java .util .concurrent .atomic .AtomicInteger ;
1314
@@ -171,13 +172,13 @@ public static void setCommonAttributes(AttributeContainer attrs, ObjectFactory o
171172 * @param mode launch mode
172173 */
173174 public static void addVariants (Project project , LaunchMode mode ,
174- Property <ManualPlatformSpec > manualPlatformConfig ) {
175- new QuarkusComponentVariants (project , mode , manualPlatformConfig ).configureAndAddVariants ();
175+ Property <PlatformSpec > platformSpecProperty ) {
176+ new QuarkusComponentVariants (project , mode , platformSpecProperty ).configureAndAddVariants ();
176177 }
177178
178179 private final Attribute <String > quarkusDepAttr ;
179180 private final Project project ;
180- private final Property <ManualPlatformSpec > manualPlatformConfig ;
181+ private final Property <PlatformSpec > platformSpecProperty ;
181182 private final Map <ArtifactKey , ProcessedDependency > processedDeps = new HashMap <>();
182183 private final Map <ArtifactKey , ConditionalDependency > allConditionalDeps = new HashMap <>();
183184 private final List <ConditionalDependencyVariant > dependencyVariantQueue = new ArrayList <>();
@@ -186,10 +187,10 @@ public static void addVariants(Project project, LaunchMode mode,
186187 private final AtomicInteger configCopyCounter = new AtomicInteger ();
187188
188189 private QuarkusComponentVariants (Project project , LaunchMode mode ,
189- Property <ManualPlatformSpec > manualPlatformConfig ) {
190+ Property <PlatformSpec > platformSpecProperty ) {
190191 this .project = project ;
191192 this .mode = mode ;
192- this .manualPlatformConfig = manualPlatformConfig ;
193+ this .platformSpecProperty = platformSpecProperty ;
193194 this .quarkusDepAttr = getConditionalDependencyAttribute (project .getName (), mode );
194195 project .getDependencies ().getAttributesSchema ().attribute (quarkusDepAttr );
195196 project .getDependencies ().getAttributesSchema ().attribute (getDeploymentDependencyAttribute (project .getName (), mode ));
@@ -456,8 +457,8 @@ private ResolvedArtifact tryResolvingRelocationArtifact(Dependency dep) {
456457 }
457458
458459 private ConditionalDependency newConditionalDep (Dependency originalDep ) {
459- var manualConfig = manualPlatformConfig .get ();
460- var dep = getConstrainedDep (originalDep , manualConfig . getConstraints () );
460+ // var platformSpec = platformSpecProperty .get();
461+ var dep = getConstrainedDep (originalDep );
461462 final Configuration config = getDetachedWithExclusions (dep ).setTransitive (false );
462463
463464 setConditionalAttributes (config , project , mode );
@@ -491,7 +492,7 @@ private ConditionalDependency newConditionalDep(Dependency originalDep) {
491492 }
492493
493494 private boolean isExplicitlyExcluded (Dependency dep ) {
494- return manualPlatformConfig .get ().getExclusions ().stream ().anyMatch (rule -> {
495+ return platformSpecProperty .get ().getExclusions ().stream ().anyMatch (rule -> {
495496 rule .getGroup ();
496497 if (!rule .getGroup ().equals (dep .getGroup ())) {
497498 return false ;
@@ -503,33 +504,46 @@ private boolean isExplicitlyExcluded(Dependency dep) {
503504
504505 private Configuration getDetachedWithExclusions (Dependency dep ) {
505506 var c = project .getConfigurations ().detachedConfiguration (dep );
506- manualPlatformConfig .get ().getExclusions ().forEach (rule -> {
507+ PlatformSpec platformSpec = platformSpecProperty .get ();
508+ platformSpec .getExclusions ().forEach (rule -> {
507509 Map <String , String > excludeProperties = new HashMap <>();
508510 excludeProperties .put ("group" , rule .getGroup ());
509511 excludeProperties .put ("module" , rule .getModule ());
510512 c .exclude (excludeProperties );
511513 });
514+ // Also apply exclusions from matching constraints
515+ findMatchingConstraint (dep ).ifPresent (constraint -> constraint .getExclusions ().forEach (rule -> {
516+ Map <String , String > excludeProperties = new HashMap <>();
517+ excludeProperties .put ("group" , rule .getGroup ());
518+ excludeProperties .put ("module" , rule .getModule ());
519+ c .exclude (excludeProperties );
520+ }));
512521 return c ;
513522 }
514523
515- private Dependency getConstrainedDep (Dependency dep , Set <ManualPlatformSpec .Constraint > constraints ) {
524+ private Dependency getConstrainedDep (Dependency dep ) {
525+ return findMatchingConstraint (dep ).map (c -> project .getDependencies ().create (
526+ dep .getGroup () + ":" + dep .getName () + ":" + c .getVersion ())).orElse (dep );
527+ }
528+
529+ private Optional <PlatformSpec .Constraint > findMatchingConstraint (Dependency dep ) {
530+ PlatformSpec platformSpec = platformSpecProperty .get ();
531+ Set <PlatformSpec .Constraint > constraints = platformSpec .getConstraints ();
516532 if (constraints == null || constraints .isEmpty ()) {
517- return dep ;
533+ return Optional . empty () ;
518534 }
519535
520536 var matchingConstraints = constraints .stream ().filter (c -> c .matches (dep )).toList ();
521537
522538 if (matchingConstraints .isEmpty ()) {
523- return dep ;
539+ return Optional . empty () ;
524540 }
525541
526542 if (matchingConstraints .size () > 1 ) {
527543 throw new RuntimeException ("Multiple matching constraints for " + dep + ": " + matchingConstraints );
528544 }
529545
530- var c = matchingConstraints .get (0 );
531- return project .getDependencies ().create (
532- dep .getGroup () + ":" + dep .getName () + ":" + c .getVersion ());
546+ return Optional .of (matchingConstraints .get (0 ));
533547 }
534548
535549 private class ProcessedDependency {
0 commit comments