Skip to content

Instantly share code, notes, and snippets.

@thewisenerd
Created April 22, 2025 10:31
Show Gist options
  • Save thewisenerd/190bb2ec619ed14f8624325dbf7bd8e1 to your computer and use it in GitHub Desktop.
Save thewisenerd/190bb2ec619ed14f8624325dbf7bd8e1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# until https://github.com/JetBrains/intellij-community/pull/3022 gets merged
set -e
tmpdir="$(mktemp -d -t patch.df-bf)"
echo "using tmpdir: $tmpdir" >&2
function patch_impl() {
cd "$tmpdir"
base="$1/plugins/maven/lib"
src="$base/maven36-server.jar"
backup="maven36-server.df.jar"
cls="org/jetbrains/idea/maven/server/Maven36ServerEmbedderImpl.class"
if [[ ! -e "$src" ]]; then
echo "patch: src file not found '$src'" >&2
exit 1
fi
jar xf "$src" "$cls"
if grep -ob "bf" "$cls" >/dev/null; then
echo "possibly already bf! skipping." >&2
return
fi
if ! grep -ob "df" "$cls" >/dev/null; then
echo "df not found in src class" >&2
exit 1
fi
echo "patching cls" >&2
perl -i -pe 'BEGIN { $found = 0 }
if (!$found && s/df/bf/g) { $found = 1 }' "$cls"
echo "backing up current jar" >&2
cp "$src" "maven36-server.jar"
cp "$src" "$backup"
echo "repacking jar" >&2
jar uf "maven36-server.jar" "$cls"
rm "$cls"
rm -r org
echo "opening folder: $base"
open "$base"
echo "opening folder: $tmpdir"
open "$tmpdir"
tmpname=$(basename "$tmpdir")
echo "drag and drop the two jar files from the patch folder '$tmpname' into the 'lib' folder!" >&2
}
function main() {
platform="$(uname -s)"
if [[ "$platform" == "Darwin" ]]; then
base="/Applications/IntelliJ IDEA.app/Contents"
else
echo "unknown platform '$platform'" >&2
exit 1
fi
if [[ ! -e "$base" ]]; then
echo "base not found: '$base'" >&2
exit 1
fi
patch_impl "$base"
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment