diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index f75004ef..c3fae71c 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -13,17 +13,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # test against latest update of each major Java version, as well as specific updates of LTS versions: - java: [ 11, 13 ] + # test against relevant LTS versions of Java + java: [ 17, 21 ] name: Build ktfmt on Java ${{ matrix.java }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 with: submodules: recursive - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} + distribution: zulu - name: Build ktfmt run: mvn -B install --file pom.xml - name: Build ktfmt_idea_plugin diff --git a/.github/workflows/publish_artifacts_on_release.yaml b/.github/workflows/publish_artifacts_on_release.yaml index a48a70a9..371d3344 100644 --- a/.github/workflows/publish_artifacts_on_release.yaml +++ b/.github/workflows/publish_artifacts_on_release.yaml @@ -15,7 +15,7 @@ on: release_tag: description: 'Release tag' required: true - type: stringe + type: string jobs: publish: runs-on: ubuntu-latest @@ -24,12 +24,13 @@ jobs: with: ref: ${{ github.events.release.tag_name || inputs.release_tag || github.ref }} - name: Set up Maven Central Repository - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: 11 + java-version: 17 server-id: ossrh server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD + distribution: zulu - id: install-secret-key name: Install gpg secret key run: | @@ -53,7 +54,7 @@ jobs: popd env: JETBRAINS_MARKETPLACE_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }} - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 - name: Deploy website run: | KTFMT_TMP_DIR=$(mktemp -d) diff --git a/.gitignore b/.gitignore index b11d4247..3aa73c4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .gradle/ ktfmt_idea_plugin/build/ +ktfmt_idea_plugin/.intellijPlatform/ .idea/ *.ims *.iml diff --git a/ktfmt_idea_plugin/build.gradle.kts b/ktfmt_idea_plugin/build.gradle.kts index 35e11bb3..6ad825f9 100644 --- a/ktfmt_idea_plugin/build.gradle.kts +++ b/ktfmt_idea_plugin/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType.* + /* * Copyright (c) Meta Platforms, Inc. and affiliates. * @@ -15,9 +17,9 @@ */ plugins { - id("org.jetbrains.intellij") version "1.17.3" java - id("com.diffplug.spotless") version "5.10.2" + alias(libs.plugins.intelliJPlatform) + alias(libs.plugins.spotless) } val ktfmtVersion = rootProject.file("../version.txt").readText().trim() @@ -27,36 +29,48 @@ group = "com.facebook" version = "$pluginVersion.$ktfmtVersion" +java { + toolchain { + targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_17 + } +} + repositories { mavenCentral() + intellijPlatform { + defaultRepositories() + } mavenLocal() } -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 -} - dependencies { + intellijPlatform { + create(IntellijIdeaCommunity, "2022.3") + instrumentationTools() + pluginVerifier() + zipSigner() + } + implementation("com.facebook", "ktfmt", ktfmtVersion) - implementation("com.google.googlejavaformat", "google-java-format", "1.22.0") + implementation(libs.googleJavaFormat) } -// See https://github.com/JetBrains/gradle-intellij-plugin/ -intellij { - // Version with which to build (and run; unless alternativeIdePath is specified) - version.set("2022.1") - // To run on a different IDE, uncomment and specify a path. - // localPath = "/Applications/Android Studio.app" -} +intellijPlatform { + pluginConfiguration.ideaVersion { + sinceBuild = "223.7571.182" // 2022.3 + untilBuild = provider { null } + } + + publishing { + token = System.getenv("JETBRAINS_MARKETPLACE_TOKEN") + } -tasks { - patchPluginXml { - sinceBuild.set("221") - untilBuild.set("") + pluginVerification { + ides { + recommended() + } } - publishPlugin { token.set(System.getenv("JETBRAINS_MARKETPLACE_TOKEN")) } - runPluginVerifier { ideVersions.set(listOf("221")) } } -spotless { java { googleJavaFormat("1.22.0") } } +spotless { java { googleJavaFormat(libs.versions.googleJavaFormat.get()) } } diff --git a/ktfmt_idea_plugin/gradle.properties b/ktfmt_idea_plugin/gradle.properties index 29e08e8c..c873b795 100644 --- a/ktfmt_idea_plugin/gradle.properties +++ b/ktfmt_idea_plugin/gradle.properties @@ -1 +1,2 @@ -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official +org.gradle.jvmargs=-Xmx2G diff --git a/ktfmt_idea_plugin/gradle/libs.versions.toml b/ktfmt_idea_plugin/gradle/libs.versions.toml new file mode 100644 index 00000000..39fa8f3f --- /dev/null +++ b/ktfmt_idea_plugin/gradle/libs.versions.toml @@ -0,0 +1,13 @@ +[versions] +googleJavaFormat = "1.23.0" + +# plugins +gradlePlugin-intelliJPlatform = "2.0.0" +gradlePlugin-spotless = "6.25.0" + +[libraries] +googleJavaFormat = { module = "com.google.googlejavaformat:google-java-format", version.ref = "googleJavaFormat" } + +[plugins] +intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "gradlePlugin-intelliJPlatform" } +spotless = { id = "com.diffplug.spotless", version.ref = "gradlePlugin-spotless" } diff --git a/ktfmt_idea_plugin/gradle/wrapper/gradle-wrapper.properties b/ktfmt_idea_plugin/gradle/wrapper/gradle-wrapper.properties index ac72c34e..dedd5d1e 100644 --- a/ktfmt_idea_plugin/gradle/wrapper/gradle-wrapper.properties +++ b/ktfmt_idea_plugin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/ktfmt_idea_plugin/src/main/resources/META-INF/plugin.xml b/ktfmt_idea_plugin/src/main/resources/META-INF/plugin.xml index 6c7512a0..7f5ed4b4 100644 --- a/ktfmt_idea_plugin/src/main/resources/META-INF/plugin.xml +++ b/ktfmt_idea_plugin/src/main/resources/META-INF/plugin.xml @@ -1,5 +1,6 @@ com.facebook.ktfmt_idea_plugin + ktfmt Facebook @@ -13,6 +14,7 @@ + { return gson.toJson( try { val request = gson.fromJson(event.body, Request::class.java) - val style = request.style + val style = request?.style ?: return "{}" when (val parseResult = ParsedArgs.parseOptions(listOfNotNull(style).toTypedArray())) { is ParseResult.Ok -> { val parsedArgs = parseResult.parsedValue