-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
153 lines (128 loc) · 4.71 KB
/
build.gradle.kts
File metadata and controls
153 lines (128 loc) · 4.71 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
fun properties(key: String) = project.findProperty(key).toString()
val platformVersion = properties("platformVersion")
val platformType = properties("platformType")
plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "2.3.20"
id("org.jetbrains.intellij.platform") version "2.13.1"
id("org.jetbrains.changelog") version "2.5.0"
}
group = properties("pluginGroup")
version = properties("pluginVersion")
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}
kotlin {
jvmToolchain(21)
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
}
}
fun getMajorVersion(version: String): String {
val parts = version.split(".")
return if (parts.size >= 2) "${parts[0]}.${parts[1]}" else version
}
changelog {
version.set(properties("pluginVersion"))
groups.set(emptyList())
// Configure to accept your version format (YYYY.N or YYYY.N.N)
headerParserRegex.set("""(\d{4}\.\d+(?:\.\d+)?)""".toRegex())
keepUnreleasedSection.set(true)
}
dependencies {
intellijPlatform {
val type: String = providers.gradleProperty("platformType").get()
val version: String = providers.gradleProperty("platformVersion").get()
create(type, version) {
useInstaller = !version.endsWith("EAP-SNAPSHOT")
}
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
}
}
intellijPlatform {
signing {
certificateChainFile = providers.environmentVariable("CERTIFICATE_CHAIN_FILE")
.map { File(it) }
privateKeyFile = providers.environmentVariable("PRIVATE_KEY_FILE")
.map { File(it) }
password = providers.environmentVariable("PRIVATE_KEY_PASSWORD")
}
publishing {
token = providers.environmentVariable("PUBLISH_TOKEN")
}
pluginVerification {
ides {
recommended()
}
}
pluginConfiguration {
changeNotes.set(provider {
val majorVersion = getMajorVersion(project.version.toString())
// Get all changelog entries that start with the major version
val matchingEntries = changelog.getAll().values
.filter { it.version.startsWith(majorVersion) }
if (matchingEntries.isNotEmpty()) {
matchingEntries.joinToString("\n\n") {
changelog.renderItem(it, org.jetbrains.changelog.Changelog.OutputType.HTML)
}
} else {
// Fallback to current version only
changelog.renderItem(
changelog.getOrNull(properties("pluginVersion"))
?: changelog.getLatest(),
org.jetbrains.changelog.Changelog.OutputType.HTML
)
}
})
ideaVersion {
sinceBuild = properties("pluginSinceBuild")
untilBuild = provider { null }
}
}
}
gradle.taskGraph.whenReady {
val isRelease = hasTask(":signPlugin") || hasTask(":publishPlugin") || hasTask(":verifyPlugin")
tasks.named("buildSearchableOptions") { enabled = isRelease }
tasks.named("prepareJarSearchableOptions") { enabled = isRelease }
tasks.named("jarSearchableOptions") { enabled = isRelease }
}
tasks {
wrapper {
gradleVersion = providers.gradleProperty("gradleVersion").get()
distributionType = Wrapper.DistributionType.BIN
}
register<DefaultTask>("verifyWrapperVersion") {
// Wire expected version as a declared input so the action doesn't capture Project
val expectedVersion = providers.gradleProperty("gradleVersion").orElse("")
inputs.property("expectedGradleVersion", expectedVersion)
doLast {
val expected = inputs.properties["expectedGradleVersion"] as String
if (expected.isBlank()) return@doLast
val actual = GradleVersion.current().version
if (expected != actual) {
throw GradleException(
"Gradle Wrapper is $actual but expected is gradleVersion=$expected. " +
"Run: ./gradlew wrapper --gradle-version $expected"
)
}
}
}
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "21"
targetCompatibility = "21"
}
}
// Verify that we have the expected version of the Gradle wrapper
listOf("build", "buildPlugin").forEach { taskName ->
tasks.matching { it.name == taskName }.configureEach {
dependsOn(tasks.named("verifyWrapperVersion"))
}
}
dependencies {
implementation("com.google.code.gson:gson:2.13.2")
implementation("io.reactivex.rxjava3:rxjava:3.1.12")
}