Improve the gradle build configs, and add the patchPluginXml task to

automate setup the blugin description and to genrate the changelog.
This commit is contained in:
Anas Elgarhy 2023-01-15 14:06:18 +02:00
parent 92ce0827f6
commit 7c180daf94
No known key found for this signature in database
GPG key ID: 0501802A1D496528

View file

@ -1,10 +1,16 @@
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
fun properties(key: String) = project.findProperty(key).toString()
plugins {
id("java")
id("org.jetbrains.intellij") version "1.10.0-SNAPSHOT"
id("org.jetbrains.intellij") version "1.11.0"
id("org.jetbrains.changelog") version "2.0.0"
}
group = "com.anas.intellij.plugins.ayah"
version = "0.0.9"
version = properties("pluginVersion")
group = properties("pluginGroup")
repositories {
mavenCentral()
@ -12,7 +18,7 @@ repositories {
}
dependencies {
implementation("com.github.anas-elgarhy:alquran-cloud-api:0.4.0-v1") // TODO: fix this
implementation("com.github.anas-elgarhy:alquran-cloud-api:0.4.1-v1")
implementation("com.miglayout:miglayout-swing:11.0")
// implementation("com.github.goxr3plus:java-stream-player:10.0.2")
implementation("com.googlecode.soundlibs:jlayer:1.0.1.4")
@ -31,9 +37,9 @@ java {
// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
version.set("LATEST-EAP-SNAPSHOT")
type.set("IC") // Target IDE Platform
downloadSources.set(true)
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
plugins.set(listOf(/* Plugin Dependencies */))
}
@ -46,18 +52,45 @@ tasks {
targetCompatibility = "17"
}
patchPluginXml {
sinceBuild.set("223")
untilBuild.set("223.*")
wrapper {
gradleVersion = properties("gradleVersion")
}
signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set("")
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
file("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").let { markdownToHTML(it) }
)
// Get the latest available change notes from the changelog file
changeNotes.set(provider {
with(changelog) {
renderItem(
getOrNull(properties("pluginVersion")) ?: getLatest(),
Changelog.OutputType.HTML,
)
}
})
}
publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
}
}