From ebbe0b18bdc6352c9839d01b78cacd6a4228dae0 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Tue, 11 Jan 2022 17:55:20 -0500 Subject: [PATCH] PJF plugin supports the new `PLUGIN_DIR/lib/*.jar` structure (#617) palantir-java-format intellij plugin supports the new `PLUGIN_DIR/lib/*.jar` structure in addition to the old `PLUGIN_DIR/impl/*.jar` location --- changelog/@unreleased/pr-617.v2.yml | 6 ++++++ .../javaformat/intellij/FormatterProvider.java | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 changelog/@unreleased/pr-617.v2.yml diff --git a/changelog/@unreleased/pr-617.v2.yml b/changelog/@unreleased/pr-617.v2.yml new file mode 100644 index 000000000..0fac7dc80 --- /dev/null +++ b/changelog/@unreleased/pr-617.v2.yml @@ -0,0 +1,6 @@ +type: fix +fix: + description: palantir-java-format intellij plugin supports the new `PLUGIN_DIR/lib/*.jar` + structure in addition to the old `PLUGIN_DIR/impl/*.jar` location + links: + - https://github.com/palantir/palantir-java-format/pull/617 diff --git a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java index e3f645e6d..1cc08249b 100644 --- a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java +++ b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java @@ -83,9 +83,13 @@ private static List getProvidedImplementationUrls(List implementation private static List getBundledImplementationUrls() { // Load from the jars bundled with the plugin. - Path implDir = PalantirCodeStyleManager.PLUGIN.getPath().toPath().resolve("impl"); - log.debug("Using palantir-java-format implementation bundled with plugin: {}", implDir); - return listDirAsUrlsUnchecked(implDir); + Path pluginPath = PalantirCodeStyleManager.PLUGIN.getPluginPath(); + Path implDir = pluginPath.resolve("impl"); + // Directory appears to have been renamed from 'impl' to 'lib' in recent idea releases + Path pathToUse = Files.isDirectory(implDir) ? implDir : pluginPath.resolve("lib"); + + log.debug("Using palantir-java-format implementation bundled with plugin: {}", pathToUse); + return listDirAsUrlsUnchecked(pathToUse); } private static List getImplementationUrls(