-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
177 lines (156 loc) · 6.32 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
177 lines (156 loc) · 6.32 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.api.tasks.bundling.Zip
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.tasks.ComposedJarTask
import org.jetbrains.intellij.platform.gradle.tasks.PatchPluginXmlTask
plugins {
java
id("org.jetbrains.intellij.platform") version "2.18.1"
}
data class PluginBranding(
val id: String,
val name: String,
val description: String,
val actionPrefix: String,
val controllerCategoryName: String,
val controllerActionName: String,
val controllerActionDescription: String,
val templateCategoryName: String,
val cycleActionDescription: String,
val incompatiblePluginId: String,
val archiveBaseName: String
)
val pluginVariantName = providers.gradleProperty("pluginVariant")
.orElse("angular")
.get()
.lowercase()
val pluginBranding = when (pluginVariantName) {
"angular" -> PluginBranding(
id = "patrick.kelleter.angular-cli-quick-switch",
name = "Angular CLI QuickSwitch",
description = "Switch between related Angular component files with configurable shortcuts. Cycle through controllers, templates, styles, and tests, jump directly to a category, and add custom suffixes.",
actionPrefix = "QuickSwitch",
controllerCategoryName = "Controller",
controllerActionName = "Controllers",
controllerActionDescription = "Switches directly to and between related controller files",
templateCategoryName = "Template",
cycleActionDescription = "Quickly switches between Angular CLI files for one component, e.g. ts, html, css",
incompatiblePluginId = "patrick.kelleter.file-quick-switch",
archiveBaseName = "angular-cli-quick-switch"
)
"file" -> PluginBranding(
id = "patrick.kelleter.file-quick-switch",
name = "File QuickSwitch",
description = "Switch between related sibling files with configurable shortcuts. Cycle through scripts, markup, styles, and tests, jump directly to a category, and add custom suffixes.",
actionPrefix = "File QuickSwitch",
controllerCategoryName = "Scripts",
controllerActionName = "Scripts",
controllerActionDescription = "Switches directly to and between related script files",
templateCategoryName = "Markup",
cycleActionDescription = "Quickly switches between related files with the same base name, e.g. ts, html, css",
incompatiblePluginId = "patrick.kelleter.angular-cli-quick-switch",
archiveBaseName = "file-quick-switch"
)
else -> throw GradleException(
"Unknown pluginVariant '$pluginVariantName'. Supported variants are 'angular' and 'file'."
)
}
val brandingTokens = mapOf(
"PLUGIN_ID" to pluginBranding.id,
"PLUGIN_NAME" to pluginBranding.name,
"PLUGIN_DESCRIPTION" to pluginBranding.description,
"ACTION_PREFIX" to pluginBranding.actionPrefix,
"CONTROLLER_CATEGORY_NAME" to pluginBranding.controllerCategoryName,
"CONTROLLER_ACTION_NAME" to pluginBranding.controllerActionName,
"CONTROLLER_ACTION_DESCRIPTION" to pluginBranding.controllerActionDescription,
"TEMPLATE_CATEGORY_NAME" to pluginBranding.templateCategoryName,
"CYCLE_ACTION_DESCRIPTION" to pluginBranding.cycleActionDescription,
"INCOMPATIBLE_PLUGIN_ID" to pluginBranding.incompatiblePluginId
)
group = "patrick.kelleter"
version = "2.0.0"
base {
archivesName = pluginBranding.archiveBaseName
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}
dependencies {
testImplementation("junit:junit:4.13.2")
intellijPlatform {
intellijIdeaCommunity("2024.2.6")
testFramework(TestFrameworkType.Platform)
}
}
tasks.withType<JavaCompile>().configureEach {
options.release = 21
}
val generatedPluginXml = layout.buildDirectory.file("generated/pluginXml/plugin.xml")
val generatePluginXml = tasks.register<Copy>("generatePluginXml") {
inputs.property("pluginVariant", pluginVariantName)
inputs.properties(brandingTokens)
from(layout.projectDirectory.file("src/main/plugin/plugin.xml"))
into(generatedPluginXml.map { it.asFile.parentFile })
filteringCharset = "UTF-8"
filter<ReplaceTokens>("tokens" to brandingTokens)
}
tasks.named<PatchPluginXmlTask>("patchPluginXml") {
dependsOn(generatePluginXml)
inputFile = generatedPluginXml
}
tasks.processResources {
inputs.property("pluginVariant", pluginVariantName)
inputs.properties(brandingTokens)
filteringCharset = "UTF-8"
filter<ReplaceTokens>("tokens" to brandingTokens)
}
tasks.named<Zip>("buildPlugin") {
archiveBaseName = pluginBranding.archiveBaseName
}
tasks.named<ComposedJarTask>("composedJar") {
archiveBaseName = pluginBranding.archiveBaseName
}
tasks.check {
dependsOn(tasks.named("verifyPluginProjectConfiguration"))
}
intellijPlatform {
buildSearchableOptions = true
pluginConfiguration {
id = pluginBranding.id
name = pluginBranding.name
description = pluginBranding.description
changeNotes = """
<ul>
<li>Updated for IntelliJ Platform 2024.2 and newer.</li>
<li>Added a settings page with optional previous-tab closing.</li>
<li>Added grouped file-type controls and optional spec.ts/spec.js test cycling.</li>
<li>Added one validated custom file suffix per category.</li>
<li>Added dedicated shortcuts for tests, ${pluginBranding.controllerActionName.lowercase()}, styles, and markup.</li>
<li>Fixed switching in editor splits and removed tab-closing side effects by default.</li>
<li>Improved support for virtual files and modern IntelliJ action APIs.</li>
</ul>
""".trimIndent()
ideaVersion {
sinceBuild = "242"
untilBuild = provider { null }
}
}
pluginVerification {
ides {
current()
recommended()
create(IntelliJPlatformType.IntellijIdea, "2025.3.6.1")
create(IntelliJPlatformType.IntellijIdea, "2026.1.5")
create(IntelliJPlatformType.IntellijIdea, "2026.2.1")
}
}
}