@@ -440,10 +440,8 @@ impl PomScope {
440440 /// artifactId (keeping an unresolved reference,
441441 /// [`interpolate_keeping`]) and version ([`interpolate_strict`]) read
442442 /// together ([`Self::resolve_all_in_build`]), every reading whose
443- /// coordinates differ from what it reads with no profile active
444- /// ([`ScopedDep::group`] / [`ScopedDep::artifact`]). A profile
445- /// declaration's own profile is always active with it, so what it reads
446- /// there is one too.
443+ /// coordinates differ from what it reads with no profile active but
444+ /// the one holding it ([`ScopedDep::group`] / [`ScopedDep::artifact`]).
447445 pub ( crate ) fn coordinate_alternatives ( & self , dep : & ScopedDep ) -> Vec < CoordinateAlternative > {
448446 let ( Some ( group_text) , Some ( artifact_text) , Some ( group) , Some ( artifact) ) = (
449447 dep. group_text . as_deref ( ) ,
@@ -463,22 +461,9 @@ impl PomScope {
463461 if let Some ( version) = dep. version_text . as_deref ( ) {
464462 texts. push ( ( version, interpolate_strict) ) ;
465463 }
466- let pos = dep. element . start ;
467- let ( own_base, readings) = self . resolve_all_in_build ( & texts, pos) ;
468- let own: Vec < String > = self
469- . own_profile ( pos)
470- . into_iter ( )
471- . map ( |i| self . profile_properties [ i] . id . clone ( ) )
472- . collect ( ) ;
473- let own_reading = ( !own. is_empty ( ) ) . then ( || {
474- let mut values = own_base;
475- if let Some ( v) = values. get_mut ( 2 ) {
476- * v = v. take ( ) . or_else ( || dep. version_text . clone ( ) ) ;
477- }
478- ( values, MovedBy :: Profiles ( own) )
479- } ) ;
464+ let ( _, readings) = self . resolve_all_in_build ( & texts, dep. element . start ) ;
480465 let mut out: Vec < CoordinateAlternative > = Vec :: new ( ) ;
481- for ( values, by) in own_reading . into_iter ( ) . chain ( readings) {
466+ for ( values, by) in readings {
482467 let mut values = values. into_iter ( ) ;
483468 let ( Some ( Some ( g) ) , Some ( Some ( a) ) ) = ( values. next ( ) , values. next ( ) ) else {
484469 continue ;
@@ -503,13 +488,16 @@ impl PomScope {
503488 out
504489 }
505490
506- /// `text` (a coordinate) with every `${name}` the build defines with
507- /// no profile active interpolated, an undefined one kept as written
508- /// ([`interpolate_lenient`]). What any profile (a declaration's own
509- /// included) makes of it is [`ScopedDep::coordinate_alternatives`]'
510- /// job, which every coordinate check weighs.
511- fn interpolate_coordinate ( & self , text : & str ) -> String {
512- interpolate_lenient ( text, & |name| self . lookup ( name, & [ ] , true ) )
491+ /// `text` (a coordinate of the declaration at `pos`) with every
492+ /// `${name}` the build defines interpolated, reading the declaration's
493+ /// own profile `<properties>` first when it sits in a profile (as its
494+ /// version is: that profile is always active with it), an undefined
495+ /// one kept as written ([`interpolate_lenient`]). What other profiles
496+ /// make of it is [`Self::coordinate_alternatives`]' job, which every
497+ /// coordinate check weighs.
498+ fn interpolate_coordinate ( & self , text : & str , pos : usize ) -> String {
499+ let own = self . own_profile ( pos) ;
500+ interpolate_lenient ( text, & |name| self . lookup ( name, & own, true ) )
513501 }
514502
515503 /// Inside a plugin / deploy section (never project resolution).
@@ -556,12 +544,11 @@ fn inside(pos: usize, set: &[Element]) -> bool {
556544pub ( crate ) struct ScopedDep {
557545 pub ( crate ) element : Element ,
558546 /// `<groupId>` / `<artifactId>` with every `${prop}` the build defines
559- /// with no profile active (user properties, the project model, the
560- /// root `<properties>`) interpolated
561- /// ([`PomScope::interpolate_coordinate`]); an undefined one stays as
562- /// written, so [`may_name`] can tell it apart. What a profile (a
563- /// `<profiles>` declaration's own included) makes of them is
564- /// [`PomScope::coordinate_alternatives`]' job.
547+ /// with no profile active but, for a `<profiles>` declaration, its own
548+ /// (user properties, the project model, the root `<properties>`)
549+ /// interpolated ([`PomScope::interpolate_coordinate`]); an undefined
550+ /// one stays as written, so [`may_name`] can tell it apart. What other
551+ /// profiles make of them is [`PomScope::coordinate_alternatives`]' job.
565552 pub ( crate ) group : Option < String > ,
566553 pub ( crate ) artifact : Option < String > ,
567554 /// The trimmed `<groupId>` / `<artifactId>` text as written.
@@ -591,10 +578,10 @@ impl PomScope {
591578 element : dep,
592579 group : group_text
593580 . as_deref ( )
594- . map ( |g| self . interpolate_coordinate ( g) ) ,
581+ . map ( |g| self . interpolate_coordinate ( g, dep . start ) ) ,
595582 artifact : artifact_text
596583 . as_deref ( )
597- . map ( |a| self . interpolate_coordinate ( a) ) ,
584+ . map ( |a| self . interpolate_coordinate ( a, dep . start ) ) ,
598585 group_text,
599586 artifact_text,
600587 version_inner : version. map ( |v| {
@@ -1658,7 +1645,7 @@ mod tests {
16581645 deps,
16591646 [
16601647 ( false , "org.a" . to_string( ) , vec![ pair( "org.b" , "x" ) ] ) ,
1661- ( true , "org.a " . to_string( ) , vec![ pair ( "org.b" , "x" ) ] ) ,
1648+ ( true , "org.b " . to_string( ) , vec![ ] ) ,
16621649 ]
16631650 ) ;
16641651 }
0 commit comments