-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.gradle.kts
123 lines (104 loc) · 4.07 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
plugins {
id("java") // Java support
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
}
group = providers.gradleProperty("pluginGroup").get()
version = getVersionString(providers.gradleProperty("pluginVersion").get())
val javaCompilerVersion = "17"
kotlin {
jvmToolchain(javaCompilerVersion.toInt())
}
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}
dependencies {
implementation("dev.gitlive:kotlin-diff-utils:5.0.7")
implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") {
exclude("org.slf4j")
}
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.10")
implementation("com.vladsch.flexmark:flexmark-all:0.64.8")
implementation("io.github.kezhenxu94:cache-lite:0.2.0")
// test libraries
testImplementation(kotlin("test"))
intellijPlatform {
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })
instrumentationTools()
pluginVerifier()
zipSigner()
testFramework(TestFrameworkType.Platform)
}
}
intellijPlatform {
pluginConfiguration {
ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = providers.gradleProperty("pluginUntilBuild")
}
}
signing {
certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN")
privateKey = providers.environmentVariable("PRIVATE_KEY")
password = providers.environmentVariable("PRIVATE_KEY_PASSWORD")
}
publishing {
token = providers.environmentVariable("PUBLISH_TOKEN")
channels = providers.environmentVariable("PUBLISH_CHANNEL").map { listOf(it) }
}
pluginVerification {
failureLevel = listOf(
VerifyPluginTask.FailureLevel.INTERNAL_API_USAGES,
VerifyPluginTask.FailureLevel.COMPATIBILITY_PROBLEMS,
VerifyPluginTask.FailureLevel.INVALID_PLUGIN,
)
ides {
recommended()
}
}
}
tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = javaCompilerVersion
targetCompatibility = javaCompilerVersion
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = javaCompilerVersion
}
}
fun runCommand(cmd: String): String {
return providers.exec {
commandLine(cmd.split(" "))
}.standardOutput.asText.get().trim()
}
fun getVersionString(baseVersion: String): String {
val tag = runCommand("git tag -l --points-at HEAD")
if (System.getenv("PUBLISH_EAP") != "1" &&
tag.isNotEmpty() && tag.contains(baseVersion)) return baseVersion
val branch = runCommand("git rev-parse --abbrev-ref HEAD").replace("/", "-")
val numberOfCommits = if (branch == "main") {
val lastTag = runCommand("git describe --tags --abbrev=0 @^")
runCommand("git rev-list ${lastTag}..HEAD --count")
} else {
runCommand("git rev-list --count HEAD ^origin/main")
}
val commitId = runCommand("git rev-parse --short=8 HEAD")
return if (System.getenv("PUBLISH_EAP") == "1") {
"$baseVersion.$numberOfCommits-eap-$commitId"
} else {
"$baseVersion-$branch-$numberOfCommits-$commitId"
}
}