@@ -176,7 +176,8 @@ struct ProfileProperties {
176176/// classpaths, `<pluginRepositories>` / `<distributionManagement>` plugin
177177/// and deploy repositories; `<profiles>` apply only when activated. Shared
178178/// by the VEX reader ([`parse_pom`]) and the hosted rewriter, so the
179- /// rewriter edits exactly the markup VEX later attests.
179+ /// rewriter edits exactly the markup VEX later attests. Only the VEX
180+ /// reader weighs profile `<properties>` ([`Self::read_profiles`]).
180181#[ derive( Debug ) ]
181182pub ( crate ) struct PomScope {
182183 /// The pom with comments and CDATA blanked byte-for-byte.
@@ -332,7 +333,17 @@ impl PomScope {
332333 . unwrap_or_else ( || text. to_string ( ) ) ;
333334 match self . resolve_in_build ( text, pos, interpolate_strict) {
334335 ( Some ( build) , alternatives) => ( spelled, build, alternatives) ,
335- ( None , _) => ( spelled, text. to_string ( ) , Vec :: new ( ) ) ,
336+ // Unresolved here (a parent pom this reader never sees may
337+ // define it): the build version stays as written, but a value
338+ // some profiles give it is still one the build may resolve.
339+ ( None , alternatives) => (
340+ spelled,
341+ text. to_string ( ) ,
342+ alternatives
343+ . into_iter ( )
344+ . filter ( |a| a. value != text)
345+ . collect ( ) ,
346+ ) ,
336347 }
337348 }
338349
@@ -544,10 +555,15 @@ fn inside(pos: usize, set: &[Element]) -> bool {
544555pub ( crate ) struct ScopedDep {
545556 pub ( crate ) element : Element ,
546557 /// `<groupId>` / `<artifactId>` with every `${prop}` the build defines
547- /// with no profile active (user properties, the project model, the
548- /// root `<properties>`) interpolated
549- /// ([`PomScope::interpolate_coordinate`]); an undefined one stays as
550- /// written, so [`may_name`] can tell it apart.
558+ /// (user properties, the project model, the root `<properties>`)
559+ /// interpolated ([`PomScope::interpolate_coordinate`]); an undefined
560+ /// one stays as written, so [`may_name`] can tell it apart. No profile
561+ /// is active but, for a `<profiles>` declaration, its own, whose
562+ /// `<properties>` count only once [`PomScope::read_profiles`] has run:
563+ /// the VEX reader runs it, the hosted rewriter does not, so a profile
564+ /// declaration whose coordinates only its own profile's `<properties>`
565+ /// define is the pinned GA to VEX (which then withholds the pin) and
566+ /// not to the rewriter.
551567 pub ( crate ) group : Option < String > ,
552568 pub ( crate ) artifact : Option < String > ,
553569 /// The trimmed `<groupId>` / `<artifactId>` text as written.
@@ -735,10 +751,12 @@ fn profile_properties(
735751 . iter ( )
736752 . find ( |p| props. start >= p. start && props. start < p. end )
737753 . copied ( ) ;
754+ // Maven names a profile without an `<id>` `default`, as the
755+ // vendored reactor does.
738756 let id = holder
739757 . and_then ( |p| direct_child_text ( p. inner ( text) , "id" ) )
740758 . filter ( |id| !id. is_empty ( ) )
741- . unwrap_or_else ( || format ! ( "#{}" , out . len ( ) + 1 ) ) ;
759+ . unwrap_or_else ( || "default" . to_string ( ) ) ;
742760 let mut map = BTreeMap :: new ( ) ;
743761 read_properties ( props. inner ( text) , & mut map) ?;
744762 out. push ( ProfileProperties {
0 commit comments