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 { plugins {
id("java") 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 = properties("pluginVersion")
version = "0.0.9" group = properties("pluginGroup")
repositories { repositories {
mavenCentral() mavenCentral()
@ -12,7 +18,7 @@ repositories {
} }
dependencies { 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.miglayout:miglayout-swing:11.0")
// implementation("com.github.goxr3plus:java-stream-player:10.0.2") // implementation("com.github.goxr3plus:java-stream-player:10.0.2")
implementation("com.googlecode.soundlibs:jlayer:1.0.1.4") implementation("com.googlecode.soundlibs:jlayer:1.0.1.4")
@ -31,9 +37,9 @@ java {
// Configure Gradle IntelliJ Plugin // Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html // Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij { intellij {
version.set("LATEST-EAP-SNAPSHOT") pluginName.set(properties("pluginName"))
type.set("IC") // Target IDE Platform version.set(properties("platformVersion"))
downloadSources.set(true) type.set(properties("platformType"))
plugins.set(listOf(/* Plugin Dependencies */)) plugins.set(listOf(/* Plugin Dependencies */))
} }
@ -46,18 +52,45 @@ tasks {
targetCompatibility = "17" targetCompatibility = "17"
} }
patchPluginXml { wrapper {
sinceBuild.set("223") gradleVersion = properties("gradleVersion")
untilBuild.set("223.*")
} }
signPlugin { patchPluginXml {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) version.set(properties("pluginVersion"))
privateKey.set(System.getenv("PRIVATE_KEY")) sinceBuild.set(properties("pluginSinceBuild"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD")) 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 { publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN")) 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()))
} }
} }