Skip to content

Commit 09cdd27

Browse files
rock3rfacebook-github-bot
authored andcommitted
Upgrade IJ plugin to new IJP Gradle plugin 2.0 (#500)
Summary: This is step 1/2 needed to be able to run the ktlint plugin on IJ 24.2, which was just released today to stable. The next step will be to actually fix the crash on 24.2 — another PR coming for that. Pull Request resolved: #500 Reviewed By: strulovich Differential Revision: D60960340 Pulled By: hick209 fbshipit-source-id: 9b9505aaebdc4d9937183efa9f976c0ca9d658b1
1 parent 937d21d commit 09cdd27

File tree

12 files changed

+62
-36
lines changed

12 files changed

+62
-36
lines changed

.github/workflows/build_and_test.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
# test against latest update of each major Java version, as well as specific updates of LTS versions:
17-
java: [ 11, 13 ]
16+
# test against relevant LTS versions of Java
17+
java: [ 17, 21 ]
1818
name: Build ktfmt on Java ${{ matrix.java }}
1919
steps:
20-
- uses: actions/checkout@v1
20+
- uses: actions/checkout@v4
2121
with:
2222
submodules: recursive
2323
- name: Set up JDK ${{ matrix.java }}
24-
uses: actions/setup-java@v1
24+
uses: actions/setup-java@v4
2525
with:
2626
java-version: ${{ matrix.java }}
27+
distribution: zulu
2728
- name: Build ktfmt
2829
run: mvn -B install --file pom.xml
2930
- name: Build ktfmt_idea_plugin

.github/workflows/publish_artifacts_on_release.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
release_tag:
1616
description: 'Release tag'
1717
required: true
18-
type: stringe
18+
type: string
1919
jobs:
2020
publish:
2121
runs-on: ubuntu-latest
@@ -24,12 +24,13 @@ jobs:
2424
with:
2525
ref: ${{ github.events.release.tag_name || inputs.release_tag || github.ref }}
2626
- name: Set up Maven Central Repository
27-
uses: actions/setup-java@v1
27+
uses: actions/setup-java@v4
2828
with:
29-
java-version: 11
29+
java-version: 17
3030
server-id: ossrh
3131
server-username: MAVEN_USERNAME
3232
server-password: MAVEN_PASSWORD
33+
distribution: zulu
3334
- id: install-secret-key
3435
name: Install gpg secret key
3536
run: |
@@ -53,7 +54,7 @@ jobs:
5354
popd
5455
env:
5556
JETBRAINS_MARKETPLACE_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
56-
- uses: actions/setup-node@v2
57+
- uses: actions/setup-node@v4
5758
- name: Deploy website
5859
run: |
5960
KTFMT_TMP_DIR=$(mktemp -d)

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.gradle/
22
ktfmt_idea_plugin/build/
3+
ktfmt_idea_plugin/.intellijPlatform/
34
.idea/
45
*.ims
56
*.iml

ktfmt_idea_plugin/build.gradle.kts

+29-23
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType.IntellijIdeaCommunity
18+
1719
plugins {
18-
id("org.jetbrains.intellij") version "1.17.3"
1920
java
20-
id("com.diffplug.spotless") version "5.10.2"
21+
alias(libs.plugins.intelliJPlatform)
22+
alias(libs.plugins.spotless)
2123
}
2224

2325
val ktfmtVersion = rootProject.file("../version.txt").readText().trim()
@@ -27,36 +29,40 @@ group = "com.facebook"
2729

2830
version = "$pluginVersion.$ktfmtVersion"
2931

32+
java {
33+
toolchain {
34+
targetCompatibility = JavaVersion.VERSION_17
35+
sourceCompatibility = JavaVersion.VERSION_17
36+
}
37+
}
38+
3039
repositories {
3140
mavenCentral()
41+
intellijPlatform { defaultRepositories() }
3242
mavenLocal()
3343
}
3444

35-
java {
36-
sourceCompatibility = JavaVersion.VERSION_11
37-
targetCompatibility = JavaVersion.VERSION_11
38-
}
39-
4045
dependencies {
41-
implementation("com.facebook", "ktfmt", ktfmtVersion)
42-
implementation("com.google.googlejavaformat", "google-java-format", "1.22.0")
43-
}
46+
intellijPlatform {
47+
create(IntellijIdeaCommunity, "2022.3")
48+
instrumentationTools()
49+
pluginVerifier()
50+
zipSigner()
51+
}
4452

45-
// See https://github.com/JetBrains/gradle-intellij-plugin/
46-
intellij {
47-
// Version with which to build (and run; unless alternativeIdePath is specified)
48-
version.set("2022.1")
49-
// To run on a different IDE, uncomment and specify a path.
50-
// localPath = "/Applications/Android Studio.app"
53+
implementation("com.facebook", "ktfmt", ktfmtVersion)
54+
implementation(libs.googleJavaFormat)
5155
}
5256

53-
tasks {
54-
patchPluginXml {
55-
sinceBuild.set("221")
56-
untilBuild.set("")
57+
intellijPlatform {
58+
pluginConfiguration.ideaVersion {
59+
sinceBuild = "223.7571.182" // 2022.3
60+
untilBuild = provider { null }
5761
}
58-
publishPlugin { token.set(System.getenv("JETBRAINS_MARKETPLACE_TOKEN")) }
59-
runPluginVerifier { ideVersions.set(listOf("221")) }
62+
63+
publishing { token = System.getenv("JETBRAINS_MARKETPLACE_TOKEN") }
64+
65+
pluginVerification { ides { recommended() } }
6066
}
6167

62-
spotless { java { googleJavaFormat("1.22.0") } }
68+
spotless { java { googleJavaFormat(libs.versions.googleJavaFormat.get()) } }

ktfmt_idea_plugin/gradle.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
kotlin.code.style=official
1+
kotlin.code.style=official
2+
org.gradle.jvmargs=-Xmx2G
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[versions]
2+
googleJavaFormat = "1.23.0"
3+
4+
# plugins
5+
gradlePlugin-intelliJPlatform = "2.0.0"
6+
gradlePlugin-spotless = "6.25.0"
7+
8+
[libraries]
9+
googleJavaFormat = { module = "com.google.googlejavaformat:google-java-format", version.ref = "googleJavaFormat" }
10+
11+
[plugins]
12+
intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "gradlePlugin-intelliJPlatform" }
13+
spotless = { id = "com.diffplug.spotless", version.ref = "gradlePlugin-spotless" }

ktfmt_idea_plugin/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

ktfmt_idea_plugin/src/main/resources/META-INF/plugin.xml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<idea-plugin url="https://github.com/facebook/ktfmt/tree/main/ktfmt_idea_plugin">
22
<id>com.facebook.ktfmt_idea_plugin</id>
3+
<!--suppress PluginXmlCapitalization -->
34
<name>ktfmt</name>
45
<vendor url="https://github.com/facebook/ktfmt">Facebook</vendor>
56

@@ -13,6 +14,7 @@
1314
<formattingService
1415
implementation="com.facebook.ktfmt.intellij.KtfmtFormattingService"/>
1516
<postStartupActivity implementation="com.facebook.ktfmt.intellij.InitialConfigurationStartupActivity"/>
17+
<!--suppress PluginXmlCapitalization -->
1618
<projectConfigurable instance="com.facebook.ktfmt.intellij.KtfmtConfigurable"
1719
id="com.facebook.ktfmt_idea_plugin.settings"
1820
displayName="ktfmt Settings"

online_formatter/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies {
3333
testImplementation(kotlin("test-junit"))
3434
}
3535

36-
kotlin { jvmToolchain(11) }
36+
kotlin { jvmToolchain(17) }
3737

3838
tasks {
3939
test { useJUnit() }

online_formatter/gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
kotlin.code.style=official
2+
org.gradle.jvmargs=-Xmx2G

online_formatter/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

online_formatter/src/main/kotlin/main.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Handler : RequestHandler<APIGatewayProxyRequestEvent, String> {
3434
return gson.toJson(
3535
try {
3636
val request = gson.fromJson(event.body, Request::class.java)
37-
val style = request.style
37+
val style = request?.style ?: return "{}"
3838
when (val parseResult = ParsedArgs.parseOptions(listOfNotNull(style).toTypedArray())) {
3939
is ParseResult.Ok -> {
4040
val parsedArgs = parseResult.parsedValue

0 commit comments

Comments
 (0)