@@ -73,8 +73,10 @@ pub fn vendor_uuid_dir_rel(eco: &str, uuid: &str) -> Option<String> {
7373/// The first of `.socket/vendor`, `.socket/vendor/<eco>` and
7474/// `.socket/vendor/<eco>/<uuid>` under `project_root` that is a symlink (or
7575/// a Windows junction), project-relative and forward-slashed; `None` when
76- /// none is. The `<eco>` level is only checked for a known ecosystem dir and
77- /// the `<uuid>` level only for a canonical uuid.
76+ /// none is. The `<eco>` level is only checked for a known ecosystem dir
77+ /// (`jvm` counts as `maven`, which also checks the JVM repository tree
78+ /// `.socket/vendor/maven2`) and the `<uuid>` level only for a canonical
79+ /// uuid.
7880///
7981/// Vendor staging creates these dirs itself and never writes symlinks, so a
8082/// linked level is never ours: its target may be another project's vendor
@@ -83,12 +85,19 @@ pub fn vendor_uuid_dir_rel(eco: &str, uuid: &str) -> Option<String> {
8385/// and revert dispatch refuses on this before touching anything, as
8486/// [`sweep_vendor_dirs`] already skips a linked eco or uuid dir.
8587pub fn vendor_dir_symlink ( project_root : & Path , eco : & str , uuid : Option < & str > ) -> Option < String > {
88+ // A `jvm` ledger entry is reverted by the maven backend, and every
89+ // maven-family entry may own files in the JVM repository tree
90+ // (`.socket/vendor/maven2`) as well as a `maven/<uuid>` unit.
91+ let eco = if eco == "jvm" { "maven" } else { eco } ;
8692 let mut levels = vec ! [ VENDOR_DIR . to_string( ) ] ;
8793 if ECOSYSTEM_DIRS . contains ( & eco) {
8894 levels. push ( format ! ( "{VENDOR_DIR}/{eco}" ) ) ;
8995 if let Some ( rel) = uuid. and_then ( |u| vendor_uuid_dir_rel ( eco, u) ) {
9096 levels. push ( rel) ;
9197 }
98+ if eco == "maven" {
99+ levels. push ( format ! ( "{VENDOR_DIR}/maven2" ) ) ;
100+ }
92101 }
93102 levels. into_iter ( ) . find ( |rel| {
94103 std:: fs:: symlink_metadata ( project_root. join ( rel) )
@@ -1004,6 +1013,26 @@ mod tests {
10041013 ) ;
10051014 assert_eq ! ( vendor_dir_symlink( & unit, "npm" , Some ( "not-a-uuid" ) ) , None ) ;
10061015
1016+ // `jvm` entries are maven-backed: the maven unit and the JVM
1017+ // repository tree are both checked.
1018+ let jvm = tmp. path ( ) . join ( "jvm" ) ;
1019+ std:: fs:: create_dir_all ( jvm. join ( ".socket/vendor" ) ) . unwrap ( ) ;
1020+ symlink ( & outside, jvm. join ( ".socket/vendor/maven" ) ) . unwrap ( ) ;
1021+ assert_eq ! (
1022+ vendor_dir_symlink( & jvm, "jvm" , Some ( UUID ) ) . as_deref( ) ,
1023+ Some ( ".socket/vendor/maven" )
1024+ ) ;
1025+ let tree = tmp. path ( ) . join ( "tree" ) ;
1026+ std:: fs:: create_dir_all ( tree. join ( ".socket/vendor/maven" ) ) . unwrap ( ) ;
1027+ symlink ( & outside, tree. join ( ".socket/vendor/maven2" ) ) . unwrap ( ) ;
1028+ for eco in [ "jvm" , "maven" ] {
1029+ assert_eq ! (
1030+ vendor_dir_symlink( & tree, eco, Some ( UUID ) ) . as_deref( ) ,
1031+ Some ( ".socket/vendor/maven2" ) ,
1032+ "{eco}"
1033+ ) ;
1034+ }
1035+
10071036 let vendor = tmp. path ( ) . join ( "vendor" ) ;
10081037 std:: fs:: create_dir_all ( vendor. join ( ".socket" ) ) . unwrap ( ) ;
10091038 symlink ( & outside, vendor. join ( ".socket/vendor" ) ) . unwrap ( ) ;
0 commit comments