diff --git a/changelog/@unreleased/pr-619.v2.yml b/changelog/@unreleased/pr-619.v2.yml new file mode 100644 index 000000000..038c070ba --- /dev/null +++ b/changelog/@unreleased/pr-619.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Fix the intellij plugin when the bundled formatter is used + links: + - https://github.com/palantir/palantir-java-format/pull/619 diff --git a/idea-plugin/build.gradle b/idea-plugin/build.gradle index 20491780d..2663811fc 100644 --- a/idea-plugin/build.gradle +++ b/idea-plugin/build.gradle @@ -19,8 +19,9 @@ apply plugin: 'org.jetbrains.intellij' apply plugin: 'com.palantir.external-publish-jar' +def name = "palantir-java-format" intellij { - pluginName = "palantir-java-format" + pluginName = name updateSinceUntilBuild = true version = "IU-202.6397.94" plugins = ['java'] @@ -73,8 +74,8 @@ tasks.withType(org.jetbrains.intellij.tasks.PrepareSandboxTask) { dependsOn configurations.runtimeClasspath // Also pack the formatter in its own directory - into("${pluginName}/impl") { - from configurations.formatter + into("${name}/impl") { + from configurations.formatter.filter { !configurations.runtimeClasspath.contains(it) } } } 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 1cc08249b..e3f645e6d 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,13 +83,9 @@ private static List getProvidedImplementationUrls(List implementation private static List getBundledImplementationUrls() { // Load from the jars bundled with the plugin. - 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); + Path implDir = PalantirCodeStyleManager.PLUGIN.getPath().toPath().resolve("impl"); + log.debug("Using palantir-java-format implementation bundled with plugin: {}", implDir); + return listDirAsUrlsUnchecked(implDir); } private static List getImplementationUrls(