diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 43bf9f6..bce81f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 17 + java-version: 21 # Setup Gradle - name: Setup Gradle @@ -111,7 +111,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 17 + java-version: 21 # Setup Gradle - name: Setup Gradle @@ -160,7 +160,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 17 + java-version: 21 # Setup Gradle - name: Setup Gradle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa06cb2..9f9193f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 17 + java-version: 21 # Setup Gradle - name: Setup Gradle diff --git a/.github/workflows/run-ui-tests.yml b/.github/workflows/run-ui-tests.yml index 6b60acd..a055cf1 100644 --- a/.github/workflows/run-ui-tests.yml +++ b/.github/workflows/run-ui-tests.yml @@ -40,7 +40,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 17 + java-version: 21 # Setup Gradle - name: Setup Gradle diff --git a/CHANGELOG.md b/CHANGELOG.md index c8f52a7..4901319 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ ## [Unreleased] +### Changed + +- Gradle task for the entire project is again called in background (async) +- Pre-commit hook added in version 1.0.5 is no more supported for gradle projects + ## [1.1.1] - 2024-08-11 ### Changed diff --git a/README.md b/README.md index d95ce5d..0e93cc7 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ [![Downloads](https://img.shields.io/jetbrains/plugin/d/22455.svg)](https://plugins.jetbrains.com/plugin/22455) +> ⚠️ Version 1.1.2 is built for Intellij IDEA 2024.2 and doesn't support the pre-commit feature for Gradle projects due to this bug https://youtrack.jetbrains.com/issue/IDEA-327879 +> +> Version 1.1.1 supports the pre-commit check properly but is only compatible with Intellij IDEA 2024.1.* versions. + The Spotless Applier IntelliJ Plugin enhances your development workflow by seamlessly integrating [Spotless](https://github.com/diffplug/spotless) Gradle and Maven tasks directly within the IntelliJ IDE. With this plugin, you can easily apply code formatting and style enforcement to your projects, @@ -17,7 +21,7 @@ either for the current file you're working on or for the entire project. | Code > Reformat Project With Spotless | Ctrl+Alt+Shift+; | ⌘Сmd+⌥Opt+⇧Shift+; | > ✔️ **Supports multi-module projects** -> + ### Commit check The plugin offers a commit check to automatically apply Spotless formatting. diff --git a/build.gradle.kts b/build.gradle.kts index cb89251..cde5637 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ version = providers.gradleProperty("pluginVersion").get() // Set the JVM language level used to build the project. kotlin { - jvmToolchain(17) + jvmToolchain(21) } repositories { diff --git a/gradle.properties b/gradle.properties index 2d4045e..b85a5c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,15 +4,15 @@ pluginName=Spotless Applier pluginRepositoryUrl=https://github.com/lipiridi/spotless-applier # SemVer format -> https://semver.org -pluginVersion=1.1.1 +pluginVersion=1.1.2 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -pluginSinceBuild=241 +pluginSinceBuild=242 pluginUntilBuild=242.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType=IC -platformVersion=2024.1.2 +platformVersion=2024.2 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP diff --git a/src/main/java/com/github/lipiridi/spotless/applier/ToolEnvExternalSystemUtil.java b/src/main/java/com/github/lipiridi/spotless/applier/ToolEnvExternalSystemUtil.java index 8f95fc3..0c1a2d2 100644 --- a/src/main/java/com/github/lipiridi/spotless/applier/ToolEnvExternalSystemUtil.java +++ b/src/main/java/com/github/lipiridi/spotless/applier/ToolEnvExternalSystemUtil.java @@ -13,6 +13,7 @@ import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.gradle.util.GradleConstants; public final class ToolEnvExternalSystemUtil { private static final Logger LOG = Logger.getInstance(ToolEnvExternalSystemUtil.class); @@ -52,15 +53,22 @@ public static void runTask( final String title = moduleName + " " + taskSettings.getTaskNames(); - Task task = getTask(project, document, title, taskUnderProgress); + Task task = getTask(project, document, title, taskUnderProgress, externalSystemId); task.queue(); } @NotNull private static Task getTask( - @NotNull Project project, Document document, String title, TaskUnderProgress taskUnderProgress) { - if (document == null) { - return new Task.Modal(project, title, true) { + @NotNull Project project, + Document document, + String title, + TaskUnderProgress taskUnderProgress, + ProjectSystemId externalSystemId) { + // Currently not found the way to run gradle task synchronously + // https://intellij-support.jetbrains.com/hc/en-us/community/posts/12849664786322-Execute-Gradle-task-in-ProgressExecutionMode-MODAL-SYNC + // https://youtrack.jetbrains.com/issue/IDEA-327879 + if (document == null && !externalSystemId.equals(GradleConstants.SYSTEM_ID)) { + return new Task.Modal(project, title, false) { @Override public void run(@NotNull ProgressIndicator indicator) { taskUnderProgress.execute(indicator); @@ -70,7 +78,9 @@ public void run(@NotNull ProgressIndicator indicator) { return new Task.Backgroundable(project, title) { @Override public void run(@NotNull ProgressIndicator indicator) { - document.setReadOnly(true); + if (document != null) { + document.setReadOnly(true); + } taskUnderProgress.execute(indicator); } }; diff --git a/src/main/java/com/github/lipiridi/spotless/applier/trigger/SpotlessCheckinHandler.java b/src/main/java/com/github/lipiridi/spotless/applier/trigger/SpotlessCheckinHandler.java index f496301..40da03a 100644 --- a/src/main/java/com/github/lipiridi/spotless/applier/trigger/SpotlessCheckinHandler.java +++ b/src/main/java/com/github/lipiridi/spotless/applier/trigger/SpotlessCheckinHandler.java @@ -2,6 +2,7 @@ import com.github.lipiridi.spotless.applier.ModuleInfo; import com.github.lipiridi.spotless.applier.ReformatProcessor; +import com.github.lipiridi.spotless.applier.enums.BuildTool; import com.github.lipiridi.spotless.applier.ui.settings.SpotlessApplierSettingsState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; @@ -16,12 +17,10 @@ import com.intellij.openapi.vcs.ui.RefreshableOnComponent; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.PairConsumer; -import java.awt.*; import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Set; -import javax.swing.*; import org.jetbrains.annotations.Nullable; public class SpotlessCheckinHandler extends CheckinHandler { @@ -89,6 +88,12 @@ public Set findAffectedModules() { continue; } + // Commiting is a synchronous flow. Currently, gradle has issues with that + // https://youtrack.jetbrains.com/issue/IDEA-327879 + if (moduleInfo.buildTool() == BuildTool.GRADLE) { + continue; + } + if (moduleInfo.rootModule()) { return Set.of(moduleInfo); }