Created
January 6, 2026 16:55
-
-
Save HugoPeters1024/40456a5421d1917aa80b1c34eff555a3 to your computer and use it in GitHub Desktop.
vscode patch script for jdtls using maxj/ecj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Replace VSCode's JDTLS plugins with custom patched versions | |
| # This replaces the actual JDTLS server files in the extension directory | |
| set -e | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| BLUE='\033[0;34m' | |
| NC='\033[0m' | |
| CUSTOM_REPO="/Users/hpeters/repos/eclipse.platform.releng.aggregator" | |
| CUSTOM_PLUGINS_DIR="${CUSTOM_REPO}/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins" | |
| VSCODE_EXT_DIR="/Users/hpeters/.vscode/extensions/redhat.java-1.51.0-darwin-arm64" | |
| VSCODE_PLUGINS_DIR="${VSCODE_EXT_DIR}/server/plugins" | |
| echo -e "${BLUE}=== Replacing JDTLS Plugins in VSCode Extension ===${NC}\n" | |
| # Check if custom plugins exist | |
| if [ ! -d "${CUSTOM_PLUGINS_DIR}" ]; then | |
| echo -e "${RED}Error: Custom JDTLS plugins not found${NC}" | |
| echo "Please build the custom JDTLS first:" | |
| echo " cd ${CUSTOM_REPO}" | |
| echo " mvn clean install" | |
| exit 1 | |
| fi | |
| # Check if VSCode extension exists | |
| if [ ! -d "${VSCODE_PLUGINS_DIR}" ]; then | |
| echo -e "${RED}Error: VSCode Java extension not found${NC}" | |
| echo "Please install 'Extension Pack for Java' in VSCode" | |
| exit 1 | |
| fi | |
| echo -e "${GREEN}✓ Custom plugins found: ${CUSTOM_PLUGINS_DIR}${NC}" | |
| echo -e "${GREEN}✓ VSCode extension found: ${VSCODE_PLUGINS_DIR}${NC}\n" | |
| # Create backup | |
| BACKUP_DIR="${VSCODE_PLUGINS_DIR}.backup.$(date +%Y%m%d_%H%M%S)" | |
| if [ ! -d "${VSCODE_PLUGINS_DIR}.backup" ]; then | |
| echo -e "${BLUE}Creating backup of original plugins...${NC}" | |
| cp -r "${VSCODE_PLUGINS_DIR}" "${BACKUP_DIR}" | |
| echo -e "${GREEN}✓ Backup created: ${BACKUP_DIR}${NC}\n" | |
| fi | |
| # Find all org.eclipse.jdt.core* plugins in custom build | |
| CUSTOM_CORE_PLUGINS=$(find "${CUSTOM_PLUGINS_DIR}" -name "org.eclipse.jdt.core*.jar" -type f) | |
| if [ -z "${CUSTOM_CORE_PLUGINS}" ]; then | |
| echo -e "${RED}Error: No org.eclipse.jdt.core plugins found in custom build${NC}" | |
| exit 1 | |
| fi | |
| echo -e "${BLUE}Replacing JDTLS core plugins...${NC}" | |
| # Replace each plugin by matching base name (ignoring version) | |
| for custom_plugin in ${CUSTOM_CORE_PLUGINS}; do | |
| # Extract plugin prefix (e.g., "org.eclipse.jdt.core" from "org.eclipse.jdt.core_3.42.0.v20250606-1600.jar") | |
| plugin_prefix=$(basename "${custom_plugin}" | sed 's/_[0-9].*//') | |
| # Find matching plugin in VSCode extension by prefix | |
| vscode_plugin=$(find "${VSCODE_PLUGINS_DIR}" -name "${plugin_prefix}_*.jar" | head -1) | |
| if [ -n "${vscode_plugin}" ]; then | |
| vscode_name=$(basename "${vscode_plugin}") | |
| custom_name=$(basename "${custom_plugin}") | |
| echo " Replacing: ${vscode_name}" | |
| echo " With: ${custom_name}" | |
| # Backup original | |
| if [ ! -f "${vscode_plugin}.orig" ]; then | |
| cp "${vscode_plugin}" "${vscode_plugin}.orig" | |
| fi | |
| # Replace with custom version (keep VSCode's filename to maintain references) | |
| cp "${custom_plugin}" "${vscode_plugin}" | |
| echo -e " ${GREEN}✓ Replaced${NC}" | |
| else | |
| echo -e " ${YELLOW}Warning: No matching plugin found for ${plugin_prefix}${NC}" | |
| fi | |
| done | |
| # Also replace the main JDTLS launcher and other critical plugins | |
| echo "" | |
| echo -e "${BLUE}Replacing other critical JDTLS plugins...${NC}" | |
| # Replace org.eclipse.jdt.ls.core if it exists | |
| CUSTOM_LS_CORE=$(find "${CUSTOM_PLUGINS_DIR}" -name "org.eclipse.jdt.ls.core*.jar" | head -1) | |
| if [ -n "${CUSTOM_LS_CORE}" ]; then | |
| VSCODE_LS_CORE=$(find "${VSCODE_PLUGINS_DIR}" -name "org.eclipse.jdt.ls.core*.jar" | head -1) | |
| if [ -n "${VSCODE_LS_CORE}" ]; then | |
| echo " Replacing: $(basename "${VSCODE_LS_CORE}")" | |
| mv "${VSCODE_LS_CORE}" "${VSCODE_LS_CORE}.orig" | |
| cp "${CUSTOM_LS_CORE}" "${VSCODE_LS_CORE}" | |
| echo -e " ${GREEN}✓ Replaced${NC}" | |
| fi | |
| fi | |
| # Replace equinox launcher if version differs | |
| CUSTOM_LAUNCHER=$(find "${CUSTOM_PLUGINS_DIR}" -name "org.eclipse.equinox.launcher_*.jar" | head -1) | |
| if [ -n "${CUSTOM_LAUNCHER}" ]; then | |
| VSCODE_LAUNCHER=$(find "${VSCODE_PLUGINS_DIR}" -name "org.eclipse.equinox.launcher_*.jar" | head -1) | |
| if [ -n "${VSCODE_LAUNCHER}" ]; then | |
| echo " Replacing: $(basename "${VSCODE_LAUNCHER}")" | |
| mv "${VSCODE_LAUNCHER}" "${VSCODE_LAUNCHER}.orig" | |
| cp "${CUSTOM_LAUNCHER}" "${VSCODE_LAUNCHER}" | |
| echo -e " ${GREEN}✓ Replaced${NC}" | |
| fi | |
| fi | |
| echo "" | |
| echo -e "${GREEN}=== Replacement Complete ===${NC}\n" | |
| echo "Next steps:" | |
| echo "1. Close VSCode completely" | |
| echo "2. Restart VSCode" | |
| echo "3. Open a Java file with custom operators" | |
| echo "4. Check that red squiggles are gone" | |
| echo "" | |
| echo -e "${YELLOW}Note:${NC} You may need to run this script again if:" | |
| echo "- VSCode updates the Java extension" | |
| echo "- The extension gets reinstalled" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment