Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/build_plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
build
src/main/resources/odools-binaries
src/main/resources/typeshed
additional_stubs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any>())
val uri = resourceUrl.toURI()
val fileSystem = try {
FileSystems.getFileSystem(uri)
} catch (e: java.nio.file.FileSystemNotFoundException) {
FileSystems.newFileSystem(uri, emptyMap<String, Any>())
}
val jarPath = fileSystem.getPath(directoryPath)
Files.walk(jarPath).forEach { source ->
val dest = targetLocation.resolve(jarPath.relativize(source).toString())
Expand All @@ -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 {
Expand Down Expand Up @@ -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()
}
Expand Down