From 8d83082a89e95573ba0011ce8128ed5217cedf82 Mon Sep 17 00:00:00 2001 From: M Mahrous Date: Fri, 24 Oct 2025 15:36:17 +0200 Subject: [PATCH] [IMP] attach additional stubs --- .github/workflows/build_plugin.yml | 15 +++++++++++ .gitignore | 1 + .../OdooLSInstallationProjectActivity.kt | 25 ++++++++++++++----- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_plugin.yml b/.github/workflows/build_plugin.yml index 08ffe08..ffc35e7 100644 --- a/.github/workflows/build_plugin.yml +++ b/.github/workflows/build_plugin.yml @@ -26,6 +26,21 @@ jobs: run: | wget ${{ steps.version.outputs.changelog_url }} -O CHANGELOG.md + - name: Checkout additional stubs from OdooLS + uses: actions/checkout@v4 + with: + repository: odoo/odoo-ls + ref: ${{ steps.version.outputs.version }} + path: additional_stubs + sparse-checkout: server/additional_stubs + sparse-checkout-cone-mode: false + + - name: Flatten additional_stubs and clean + run: | + # Move the stubs to the root of additional_stubs + mv additional_stubs/server/additional_stubs/* src/main/resources/additional_stubs/ + rm -rf additional_stubs/server + - name: Download language server binaries run: | VERSION=${{ steps.version.outputs.version }} diff --git a/.gitignore b/.gitignore index b0de61c..d24e1e7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build src/main/resources/odools-binaries src/main/resources/typeshed +additional_stubs \ No newline at end of file diff --git a/src/main/kotlin/com/odoo/odools/OdooLSInstallationProjectActivity.kt b/src/main/kotlin/com/odoo/odools/OdooLSInstallationProjectActivity.kt index fb5bece..0ac0305 100644 --- a/src/main/kotlin/com/odoo/odools/OdooLSInstallationProjectActivity.kt +++ b/src/main/kotlin/com/odoo/odools/OdooLSInstallationProjectActivity.kt @@ -53,12 +53,17 @@ class OdooLSInstallationProjectActivity : ProjectActivity, DumbAware { } fun copyDirectoryFromResourcesToInstallLocation(directoryPath: String, targetPath: String) { - val targetLocation = Paths.get(targetPath, "typeshed") + val targetLocation = Paths.get(targetPath, directoryPath) val resourceUrl = javaClass.classLoader.getResource(directoryPath) ?: throw IllegalArgumentException("Resource not found: $directoryPath") if (resourceUrl.protocol == "jar") { - val fileSystem = FileSystems.newFileSystem(resourceUrl.toURI(), emptyMap()) + val uri = resourceUrl.toURI() + val fileSystem = try { + FileSystems.getFileSystem(uri) + } catch (e: java.nio.file.FileSystemNotFoundException) { + FileSystems.newFileSystem(uri, emptyMap()) + } val jarPath = fileSystem.getPath(directoryPath) Files.walk(jarPath).forEach { source -> val dest = targetLocation.resolve(jarPath.relativize(source).toString()) @@ -82,7 +87,7 @@ class OdooLSInstallationProjectActivity : ProjectActivity, DumbAware { } } - fun ressourceToInstallPath(resourcePath: String, targetPath: Path) { + fun resourceToInstallPath(resourcePath: String, targetPath: Path) { javaClass.classLoader.getResourceAsStream(resourcePath).use { input -> requireNotNull(input) { "Resource not found: $resourcePath" } try { @@ -192,23 +197,31 @@ class OdooLSInstallationProjectActivity : ProjectActivity, DumbAware { installedVersionOlder(Paths.get(targetLocation, exeName)) { isOlder -> if (isOlder) { - ressourceToInstallPath("odools-binaries/${targetOs}/$exeName", Paths.get(targetLocation, exeName)) + resourceToInstallPath("odools-binaries/${targetOs}/$exeName", Paths.get(targetLocation, exeName)) if (SystemInfo.isWindows && (!Files.exists(Paths.get(targetLocation, "odoo_ls_server.pdb")))) { - ressourceToInstallPath("odools-binaries/${targetOs}/odoo_ls_server.pdb", Paths.get(targetLocation, "odoo_ls_server.pdb")) + resourceToInstallPath("odools-binaries/${targetOs}/odoo_ls_server.pdb", Paths.get(targetLocation, "odoo_ls_server.pdb")) } if (!SystemInfo.isWindows) { Paths.get(targetLocation, exeName).toFile().setExecutable(true, false) } } - if (!Files.exists(Paths.get(targetLocation, "typeshed")) && isTypeshedOutDated(Paths.get(targetLocation, "typeshed"))) { + if (!Files.exists(Paths.get(targetLocation, "typeshed")) || isTypeshedOutDated(Paths.get(targetLocation, "typeshed"))) { val file = Paths.get(targetLocation, "typeshed").toFile() if (file.exists()) { file.deleteRecursively() } copyDirectoryFromResourcesToInstallLocation("typeshed", targetLocation) } + if (!Files.exists(Paths.get(targetLocation, "additional_stubs"))) { + val file = Paths.get(targetLocation, "additional_stubs").toFile() + if (file.exists()) { + file.deleteRecursively() + } + copyDirectoryFromResourcesToInstallLocation("additional_stubs", targetLocation) + + } println("Installation complete") callback() }