2323 */
2424@file:Suppress(" SpellCheckingInspection" , " HardCodedStringLiteral" )
2525
26+ import io.gitlab.arturbosch.detekt.Detekt
27+ import org.jetbrains.changelog.Changelog
28+ import org.jetbrains.changelog.markdownToHTML
2629import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2730
2831fun properties (key : String ) = project.findProperty(key).toString()
2932
33+ fun environment (key : String ) = providers.environmentVariable(key)
34+
3035fun fileProperties (key : String ) = project.findProperty(key).toString().let { if (it.isNotEmpty()) file(it) else null }
3136
3237
3338plugins {
39+ signing
3440 // Java support
3541 id(" java" )
36- // Kotlin support
37- id(" org.jetbrains.kotlin.jvm" ) version " 1.9.21"
38- // gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
39- id(" org.jetbrains.intellij" ) version " 1.16.0"
40- // gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
41- id(" org.jetbrains.changelog" ) version " 2.2.0"
42- // detekt linter - read more: https://detekt.github.io/detekt/gradle.html
43- id(" io.gitlab.arturbosch.detekt" ) version " 1.23.4"
44- // ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
45- id(" org.jlleitschuh.gradle.ktlint" ) version " 11.6.1"
42+ alias(libs.plugins.kotlin)
43+ alias(libs.plugins.gradleIntelliJPlugin)
44+ alias(libs.plugins.changelog)
45+ alias(libs.plugins.qodana)
46+ alias(libs.plugins.detekt)
47+ alias(libs.plugins.ktlint)
48+ alias(libs.plugins.kover)
4649}
4750
4851group = properties(" pluginGroup" )
@@ -64,8 +67,12 @@ java {
6467 }
6568}
6669
70+ kotlin {
71+ jvmToolchain(17 )
72+ }
73+
6774dependencies {
68- // detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.20.0 ")
75+ detektPlugins(" io.gitlab.arturbosch.detekt:detekt-formatting:1.23.4 " )
6976 implementation(" com.twelvemonkeys.imageio:imageio-core:$depsTwelveMonkeys " )
7077 implementation(" com.twelvemonkeys.imageio:imageio-metadata:$depsTwelveMonkeys " )
7178 implementation(" com.twelvemonkeys.imageio:imageio-sgi:$depsTwelveMonkeys " )
@@ -114,13 +121,18 @@ changelog {
114121
115122// Configure detekt plugin.
116123// Read more: https://detekt.github.io/detekt/kotlindsl.html
117- // detekt {
118- // config = files("./detekt-config.yml")
119- // buildUponDefaultConfig = true
120- // autoCorrect = true
121- // }
124+ detekt {
125+ config.setFrom(" ./detekt-config.yml" )
126+ buildUponDefaultConfig = true
127+ autoCorrect = true
128+ ignoreFailures = true
129+ }
122130
123131tasks {
132+ wrapper {
133+ gradleVersion = properties(" gradleVersion" )
134+ }
135+
124136 properties(" javaVersion" ).let {
125137 // Set the compatibility versions to 1.8
126138 withType<JavaCompile > {
@@ -133,10 +145,10 @@ tasks {
133145 }
134146 }
135147
136- // withType<Detekt> {
137- // jvmTarget = properties("javaVersion")
138- // reports.xml.required.set( true)
139- // }
148+ withType<Detekt > {
149+ jvmTarget = properties(" javaVersion" )
150+ reports.xml.required = true
151+ }
140152
141153 withType<Copy > {
142154 duplicatesStrategy = DuplicatesStrategy .INCLUDE
@@ -150,14 +162,12 @@ tasks {
150162 }
151163
152164 patchPluginXml {
153- version.set( properties(" pluginVersion" ) )
154- sinceBuild.set( properties(" pluginSinceBuild" ) )
155- untilBuild.set( properties(" pluginUntilBuild" ) )
165+ version = properties(" pluginVersion" )
166+ sinceBuild = properties(" pluginSinceBuild" )
167+ untilBuild = properties(" pluginUntilBuild" )
156168
157169 // Get the latest available change notes from the changelog file
158- changeNotes.set(
159- changelog.getLatest().toHTML()
160- )
170+ changeNotes = changelog.renderItem(changelog.getLatest(), Changelog .OutputType .HTML )
161171 }
162172
163173 runPluginVerifier {
@@ -174,18 +184,24 @@ tasks {
174184// }
175185
176186 signPlugin {
177- certificateChain.set( System .getenv( " CERTIFICATE_CHAIN" ) )
178- privateKey.set( System .getenv( " PRIVATE_KEY" ) )
179- password.set( System .getenv( " PRIVATE_KEY_PASSWORD" ) )
187+ certificateChain = environment( " CERTIFICATE_CHAIN" )
188+ privateKey = environment( " PRIVATE_KEY" )
189+ password = environment( " PRIVATE_KEY_PASSWORD" )
180190 }
181191
182192 publishPlugin {
183- // dependsOn("patchChangelog")
184- token.set(System .getenv(" INTELLIJ_PUBLISH_TOKEN" ) ? : file(" ./publishToken" ).readText().trim())
185- channels.set(listOf (properties(" pluginVersion" ).split(' -' ).getOrElse(1 ) { " default" }.split(' .' ).first()))
193+ token = environment(" PUBLISH_TOKEN" )
194+ channels = listOf (properties(" pluginVersion" ).split(' -' ).getOrElse(1 ) { " default" }.split(' .' ).first())
186195 }
187196
188197 runIde {
189- ideDir.set(fileProperties(" idePath" ))
198+ ideDir = fileProperties(" idePath" )
199+ }
200+
201+ register(" markdownToHtml" ) {
202+ val input = File (" ${project.projectDir} /docs/CHANGELOG.md" )
203+ File (" ${project.projectDir} /docs/CHANGELOG.html" ).run {
204+ writeText(markdownToHTML(input.readText()))
205+ }
190206 }
191207}
0 commit comments