|
1 | 1 | import io.gitlab.arturbosch.detekt.Detekt |
2 | 2 | import org.jetbrains.changelog.closure |
| 3 | +import org.jetbrains.changelog.date |
3 | 4 | import org.jetbrains.changelog.markdownToHTML |
4 | 5 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
5 | 6 |
|
6 | 7 | fun properties(key: String) = project.findProperty(key).toString() |
7 | 8 |
|
8 | 9 | plugins { |
9 | | - // Java support |
10 | | - id("java") |
11 | | - // Kotlin support |
12 | | - id("org.jetbrains.kotlin.jvm") version "1.4.31" |
13 | | - // gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin |
14 | | - id("org.jetbrains.intellij") version "0.7.2" |
15 | | - // gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin |
16 | | - id("org.jetbrains.changelog") version "1.1.2" |
17 | | - // detekt linter - read more: https://detekt.github.io/detekt/gradle.html |
18 | | - id("io.gitlab.arturbosch.detekt") version "1.16.0" |
19 | | - // ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle |
20 | | - id("org.jlleitschuh.gradle.ktlint") version "10.0.0" |
| 10 | + // Java support |
| 11 | + id("java") |
| 12 | + // Kotlin support |
| 13 | + id("org.jetbrains.kotlin.jvm") version "1.4.31" |
| 14 | + // gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin |
| 15 | + id("org.jetbrains.intellij") version "0.7.2" |
| 16 | + // gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin |
| 17 | + id("org.jetbrains.changelog") version "1.1.2" |
| 18 | + // detekt linter - read more: https://detekt.github.io/detekt/gradle.html |
| 19 | + id("io.gitlab.arturbosch.detekt") version "1.15.0" |
| 20 | + // ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle |
| 21 | + id("org.jlleitschuh.gradle.ktlint") version "10.0.0" |
21 | 22 | } |
22 | 23 |
|
23 | 24 | group = properties("pluginGroup") |
24 | 25 | version = properties("pluginVersion") |
25 | 26 |
|
26 | 27 | // Configure project's dependencies |
27 | 28 | repositories { |
28 | | - mavenCentral() |
29 | | - jcenter() |
| 29 | + mavenCentral() |
| 30 | + jcenter() |
30 | 31 | } |
31 | 32 | dependencies { |
32 | | - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.16.0") |
| 33 | + detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0") |
33 | 34 | } |
34 | 35 |
|
35 | 36 | // Configure gradle-intellij-plugin plugin. |
36 | 37 | // Read more: https://github.com/JetBrains/gradle-intellij-plugin |
37 | 38 | intellij { |
38 | | - pluginName = properties("pluginName") |
39 | | - version = properties("platformVersion") |
40 | | - type = properties("platformType") |
41 | | - downloadSources = properties("platformDownloadSources").toBoolean() |
42 | | - updateSinceUntilBuild = true |
43 | | - |
44 | | - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. |
45 | | - setPlugins(*properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray()) |
| 39 | + pluginName = properties("pluginName") |
| 40 | + version = properties("platformVersion") |
| 41 | + type = properties("platformType") |
| 42 | + downloadSources = properties("platformDownloadSources").toBoolean() |
| 43 | + updateSinceUntilBuild = true |
| 44 | + |
| 45 | + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. |
| 46 | + setPlugins(*properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray()) |
46 | 47 | } |
47 | 48 |
|
48 | 49 | // Configure gradle-changelog-plugin plugin. |
49 | 50 | // Read more: https://github.com/JetBrains/gradle-changelog-plugin |
50 | 51 | changelog { |
51 | | - version = properties("pluginVersion") |
52 | | - groups = emptyList() |
| 52 | + version = properties("pluginVersion") |
| 53 | + path = "${project.projectDir}/CHANGELOG.md" |
| 54 | + header = closure { "[$version] - ${date()}" } |
| 55 | + itemPrefix = "-" |
| 56 | + keepUnreleasedSection = true |
| 57 | + unreleasedTerm = "[Unreleased]" |
| 58 | + groups = listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security") |
53 | 59 | } |
54 | 60 |
|
55 | 61 | // Configure detekt plugin. |
56 | 62 | // Read more: https://detekt.github.io/detekt/kotlindsl.html |
57 | 63 | detekt { |
58 | | - config = files("./detekt-config.yml") |
59 | | - buildUponDefaultConfig = true |
60 | | - |
61 | | - reports { |
62 | | - html.enabled = false |
63 | | - xml.enabled = false |
64 | | - txt.enabled = false |
65 | | - } |
| 64 | + config = files("./detekt-config.yml") |
| 65 | + buildUponDefaultConfig = true |
| 66 | + |
| 67 | + reports { |
| 68 | + html.enabled = false |
| 69 | + xml.enabled = false |
| 70 | + txt.enabled = false |
| 71 | + } |
66 | 72 | } |
67 | 73 |
|
68 | 74 | tasks { |
69 | | - // Set the compatibility versions to 1.8 |
70 | | - withType<JavaCompile> { |
71 | | - sourceCompatibility = "1.8" |
72 | | - targetCompatibility = "1.8" |
73 | | - } |
74 | | - withType<KotlinCompile> { |
75 | | - kotlinOptions.jvmTarget = "1.8" |
76 | | - } |
77 | | - |
78 | | - withType<Detekt> { |
79 | | - jvmTarget = "1.8" |
80 | | - } |
81 | | - |
82 | | - patchPluginXml { |
83 | | - version(properties("pluginVersion")) |
84 | | - sinceBuild(properties("pluginSinceBuild")) |
85 | | - untilBuild(properties("pluginUntilBuild")) |
86 | | - |
87 | | - // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest |
88 | | - pluginDescription( |
89 | | - closure { |
90 | | - File("./README.md").readText().lines().run { |
91 | | - val start = "<!-- Plugin description -->" |
92 | | - val end = "<!-- Plugin description end -->" |
93 | | - |
94 | | - if (!containsAll(listOf(start, end))) { |
95 | | - throw GradleException("Plugin description section not found in README.md:\n$start ... $end") |
96 | | - } |
97 | | - subList(indexOf(start) + 1, indexOf(end)) |
98 | | - }.joinToString("\n").run { markdownToHTML(this) } |
99 | | - } |
100 | | - ) |
101 | | - |
102 | | - // Get the latest available change notes from the changelog file |
103 | | - changeNotes( |
104 | | - closure { |
105 | | - changelog.getLatest().toHTML() |
106 | | - } |
107 | | - ) |
108 | | - } |
109 | | - |
110 | | - runPluginVerifier { |
111 | | - ideVersions(properties("pluginVerifierIdeVersions")) |
112 | | - } |
113 | | - |
114 | | - publishPlugin { |
115 | | - dependsOn("patchChangelog") |
116 | | - token(System.getenv("PUBLISH_TOKEN")) |
117 | | - // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 |
118 | | - // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: |
119 | | - // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel |
120 | | - channels(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()) |
121 | | - } |
| 75 | + // Set the compatibility versions to 1.8 |
| 76 | + withType<JavaCompile> { |
| 77 | + sourceCompatibility = "1.8" |
| 78 | + targetCompatibility = "1.8" |
| 79 | + } |
| 80 | + withType<KotlinCompile> { |
| 81 | + kotlinOptions.jvmTarget = "1.8" |
| 82 | + } |
| 83 | + |
| 84 | + withType<Detekt> { |
| 85 | + jvmTarget = "1.8" |
| 86 | + } |
| 87 | + |
| 88 | + patchPluginXml { |
| 89 | + version(properties("pluginVersion")) |
| 90 | + sinceBuild(properties("pluginSinceBuild")) |
| 91 | + untilBuild(properties("pluginUntilBuild")) |
| 92 | + pluginDescription( |
| 93 | + closure { |
| 94 | + File("./README.md").readText().lines().run { |
| 95 | + val start = "<!-- Plugin description -->" |
| 96 | + val end = "<!-- Plugin description end -->" |
| 97 | + |
| 98 | + if (!containsAll(listOf(start, end))) { |
| 99 | + throw GradleException("Plugin description section not found in README.md:\n$start ... $end") |
| 100 | + } |
| 101 | + subList(indexOf(start) + 1, indexOf(end)) |
| 102 | + }.joinToString("\n").run { markdownToHTML(this) } |
| 103 | + } |
| 104 | + ) |
| 105 | + |
| 106 | + changeNotes( |
| 107 | + closure { |
| 108 | + changelog.getUnreleased().toHTML() |
| 109 | + } |
| 110 | + ) |
| 111 | + } |
| 112 | + |
| 113 | + runPluginVerifier { |
| 114 | + ideVersions(properties("pluginVerifierIdeVersions")) |
| 115 | + } |
| 116 | + |
| 117 | + publishPlugin { |
| 118 | + dependsOn("patchChangelog") |
| 119 | + token(System.getenv("PUBLISH_TOKEN")) |
| 120 | + // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 |
| 121 | + // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: |
| 122 | + // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel |
| 123 | + channels(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()) |
| 124 | + } |
122 | 125 | } |
0 commit comments