xref: /aosp_15_r20/external/ktfmt/ktfmt_idea_plugin/build.gradle.kts (revision 5be3f65c8cf0e6db0a7e312df5006e8e93cdf9ec)
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 import com.ncorti.ktfmt.gradle.tasks.KtfmtCheckTask
18 import com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask
19 import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType.IntellijIdeaCommunity
20 
<lambda>null21 plugins {
22   java
23   alias(libs.plugins.kotlin)
24   alias(libs.plugins.intelliJPlatform)
25   alias(libs.plugins.ktfmt)
26 }
27 
28 val ktfmtVersion = rootProject.file("../version.txt").readText().trim()
29 val pluginVersion = "1.2"
30 
31 group = "com.facebook"
32 
33 version = "$pluginVersion.$ktfmtVersion"
34 
<lambda>null35 kotlin { jvmToolchain(17) }
36 
<lambda>null37 repositories {
38   mavenCentral()
39   intellijPlatform { defaultRepositories() }
40   mavenLocal()
41 }
42 
<lambda>null43 dependencies {
44   intellijPlatform {
45     create(IntellijIdeaCommunity, "2022.3")
46     instrumentationTools()
47     pluginVerifier()
48     zipSigner()
49   }
50 
51   implementation("com.facebook:ktfmt:$ktfmtVersion")
52 }
53 
<lambda>null54 intellijPlatform {
55   pluginConfiguration.ideaVersion {
56     sinceBuild = "223.7571.182" // 2022.3
57     untilBuild = provider { null }
58   }
59 
60   publishing { token = System.getenv("JETBRAINS_MARKETPLACE_TOKEN") }
61 
62   pluginVerification { ides { recommended() } }
63 }
64 
65 val runIntellij242 by
<lambda>null66     intellijPlatformTesting.runIde.registering {
67       type = IntellijIdeaCommunity
68       version = "2024.2"
69     }
70 
<lambda>null71 tasks {
72   // Set up ktfmt formatting tasks
73   val ktfmtFormatKts by
74       creating(KtfmtFormatTask::class) {
75         source = fileTree(rootDir)
76         include("**/*.kts")
77       }
78   val ktfmtCheckKts by
79       creating(KtfmtCheckTask::class) {
80         source = fileTree(rootDir)
81         include("**/*.kts")
82         mustRunAfter("compileKotlin")
83         mustRunAfter("prepareSandbox")
84         mustRunAfter("prepareTestSandbox")
85         mustRunAfter("instrumentCode")
86         mustRunAfter("instrumentTestCode")
87         mustRunAfter("buildSearchableOptions")
88         mustRunAfter("prepareJarSearchableOptions")
89       }
90   val ktfmtFormat by getting { dependsOn(ktfmtFormatKts) }
91   val ktfmtCheck by getting { dependsOn(ktfmtCheckKts) }
92   val check by getting { dependsOn(ktfmtCheck) }
93 }
94