Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade IJ plugin to new IJP Gradle plugin 2.0 #500

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/publish_artifacts_on_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
release_tag:
description: 'Release tag'
required: true
type: stringe
type: string
jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -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: |
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.gradle/
ktfmt_idea_plugin/build/
ktfmt_idea_plugin/.intellijPlatform/
.idea/
*.ims
*.iml
Expand Down
58 changes: 36 additions & 22 deletions ktfmt_idea_plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType.*

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
Expand All @@ -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()
Expand All @@ -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()) } }
3 changes: 2 additions & 1 deletion ktfmt_idea_plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
kotlin.code.style=official
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2G
13 changes: 13 additions & 0 deletions ktfmt_idea_plugin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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" }
2 changes: 1 addition & 1 deletion ktfmt_idea_plugin/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions ktfmt_idea_plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<idea-plugin url="https://github.com/facebook/ktfmt/tree/main/ktfmt_idea_plugin">
<id>com.facebook.ktfmt_idea_plugin</id>
<!--suppress PluginXmlCapitalization -->
<name>ktfmt</name>
<vendor url="https://github.com/facebook/ktfmt">Facebook</vendor>

Expand All @@ -13,6 +14,7 @@
<formattingService
implementation="com.facebook.ktfmt.intellij.KtfmtFormattingService"/>
<postStartupActivity implementation="com.facebook.ktfmt.intellij.InitialConfigurationStartupActivity"/>
<!--suppress PluginXmlCapitalization -->
<projectConfigurable instance="com.facebook.ktfmt.intellij.KtfmtConfigurable"
id="com.facebook.ktfmt_idea_plugin.settings"
displayName="ktfmt Settings"
Expand Down
2 changes: 1 addition & 1 deletion online_formatter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
testImplementation(kotlin("test-junit"))
}

kotlin { jvmToolchain(11) }
kotlin { jvmToolchain(17) }

tasks {
test { useJUnit() }
Expand Down
1 change: 1 addition & 0 deletions online_formatter/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2G
2 changes: 1 addition & 1 deletion online_formatter/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion online_formatter/src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Handler : RequestHandler<APIGatewayProxyRequestEvent, String> {
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
Expand Down