-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
169 lines (139 loc) · 4.78 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import org.jetbrains.intellij.platform.gradle.Constants
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)
plugins {
id("java")
// id("org.jetbrains.intellij.platform.migration") version "2.1.0"
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
}
group = properties("pluginGroup").get()
version = "1.0.5.131"
val jvmVersion = "17"
val platformVersion = properties("platformVersion")
val platformType = properties("platformType")
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
// Set the JVM language level used to build the project.
kotlin {
jvmToolchain(17)
}
dependencies {
intellijPlatform {
// intellijIdeaCommunity("2022.3")
create(platformType,platformVersion)
val parser = { it: String -> it.split(',').map(String::trim).filter(String::isNotEmpty) }
plugins(providers.gradleProperty("platformPlugins").map(parser))
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map(parser))
// instrumentationTools()
pluginVerifier()
}
}
// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html
intellijPlatform {
projectName = project.name
pluginConfiguration {
version.set("${project.version}")
ideaVersion {
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}
}
signing {
certificateChain = System.getenv("CERTIFICATE_CHAIN")
privateKey = System.getenv("PRIVATE_KEY")
password = System.getenv("PRIVATE_KEY_PASSWORD")
}
publishing {
token = System.getenv("PUBLISH_TOKEN")
}
pluginVerification {
ides {
ide(IntelliJPlatformType.IntellijIdeaCommunity,"2022.3")
ide(IntelliJPlatformType.IntellijIdeaCommunity,"251.17181.16")
// ide(IntelliJPlatformType.AndroidStudio,"2024.2.1.9")
// recommended()
}
}
}
tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = jvmVersion
targetCompatibility = jvmVersion
}
withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(jvmVersion))
}
}
buildSearchableOptions {
enabled = false
}
jarSearchableOptions {
enabled = false
}
// runIde {
// // Absolute path to installed target 3.5 Android Studio to use as
// // IDE Development Instance (the "Contents" directory is macOS specific):
//// ideDir.set(file("C:\\Program Files\\Android\\Android Studio"))
// }
register("incrementBuild") {
group = "version"
description = "Increment build number in version on each build"
val versionStr = version.toString()
val buildFile = project.buildFile
doFirst {
if (!buildFile.canWrite()) {
println("Can't write new version to file")
return@doFirst
}
val versionParts = versionStr.split(".").map(String::toInt).toMutableList()
//0 - major
//1 - minor
//2 - patch
//3 - build
if (versionParts.size < 4) {
return@doFirst
}
versionParts[3]++
val newVersion = versionParts.joinToString(".")
val content = buildFile.readText()
val newContent =
content.replace(
regex = Regex(
pattern = """version\s*=\s*"$versionStr"""",
option = RegexOption.MULTILINE,
),
replacement = "version = \"$newVersion\"",
)
println("Version: $versionStr -> $newVersion")
buildFile.writeText(newContent)
// version = newVersion
// project.version = newVersion
// named(Constants.Tasks.PATCH_PLUGIN_XML) {
// for (propName in listOf("version","pluginVersion")) {
// if (this.hasProperty(propName)) this.setProperty(propName, newVersion)
// }
// }
}
}
named(Constants.Tasks.BUILD_PLUGIN) {
dependsOn(":incrementBuild")
}
named(Constants.Tasks.PATCH_PLUGIN_XML) {
dependsOn(":incrementBuild")
}
}