Skip to content

Commit

Permalink
Allow jdtls.py to be dynamically imported (#3386)
Browse files Browse the repository at this point in the history
- Use importlib to dynamically import jdtls.py from script directory

Signed-off-by: Trenek <[email protected]>
Co-authored-by: Roland Grunberg <[email protected]>
  • Loading branch information
Trenek and rgrunber authored Feb 19, 2025
1 parent 1951866 commit eb8536d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions org.eclipse.jdt.ls.product/scripts/jdtls
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@
# Contributors:
# Marc Schreiber - initial API and implementation
###############################################################################
import jdtls
import importlib.util
import sys
import os

jdtls.main(sys.argv[1:])
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, "jdtls.py")

spec = importlib.util.spec_from_file_location("jdtls", file_path)
jdtls = importlib.util.module_from_spec(spec)
sys.modules["jdtls"] = jdtls
spec.loader.exec_module(jdtls)

jdtls.main(sys.argv[1:])

0 comments on commit eb8536d

Please sign in to comment.