Skip to content

Commit

Permalink
Use Intellij Platform Gradle Plugin 2.0.0-beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfromXXII committed Apr 16, 2024
1 parent 5f69135 commit 5fd0df3
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 117 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.gradle
.idea
.intellijPlatform
build
214 changes: 100 additions & 114 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.intellij.platform.gradle.extensions.TestFrameworkType

fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.9.20"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.17.0"
// IntelliJ Platform Gradle Plugin
id("org.jetbrains.intellij.platform") version "2.0.0-beta1"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.2.0"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
Expand All @@ -20,73 +23,106 @@ plugins {

sourceSets["main"].java.srcDirs("src/main/gen")

// 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
group = properties("pluginGroup").get()
version = properties("pluginVersion").get()

val platformType: String by project
val platformVersion: String by project
val platformPlugins: String by project
val platformDownloadSources: String by project
// Set the JVM language level used to build the project.
kotlin {
jvmToolchain(17)
}

group = pluginGroup
version = pluginVersion
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

// Configure project's dependencies
repositories {
maven("https://cache-redirector.jetbrains.com/maven-central")
maven("https://cache-redirector.jetbrains.com/intellij-repository/releases")
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
maven("https://cache-redirector.jetbrains.com/jcenter.bintray.com")
mavenCentral()

// IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
intellijPlatform {
defaultRepositories()
}
}

// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
testImplementation("com.jetbrains.intellij.go:go-test-framework:241.14494.238") {
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
exclude("org.jetbrains.kotlin", "kotlin-reflect")
exclude("com.jetbrains.rd", "rd-core")
exclude("com.jetbrains.rd", "rd-swing")
exclude("com.jetbrains.rd", "rd-framework")
exclude("org.jetbrains.teamcity", "serviceMessages")
exclude("io.ktor", "ktor-network-jvm")
exclude("com.jetbrains.infra", "download-pgp-verifier")
exclude("ai.grazie.utils", "utils-common-jvm")
exclude("ai.grazie.model", "model-common-jvm")
exclude("ai.grazie.model", "model-gec-jvm")
exclude("ai.grazie.model", "model-text-jvm")
exclude("ai.grazie.nlp", "nlp-common-jvm")
exclude("ai.grazie.nlp", "nlp-detect-jvm")
exclude("ai.grazie.nlp", "nlp-langs-jvm")
exclude("ai.grazie.nlp", "nlp-patterns-jvm")
exclude("ai.grazie.nlp", "nlp-phonetics-jvm")
exclude("ai.grazie.nlp", "nlp-similarity-jvm")
exclude("ai.grazie.nlp", "nlp-stemmer-jvm")
exclude("ai.grazie.nlp", "nlp-tokenizer-jvm")
exclude("ai.grazie.spell", "hunspell-en-jvm")
exclude("ai.grazie.spell", "gec-spell-engine-local-jvm")
exclude("ai.grazie.utils", "utils-lucene-lt-compatibility-jvm")
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
intellijPlatform {
create(properties("platformType"), properties("platformVersion"))

// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
bundledPlugins(properties("platformBundledPlugins").map { it.split(',') })

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
plugins(properties("platformPlugins").map { it.split(',') })

instrumentationTools()
pluginVerifier()

testFramework(TestFrameworkType.Plugin.Go)
}

testImplementation(kotlin("test"))

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.21.0")
implementation("org.codehaus.plexus:plexus-utils:3.5.1")
}

// Configure gradle-intellij-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(pluginName_)
version.set(platformVersion)
type.set(platformType)
downloadSources.set(platformDownloadSources.toBoolean())
updateSinceUntilBuild.set(true)

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(platformPlugins.split(',').map(String::trim).filter(String::isNotEmpty))
intellijPlatform {
pluginConfiguration {
name = properties("pluginName")
version = properties("platformVersion")

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

with(it.lines()) {
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)
}
}

val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes = properties("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
}

ideaVersion {
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}
}

publishing {
token.set(environment("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 = properties("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
}

verifyPlugin {
ides {
recommended()
}
}
}

// Configure detekt plugin.
Expand All @@ -96,17 +132,15 @@ detekt {
buildUponDefaultConfig = true
}

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
repositoryUrl = properties("pluginRepositoryUrl")
}

tasks {
// Set the compatibility versions to 17
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = listOf("-Xjvm-default=all-compatibility")
}
wrapper {
gradleVersion = properties("gradleVersion").get()
}

withType<Detekt> {
Expand All @@ -118,55 +152,7 @@ tasks {
}
}

withType<Test> {
systemProperty("idea.home.path", "${layout.buildDirectory.get()}/idea-sandbox/")
}

patchPluginXml {
version.set(pluginVersion)
sinceBuild.set(pluginSinceBuild)
untilBuild.set(pluginUntilBuild)

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

with(it.lines()) {
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)
}
}
)

// Get the latest available change notes from the changelog file
val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes.set(
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML
)
}
)
}

runPluginVerifier {
ideVersions.set(pluginVerifierIdeVersions.split(',').map { it.trim() })
}

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(pluginVersion.split('-').getOrElse(1) { "default" }.split('.').first()))
dependsOn(patchChangelog)
}
}
16 changes: 13 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html

pluginGroup = org.jetbrains.tinygoplugin
pluginName_ = tinygo-plugin
pluginName = tinygo-plugin
pluginRepositoryUrl = https://github.com/JetBrains/tinygo-plugin
pluginVersion = 0.5.13
pluginSinceBuild = 241.14494.238
pluginUntilBuild = 241.*
Expand All @@ -14,9 +15,18 @@ platformType = GO
platformVersion = 2024.1
platformDownloadSources = true
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = org.jetbrains.plugins.go, org.intellij.intelliLang
# Example: platformPlugins = com.jetbrains.php:203.4449.22
platformPlugins = org.jetbrains.plugins.go:241.14494.240
# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins = org.intellij.intelliLang

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.5

# Opt-out flag for bundling Kotlin standard library.
# See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details.
kotlin.stdlib.default.dependency = false
# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
org.gradle.configuration-cache = true
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching = true

0 comments on commit 5fd0df3

Please sign in to comment.