@@ -105,9 +105,13 @@ class TranspilerInstaller(abc.ABC):
105105 _install_path : Path
106106 """The path where the transpiler is being installed, once this starts."""
107107
108- def __init__ (self , repository : TranspilerRepository , product_name : str ) -> None :
108+ def __init__ (self ,
109+ repository : TranspilerRepository ,
110+ product_name : str ,
111+ legacy_product_names : list [str ] | None = None ) -> None :
109112 self ._repository = repository
110113 self ._product_name = product_name
114+ self ._legacy_product_names = legacy_product_names
111115
112116 _version_pattern = re .compile (r"[_-](\d+(?:[.\-_]\w*\d+)+)" )
113117
@@ -166,6 +170,16 @@ def _install_version_with_backup(self, version: str) -> Path | None:
166170 def _install_version (self , version : str ) -> bool :
167171 """Install a specific version of the transpiler, returning True if successful."""
168172
173+ def uninstall (self , name : str ) -> bool :
174+ product_path = self ._repository .transpilers_path () / name
175+ if not product_path .exists ():
176+ logger .warning (f"Cannot uninstall non-existing transpiler: { name } " )
177+ return False
178+
179+ rmtree (product_path )
180+ logger .info (f"Successfully uninstalled transpiler: { name } " )
181+ return True
182+
169183
170184class WheelInstaller (TranspilerInstaller ):
171185
@@ -359,8 +373,9 @@ def __init__(
359373 group_id : str ,
360374 artifact_id : str ,
361375 artifact : Path | None = None ,
376+ legacy_product_names : list [str ] | None = None ,
362377 ) -> None :
363- super ().__init__ (repository , product_name )
378+ super ().__init__ (repository , product_name , legacy_product_names )
364379 self ._group_id = group_id
365380 self ._artifact_id = artifact_id
366381 self ._artifact = artifact
@@ -400,6 +415,17 @@ def _copy_lsp_config(self, jar_file_path: Path) -> None:
400415 shutil .move (self ._install_path / "lsp" / "config.yml" , self ._install_path / "config.yml" )
401416 os .rmdir (self ._install_path / "lsp" )
402417
418+ def find_legacy_installs (self ):
419+ """Check for legacy installations of this transpiler, returning the names if found."""
420+ found = []
421+ legacy_product_names = self ._legacy_product_names if self ._legacy_product_names else []
422+ for legacy_name in legacy_product_names :
423+ installed_version = self ._repository .get_installed_version (legacy_name )
424+ if installed_version :
425+ logger .info (f"Detected legacy installation of { legacy_name } v{ installed_version } " )
426+ found .append (legacy_name )
427+ return found
428+
403429
404430class WorkspaceInstaller :
405431 def __init__ (
@@ -466,11 +492,20 @@ def install_morpheus(self, artifact: Path | None = None) -> None:
466492 "The morpheus transpiler requires Java 11 or above. Please install Java and re-run 'install-transpile'."
467493 )
468494 return
469- product_name = "databricks-morph-plugin "
495+ product_name = "morpheus "
470496 group_id = "com.databricks.labs"
471- artifact_id = product_name
472- maven_installer = MavenInstaller (self ._transpiler_repository , product_name , group_id , artifact_id , artifact )
473- maven_installer .install ()
497+ artifact_id = "databricks-morph-plugin"
498+ legacy_product_names = list (artifact_id )
499+ maven_installer = MavenInstaller (
500+ self ._transpiler_repository , product_name , group_id , artifact_id , artifact , legacy_product_names
501+ )
502+ installed = maven_installer .install ()
503+ if installed :
504+ installed_legacy = maven_installer .find_legacy_installs ()
505+ for legacy_name in installed_legacy :
506+ logger .info (f"Found legacy installation, uninstalling: { legacy_name } ." )
507+ logger .info ("Please reconfigure any transpile conf files using this transpiler." )
508+ maven_installer .uninstall (legacy_name )
474509
475510 @classmethod
476511 def is_java_version_okay (cls ) -> bool :
0 commit comments