1- import io.gitlab.arturbosch.detekt.Detekt
1+ import org.jetbrains.changelog.Changelog
22import org.jetbrains.changelog.markdownToHTML
3- import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
43
5- /* *
6- * Get properties from gradle.properties
7- */
8- fun properties (key : String ) = project.findProperty(key).toString()
4+ fun properties (key : String ) = providers.gradleProperty(key)
5+ fun environment (key : String ) = providers.environmentVariable(key)
96
107plugins {
11- id(" java" )
12- id(" org.jetbrains.kotlin.jvm" ) version " 1.8.0-Beta"
13- id(" org.jetbrains.intellij" ) version " 1.10.0"
14- id(" org.jetbrains.changelog" ) version " 2.0.0"
15- id(" io.gitlab.arturbosch.detekt" ) version " 1.22.0"
16- id(" org.jlleitschuh.gradle.ktlint" ) version " 11.0.0"
17- id(" org.jetbrains.qodana" ) version " 0.1.13"
18- id(" com.github.ben-manes.versions" ) version " 0.44.0"
8+ id(" java" ) // Java support
9+ alias(libs.plugins.kotlin) // Kotlin support
10+ alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
11+ alias(libs.plugins.changelog) // Gradle Changelog Plugin
12+ alias(libs.plugins.qodana) // Gradle Qodana Plugin
13+ alias(libs.plugins.kover) // Gradle Kover Plugin
14+ id(" com.github.ben-manes.versions" ) version " 0.47.0"
1915}
2016
21- group = properties(" pluginGroup" )
22- version = properties(" pluginVersion" )
17+ group = properties(" pluginGroup" ).get()
18+ version = properties(" pluginVersion" ).get()
2319
2420// Configure project's dependencies
2521repositories {
2622 mavenCentral()
2723}
2824
29- dependencies {
30- detektPlugins( " io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0 " )
25+ kotlin {
26+ jvmToolchain( 17 )
3127}
3228
33- // Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
3429intellij {
35- pluginName.set( properties(" pluginName" ) )
36- version.set( properties(" platformVersion" ) )
37- type.set( properties(" platformType" ) )
30+ pluginName = properties(" pluginName" )
31+ version = properties(" platformVersion" )
32+ type = properties(" platformType" )
3833
3934 // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
40- plugins.set( properties(" platformPlugins" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
35+ plugins = properties(" platformPlugins" ).map { it. split(' ,' ).map(String ::trim).filter(String ::isNotEmpty) }
4136}
4237
4338// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
4439changelog {
45- version.set(properties( " pluginVersion " ) )
46- groups.set(emptyList() )
40+ groups.empty( )
41+ repositoryUrl = properties( " pluginRepositoryUrl " )
4742}
4843
44+
4945// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
5046qodana {
51- cachePath.set(projectDir.resolve(" .qodana" ).canonicalPath)
52- reportPath.set(projectDir.resolve(" build/reports/inspections" ).canonicalPath)
53- saveReport.set(true )
54- showReport.set(System .getenv(" QODANA_SHOW_REPORT" )?.toBoolean() ? : false )
55- }
56-
57- // Configure detekt plugin.
58- // Read more: https://detekt.github.io/detekt/kotlindsl.html
59- detekt {
60- config = files(" ./detekt-config.yml" )
61- buildUponDefaultConfig = true
47+ cachePath = provider { file(" .qodana" ).canonicalPath }
48+ reportPath = provider { file(" build/reports/inspections" ).canonicalPath }
49+ saveReport = true
50+ showReport = environment(" QODANA_SHOW_REPORT" ).map { it.toBoolean() }.getOrElse(false )
6251}
6352
64- tasks {
65- // Set the JVM compatibility versions
66- properties(" javaVersion" ).let {
67- withType<JavaCompile > {
68- sourceCompatibility = it
69- targetCompatibility = it
70- }
71- withType<KotlinCompile > {
72- kotlinOptions.jvmTarget = it
73- }
74- withType<Detekt > {
75- jvmTarget = it
53+ // Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
54+ koverReport {
55+ defaults {
56+ xml {
57+ onCheck = true
7658 }
7759 }
60+ }
7861
62+ tasks {
7963 wrapper {
80- gradleVersion = properties(" gradleVersion" )
64+ gradleVersion = properties(" gradleVersion" ).get()
8165 }
8266
8367 patchPluginXml {
84- version.set( properties(" pluginVersion" ) )
85- sinceBuild.set( properties(" pluginSinceBuild" ) )
86- untilBuild.set( properties(" pluginUntilBuild" ) )
68+ version = properties(" pluginVersion" )
69+ sinceBuild = properties(" pluginSinceBuild" )
70+ untilBuild = properties(" pluginUntilBuild" )
8771
8872 // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
89- pluginDescription.set(
90- projectDir.resolve(" README.md" ).readText().lines().run {
91- val start = " <!-- Plugin description -->"
92- val end = " <!-- Plugin description end -->"
73+ pluginDescription = providers.fileContents(layout.projectDirectory.file(" README.md" )).asText.map {
74+ val start = " <!-- Plugin description -->"
75+ val end = " <!-- Plugin description end -->"
9376
77+ with (it.lines()) {
9478 if (! containsAll(listOf (start, end))) {
9579 throw GradleException (" Plugin description section not found in README.md:\n $start ... $end " )
9680 }
97- subList(indexOf(start) + 1 , indexOf(end))
98- }.joinToString( " \n " ). run { markdownToHTML( this ) }
99- )
81+ subList(indexOf(start) + 1 , indexOf(end)).joinToString( " \n " ). let (::markdownToHTML)
82+ }
83+ }
10084
85+ val changelog = project.changelog // local variable for configuration cache compatibility
10186 // Get the latest available change notes from the changelog file
102- changeNotes.set(
103- provider {
104- changelog.run {
105- getOrNull(properties(" pluginVersion" )) ? : getLatest()
106- }.toHTML()
87+ changeNotes = properties(" pluginVersion" ).map { pluginVersion ->
88+ with (changelog) {
89+ renderItem(
90+ (getOrNull(pluginVersion) ? : getUnreleased())
91+ .withHeader(false )
92+ .withEmptySections(false ),
93+ Changelog .OutputType .HTML ,
94+ )
10795 }
108- )
96+ }
10997 }
11098
11199 // Configure UI tests plugin
@@ -118,17 +106,17 @@ tasks {
118106 }
119107
120108 signPlugin {
121- certificateChain.set( System .getenv( " CERTIFICATE_CHAIN" ) )
122- privateKey.set( System .getenv( " PRIVATE_KEY" ) )
123- password.set( System .getenv( " PRIVATE_KEY_PASSWORD" ) )
109+ certificateChain = environment( " CERTIFICATE_CHAIN" )
110+ privateKey = environment( " PRIVATE_KEY" )
111+ password = environment( " PRIVATE_KEY_PASSWORD" )
124112 }
125113
126114 publishPlugin {
127115 dependsOn(" patchChangelog" )
128- token.set( System .getenv( " PUBLISH_TOKEN" ) )
129- // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
116+ token = environment( " PUBLISH_TOKEN" )
117+ // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
130118 // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
131119 // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
132- channels.set( listOf ( properties(" pluginVersion" ).split(' -' ).getOrElse(1 ) { " default" }.split(' .' ).first()))
120+ channels = properties(" pluginVersion" ).map { listOf (it. split(' -' ).getOrElse(1 ) { " default" }.split(' .' ).first()) }
133121 }
134- }
122+ }
0 commit comments