properties shorthand function for accessing gradle.properties in a cleaner way (#92)

This commit is contained in:
Jakub Chrzanowski 2021-02-25 10:41:19 +01:00 committed by GitHub
parent b812e459d4
commit 507b055937
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 31 deletions

View File

@ -2,7 +2,7 @@
# -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
pluginGroup = %GROUP%
pluginName_ = %NAME%
pluginName = %NAME%
pluginVersion = 0.0.1
pluginSinceBuild = 202
pluginUntilBuild = 203.*

View File

@ -114,7 +114,7 @@ jobs:
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
NAME="$(echo "$PROPERTIES" | grep "^pluginName_:" | cut -f2- -d ' ')"
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"

View File

@ -3,6 +3,9 @@
# IntelliJ Platform Plugin Template Changelog
## [Unreleased]
### Added
- `properties` shorthand function for accessing `gradle.properties` in a cleaner way
## [0.8.3]
### Changed
- Dependencies - upgrade `org.jetbrains.intellij` to `0.7.2`

View File

@ -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())
}
}

View File

@ -2,7 +2,7 @@
# -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
pluginGroup = org.jetbrains.plugins.template
pluginName_ = IntelliJ Platform Plugin Template
pluginName = IntelliJ Platform Plugin Template
pluginVersion = 0.8.3
pluginSinceBuild = 202
pluginUntilBuild = 203.*