1
+ import org.jetbrains.changelog.Changelog
1
2
import org.jetbrains.changelog.date
2
3
import org.jetbrains.changelog.markdownToHTML
3
- import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4
-
5
- fun properties (key : String ) = project.findProperty(key).toString()
6
4
7
5
plugins {
8
- // Java support
9
6
id(" java" )
10
- // Kotlin support
11
- id(" org.jetbrains.kotlin.jvm" ) version " 1.5.30"
12
- // Gradle IntelliJ Plugin
13
- id(" org.jetbrains.intellij" ) version " 1.11.0"
14
- // Gradle Changelog Plugin
15
- id(" org.jetbrains.changelog" ) version " 1.3.0"
16
- // Gradle Qodana Plugin
17
- id(" org.jetbrains.qodana" ) version " 0.1.12"
7
+ id(" org.jetbrains.changelog" ) version " 2.2.1"
8
+ id(" org.jetbrains.intellij.platform" ) version " 2.0.1"
18
9
}
19
10
20
- group = properties(" pluginGroup" )
21
- version = properties(" pluginVersion" )
22
-
23
- // Configure project's dependencies
24
11
repositories {
25
12
mavenCentral()
13
+ intellijPlatform {
14
+ defaultRepositories()
15
+ }
26
16
}
27
17
28
18
dependencies {
@@ -32,107 +22,92 @@ dependencies {
32
22
implementation(" com.twelvemonkeys.imageio:imageio-webp:3.10.1" )
33
23
implementation(" com.twelvemonkeys.imageio:imageio-batik:3.10.1" )
34
24
implementation(" com.tinify:tinify:1.8.3" )
35
- }
36
25
37
- // Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
38
- intellij {
39
- pluginName.set(properties( " pluginName " ) )
40
- version.set(properties( " platformVersion " ) )
41
- type.set(properties( " platformType " ))
42
- downloadSources.set(properties( " platformDownloadSources " ).toBoolean() )
43
- updateSinceUntilBuild.set( false )
44
- // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
45
- plugins.set(properties( " platformPlugins " ).split( ' , ' ).map( String ::trim).filter( String ::isNotEmpty))
26
+ intellijPlatform {
27
+ create(providers.gradleProperty( " platformType " ), providers.gradleProperty( " platformVersion " ))
28
+ bundledPlugins(providers.gradleProperty( " platformBundledPlugins " ).map { it.split( ' , ' ) } )
29
+ plugins(providers.gradleProperty( " platformPlugins " ).map { it.split( ' , ' ) } )
30
+
31
+ instrumentationTools( )
32
+ pluginVerifier( )
33
+ zipSigner()
34
+ }
46
35
}
47
36
48
- // Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
49
37
changelog {
50
- version.set(properties (" pluginVersion" ))
51
- path.set(" ${project.projectDir} / CHANGELOG.md" )
38
+ version.set(providers.gradleProperty (" pluginVersion" ))
39
+ path.set(file( " CHANGELOG.md" ).canonicalPath )
52
40
header.set(provider { " [${version.get()} ] - ${date()} " })
41
+ headerParserRegex.set(""" (\d+\.\d+\.\d+)""" .toRegex())
53
42
itemPrefix.set(" -" )
54
43
keepUnreleasedSection.set(true )
55
44
unreleasedTerm.set(" [未完待续]" )
56
45
groups.set(listOf (" " ))
57
46
}
58
47
59
- // Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
60
- qodana {
61
- cachePath.set(projectDir.resolve(" .qodana" ).canonicalPath)
62
- reportPath.set(projectDir.resolve(" build/reports/inspections" ).canonicalPath)
63
- saveReport.set(true )
64
- showReport.set(System .getenv(" QODANA_SHOW_REPORT" ).toBoolean())
65
- }
48
+ intellijPlatform {
49
+ pluginConfiguration {
50
+ version = providers.gradleProperty(" pluginVersion" )
51
+ description = providers.fileContents(layout.projectDirectory.file(" PLUGIN_DESC.md" )).asText.map {
52
+ val start = " <!-- Plugin description -->"
53
+ val end = " <!-- Plugin description end -->"
66
54
67
- tasks {
68
- // Set the JVM compatibility versions
69
- properties(" javaVersion" ).let {
70
- withType<JavaCompile > {
71
- sourceCompatibility = it
72
- targetCompatibility = it
55
+ with (it.lines()) {
56
+ if (! containsAll(listOf (start, end))) {
57
+ throw GradleException (" Plugin description section not found in README.md:\n $start ... $end " )
58
+ }
59
+ subList(indexOf(start) + 1 , indexOf(end)).joinToString(" \n " ).let (::markdownToHTML)
60
+ }
61
+ }
62
+ ideaVersion {
63
+ sinceBuild = providers.gradleProperty(" pluginSinceBuild" )
64
+ untilBuild = provider { null }
73
65
}
74
- withType<KotlinCompile > {
75
- kotlinOptions.jvmTarget = it
66
+ val changelog = project.changelog
67
+ changeNotes = providers.gradleProperty(" pluginVersion" ).map { pluginVersion ->
68
+ with (changelog) {
69
+ renderItem(
70
+ (getOrNull(pluginVersion) ? : getUnreleased())
71
+ .withHeader(false )
72
+ .withEmptySections(false ),
73
+ Changelog .OutputType .HTML ,
74
+ )
75
+ }
76
76
}
77
77
}
78
-
79
- wrapper {
80
- gradleVersion = properties(" gradleVersion" )
78
+ signing {
79
+ certificateChainFile.set(project.file(" profiles/chain.crt" ))
80
+ privateKeyFile.set(project.file(" profiles/private.pem" ))
81
+ password.set(providers.environmentVariable(" PRIVATE_KEY_PASSWORD" ))
81
82
}
82
-
83
- patchPluginXml {
84
- version.set(properties(" pluginVersion" ))
85
- // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
86
- pluginDescription.set(
87
- projectDir.resolve(" PLUGIN_DESC.md" ).readText().lines().run {
88
- val start = " <!-- Plugin description -->"
89
- val end = " <!-- Plugin description end -->"
90
-
91
- if (! containsAll(listOf (start, end))) {
92
- throw GradleException (" Plugin description section not found in PLUGIN_DESC.md:\n $start ... $end " )
93
- }
94
- subList(indexOf(start) + 1 , indexOf(end))
95
- }.joinToString(" \n " ).run { markdownToHTML(this ) }
96
- )
97
-
98
- // Get the latest available change notes from the changelog file
99
- changeNotes.set(provider {
100
- changelog.run {
101
- getOrNull(properties(" pluginVersion" )) ? : getLatest()
102
- }.toHTML()
103
- })
83
+ publishing {
84
+ token = providers.environmentVariable(" PUBLISH_TOKEN" )
85
+ channels = providers.gradleProperty(" pluginVersion" ).map { listOf (it.substringAfter(' -' , " " ).substringBefore(' .' ).ifEmpty { " default" }) }
104
86
}
105
-
106
- runPluginVerifier {
107
- ideVersions.set(properties(" pluginVerifierIdeVersions" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
87
+ pluginVerification {
88
+ ides {
89
+ recommended()
90
+ }
108
91
}
92
+ }
109
93
110
- // Configure UI tests plugin
111
- // Read more: https://github.com/JetBrains/intellij-ui-test-robot
112
- runIdeForUiTests {
113
- systemProperty(" robot-server.port" , " 8082" )
114
- systemProperty(" ide.mac.message.dialogs.as.sheets" , " false" )
115
- systemProperty(" jb.privacy.policy.text" , " <!--999.999-->" )
116
- systemProperty(" jb.consents.confirmation.enabled" , " false" )
94
+ intellijPlatformTesting {
95
+ runIde {
96
+ register(" runOnAndroidStudio" ) {
97
+ localPath = file(providers.gradleProperty(" idePath" ))
98
+ prepareSandboxTask {
99
+ sandboxDirectory = project.layout.buildDirectory.dir(" sandbox-as" )
100
+ }
101
+ }
117
102
}
103
+ }
118
104
119
- signPlugin {
120
- certificateChainFile.set(project.file(" profiles/chain.crt" ))
121
- privateKeyFile.set(project.file(" profiles/private.pem" ))
122
- password.set(System .getenv(" PRIVATE_KEY_PASSWORD" ))
105
+ tasks {
106
+ wrapper {
107
+ gradleVersion = providers.gradleProperty(" gradleVersion" ).get()
123
108
}
124
109
125
110
publishPlugin {
126
- // dependsOn("patchChangelog")
127
- token.set(System .getenv(" PUBLISH_TOKEN" ))
128
- // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
129
- // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
130
- // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
131
- channels.set(listOf (properties(" pluginVersion" ).split(' -' ).getOrElse(1 ) { " default" }.split(' .' ).first()))
132
- }
133
-
134
- runIde {
135
- // jbrVersion.set("11_0_10b1145.115")
136
- ideDir.set(file(properties(" idePath" )))
111
+ dependsOn(patchChangelog)
137
112
}
138
113
}
0 commit comments