mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2026-03-02 03:39:24 +00:00
properties shorthand function for accessing gradle.properties in a cleaner way (#92)
This commit is contained in:
committed by
GitHub
parent
b812e459d4
commit
507b055937
@@ -3,6 +3,8 @@ import org.jetbrains.changelog.closure
|
||||
import org.jetbrains.changelog.markdownToHTML
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
fun properties(key: String) = project.findProperty(key).toString()
|
||||
|
||||
plugins {
|
||||
// Java support
|
||||
id("java")
|
||||
@@ -18,23 +20,8 @@ plugins {
|
||||
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
|
||||
}
|
||||
|
||||
// Import variables from gradle.properties file
|
||||
val pluginGroup: String by project
|
||||
// `pluginName_` variable ends with `_` because of the collision with Kotlin magic getter in the `intellij` closure.
|
||||
// Read more about the issue: https://github.com/JetBrains/intellij-platform-plugin-template/issues/29
|
||||
val pluginName_: String by project
|
||||
val pluginVersion: String by project
|
||||
val pluginSinceBuild: String by project
|
||||
val pluginUntilBuild: String by project
|
||||
val pluginVerifierIdeVersions: String by project
|
||||
|
||||
val platformType: String by project
|
||||
val platformVersion: String by project
|
||||
val platformPlugins: String by project
|
||||
val platformDownloadSources: String by project
|
||||
|
||||
group = pluginGroup
|
||||
version = pluginVersion
|
||||
group = properties("pluginGroup")
|
||||
version = properties("projectVersion")
|
||||
|
||||
// Configure project's dependencies
|
||||
repositories {
|
||||
@@ -48,20 +35,20 @@ dependencies {
|
||||
// Configure gradle-intellij-plugin plugin.
|
||||
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
|
||||
intellij {
|
||||
pluginName = pluginName_
|
||||
version = platformVersion
|
||||
type = platformType
|
||||
downloadSources = platformDownloadSources.toBoolean()
|
||||
pluginName = properties("pluginName")
|
||||
version = properties("platformVersion")
|
||||
type = properties("platformType")
|
||||
downloadSources = properties("platformDownloadSources").toBoolean()
|
||||
updateSinceUntilBuild = true
|
||||
|
||||
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
|
||||
setPlugins(*platformPlugins.split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray())
|
||||
setPlugins(*properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray())
|
||||
}
|
||||
|
||||
// Configure gradle-changelog-plugin plugin.
|
||||
// Read more: https://github.com/JetBrains/gradle-changelog-plugin
|
||||
changelog {
|
||||
version = pluginVersion
|
||||
version = properties("pluginVersion")
|
||||
groups = emptyList()
|
||||
}
|
||||
|
||||
@@ -93,9 +80,9 @@ tasks {
|
||||
}
|
||||
|
||||
patchPluginXml {
|
||||
version(pluginVersion)
|
||||
sinceBuild(pluginSinceBuild)
|
||||
untilBuild(pluginUntilBuild)
|
||||
version(properties("pluginVersion"))
|
||||
sinceBuild(properties("pluginSinceBuild"))
|
||||
untilBuild(properties("pluginUntilBuild"))
|
||||
|
||||
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
|
||||
pluginDescription(
|
||||
@@ -121,7 +108,7 @@ tasks {
|
||||
}
|
||||
|
||||
runPluginVerifier {
|
||||
ideVersions(pluginVerifierIdeVersions)
|
||||
ideVersions(properties("pluginVerifierIdeVersions"))
|
||||
}
|
||||
|
||||
publishPlugin {
|
||||
@@ -130,6 +117,6 @@ tasks {
|
||||
// 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(pluginVersion.split('-').getOrElse(1) { "default" }.split('.').first())
|
||||
channels(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user