Skip to content

Commit 5dbb927

Browse files
authored
fix: jdtls throws errors equinox org jar not found #2
fix: jdtls setup fails due to unavailable equinox launcher org file
1 parent 7e80427 commit 5dbb927

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed

.github/workflows/jdtls-milestone-checker.yml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,38 @@ on:
88
branches:
99
- main
1010
workflow_dispatch:
11+
inputs:
12+
JDTLS_VERSION:
13+
description: "jdtls version"
14+
required: false
15+
FORCE_REPACKAGE:
16+
description: "Replace package already exists"
17+
required: true
18+
default: false
19+
type: boolean
1120

1221
permissions:
1322
contents: write
1423

1524
jobs:
1625
check-and-release:
26+
env:
27+
JDTLS_VERSION: ${{ github.event.inputs.JDTLS_VERSION }}
28+
FORCE_REPACKAGE: ${{ github.event.inputs.FORCE_REPACKAGE }}
1729
runs-on: ubuntu-latest
1830

1931
steps:
2032
- name: Checkout repository
2133
uses: actions/checkout@v3
2234

23-
- name: Get latest jdtls version
24-
id: get_latest
35+
- name: Set the latest jdtls version
36+
if: env.JDTLS_VERSION == ''
2537
run: |
2638
pip install requests
27-
echo "latest_version=$(python ./get_latest.py)" >> $GITHUB_ENV
39+
echo "JDTLS_VERSION=$(python ./get_latest.py)" >> $GITHUB_ENV
2840
2941
- name: Check if latest version has been released
42+
if: env.FORCE_REPACKAGE == 'false'
3043
env:
3144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3245
run: |
@@ -35,24 +48,28 @@ jobs:
3548
-H "Accept: application/vnd.github.v3+json" \
3649
https://api.github.com/repos/${{ github.repository }}/releases)
3750
38-
if echo "$releases" | jq -e '.[] | select(.tag_name == "${{ env.latest_version }}")' > /dev/null; then
39-
echo "release_exists=true" >> $GITHUB_ENV
51+
if echo "$releases" | jq -e '.[] | select(.tag_name == "${{ env.JDTLS_VERSION }}")' > /dev/null; then
52+
echo "RELEASE_EXISTS=true" >> $GITHUB_ENV
4053
else
41-
echo "release_exists=false" >> $GITHUB_ENV
54+
echo "RELEASE_EXISTS=false" >> $GITHUB_ENV
4255
fi
4356
4457
- name: Repackage jdtls
45-
if: env.release_exists == 'false'
58+
if: env.RELEASE_EXISTS == 'false' || env.FORCE_REPACKAGE == 'true'
4659
run: |
4760
pip install requests
4861
python ./repackage.py
4962
ls
5063
64+
- name: Debug
65+
run: |
66+
env
67+
5168
- name: Release
52-
if: env.release_exists == 'false'
69+
if: env.RELEASE_EXISTS == 'false' || env.FORCE_REPACKAGE == 'true'
5370
uses: softprops/action-gh-release@v2
5471
with:
5572
files: jdtls.tar.gz
56-
make_latest: "true"
57-
name: "${{env.latest_version}}"
58-
tag_name: "${{env.latest_version}}"
73+
make_latest: "${{ github.event_name == 'scheduled' && 'true' || 'false' }}"
74+
name: "${{env.JDTLS_VERSION}}"
75+
tag_name: "${{env.JDTLS_VERSION}}"

repackage.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import re
22
import requests
33
from urllib.parse import urljoin
4-
import urllib.request
54
import tarfile
65
import os
76
import tempfile
8-
from shutil import move, copyfile
7+
from shutil import copyfile
98

109
base_url = 'https://download.eclipse.org/jdtls/milestones/'
1110

@@ -52,7 +51,10 @@ def extract_tar_gz(tar_gz_path, equinox_plugin_path):
5251
with tempfile.TemporaryDirectory() as tmp:
5352
ex_dir = f'{tmp}/jdtls'
5453
tar.extractall(path=ex_dir)
55-
move(f'{ex_dir}/plugins/{equinox_plugin_path}', f'{ex_dir}/plugins/org.eclipse.equinox.launcher.jar')
54+
# creating a hard link instead of moving the file
55+
# https://github.com/nvim-java/release-jdtls/issues/1
56+
os.link(f'{ex_dir}/plugins/{equinox_plugin_path}', f'{ex_dir}/plugins/org.eclipse.equinox.launcher.jar')
57+
# move(f'{ex_dir}/plugins/{equinox_plugin_path}', f'{ex_dir}/plugins/org.eclipse.equinox.launcher.jar')
5658
with tempfile.TemporaryDirectory() as tmpout:
5759
out_path = f'{tmpout}/jdtls.tar.gz'
5860
with tarfile.open(out_path, "w:gz") as tarout:
@@ -61,7 +63,16 @@ def extract_tar_gz(tar_gz_path, equinox_plugin_path):
6163
copyfile(f'{tmpout}/jdtls.tar.gz', './jdtls.tar.gz')
6264

6365

64-
version = get_latest_version()
66+
67+
if os.environ.get('JDTLS_VERSION'):
68+
is_custom_version = True
69+
version = os.environ.get('JDTLS_VERSION')
70+
else:
71+
is_custom_version = False
72+
version = get_latest_version()
73+
74+
print(f"re-packaging version {version}")
75+
6576
download_url = get_jdtls_download_url(version)
6677
equinox_plugin_path = get_equinox_launcher_name(version)
6778
downloaded_path = download_file(download_url)

0 commit comments

Comments
 (0)