1
1
import org.jetbrains.changelog.Changelog
2
2
import org.jetbrains.changelog.markdownToHTML
3
3
4
- fun properties (key : String ) = project.findProperty(key).toString()
4
+ fun properties (key : String ) = providers.gradleProperty(key)
5
+ fun environment (key : String ) = providers.environmentVariable(key)
5
6
6
7
plugins {
7
8
// Java support
8
9
id(" java" )
9
10
// Kotlin support
10
- id(" org.jetbrains.kotlin.jvm" ) version " 1.8.10 "
11
+ id(" org.jetbrains.kotlin.jvm" ) version " 1.8.20 "
11
12
// Gradle IntelliJ Plugin
12
- id(" org.jetbrains.intellij" ) version " 1.13.0 "
13
+ id(" org.jetbrains.intellij" ) version " 1.13.3 "
13
14
// Gradle Changelog Plugin
14
15
id(" org.jetbrains.changelog" ) version " 2.0.0"
15
16
// Gradle Qodana Plugin
@@ -18,16 +19,16 @@ plugins {
18
19
id(" org.jetbrains.kotlinx.kover" ) version " 0.6.1"
19
20
}
20
21
21
- group = properties(" pluginGroup" )
22
- version = properties(" pluginVersion" )
22
+ group = properties(" pluginGroup" ).get()
23
+ version = properties(" pluginVersion" ).get()
23
24
24
25
// Configure project's dependencies
25
26
repositories {
26
27
mavenCentral()
27
28
}
28
29
29
30
kotlin {
30
- jvmToolchain(properties(" javaVersion" ).toInt())
31
+ jvmToolchain(properties(" javaVersion" ).get(). toInt())
31
32
}
32
33
33
34
// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
@@ -37,21 +38,21 @@ intellij {
37
38
type.set(properties(" platformType" ))
38
39
39
40
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
40
- plugins.set(properties(" platformPlugins" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
41
+ plugins.set(properties(" platformPlugins" ).map { it. split(' ,' ).map(String ::trim).filter(String ::isNotEmpty) } )
41
42
}
42
43
43
44
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
44
45
changelog {
45
- groups.set(emptyList() )
46
+ groups.empty( )
46
47
repositoryUrl.set(properties(" pluginRepositoryUrl" ))
47
48
}
48
49
49
50
// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
50
51
qodana {
51
- cachePath.set(file(" .qodana" ).canonicalPath)
52
- reportPath.set(file(" build/reports/inspections" ).canonicalPath)
52
+ cachePath.set(provider { file(" .qodana" ).canonicalPath } )
53
+ reportPath.set(provider { file(" build/reports/inspections" ).canonicalPath } )
53
54
saveReport.set(true )
54
- showReport.set(System .getenv (" QODANA_SHOW_REPORT" )?. toBoolean() ? : false )
55
+ showReport.set(environment (" QODANA_SHOW_REPORT" ).map { it. toBoolean() }.getOrElse( false ) )
55
56
}
56
57
57
58
// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
@@ -61,7 +62,7 @@ kover.xmlReport {
61
62
62
63
tasks {
63
64
wrapper {
64
- gradleVersion = properties(" gradleVersion" )
65
+ gradleVersion = properties(" gradleVersion" ).get()
65
66
}
66
67
67
68
patchPluginXml {
@@ -70,24 +71,26 @@ tasks {
70
71
untilBuild.set(properties(" pluginUntilBuild" ))
71
72
72
73
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
73
- pluginDescription.set(
74
- file(" README.md" ).readText().lines().run {
75
- val start = " <!-- Plugin description -->"
76
- val end = " <!-- Plugin description end -->"
74
+ pluginDescription.set(providers.fileContents(layout.projectDirectory.file(" README.md" )).asText.map {
75
+ val start = " <!-- Plugin description -->"
76
+ val end = " <!-- Plugin description end -->"
77
77
78
+ with (it.lines()) {
78
79
if (! containsAll(listOf (start, end))) {
79
80
throw GradleException (" Plugin description section not found in README.md:\n $start ... $end " )
80
81
}
81
- subList(indexOf(start) + 1 , indexOf(end))
82
- }.joinToString( " \n " ). let { markdownToHTML(it) }
83
- )
82
+ subList(indexOf(start) + 1 , indexOf(end)).joinToString( " \n " ). let (::markdownToHTML)
83
+ }
84
+ } )
84
85
86
+ val changelog = project.changelog // local variable for configuration cache compatibility
85
87
// Get the latest available change notes from the changelog file
86
- changeNotes.set(provider {
88
+ changeNotes.set(properties( " pluginVersion " ).map { pluginVersion ->
87
89
with (changelog) {
88
90
renderItem(
89
- getOrNull(properties(" pluginVersion" ))
90
- ? : runCatching { getLatest() }.getOrElse { getUnreleased() },
91
+ (getOrNull(pluginVersion) ? : getUnreleased())
92
+ .withHeader(false )
93
+ .withEmptySections(false ),
91
94
Changelog .OutputType .HTML ,
92
95
)
93
96
}
@@ -104,17 +107,17 @@ tasks {
104
107
}
105
108
106
109
signPlugin {
107
- certificateChain.set(System .getenv (" CERTIFICATE_CHAIN" ))
108
- privateKey.set(System .getenv (" PRIVATE_KEY" ))
109
- password.set(System .getenv (" PRIVATE_KEY_PASSWORD" ))
110
+ certificateChain.set(environment (" CERTIFICATE_CHAIN" ))
111
+ privateKey.set(environment (" PRIVATE_KEY" ))
112
+ password.set(environment (" PRIVATE_KEY_PASSWORD" ))
110
113
}
111
114
112
115
publishPlugin {
113
116
dependsOn(" patchChangelog" )
114
- token.set(System .getenv (" PUBLISH_TOKEN" ))
117
+ token.set(environment (" PUBLISH_TOKEN" ))
115
118
// The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
116
119
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
117
120
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
118
- channels.set(listOf ( properties(" pluginVersion" ).split(' -' ).getOrElse(1 ) { " default" }.split(' .' ).first()))
121
+ channels.set(properties(" pluginVersion" ).map { listOf (it. split(' -' ).getOrElse(1 ) { " default" }.split(' .' ).first()) } )
119
122
}
120
123
}
0 commit comments