Skip to content

Commit

Permalink
chore: update IntelliJ platform and plugin versions
Browse files Browse the repository at this point in the history
- Update IntelliJ platform version to 2024.1 and plugin version to 1.17.2
- Add new plugin description file and include plugin module in settings
  • Loading branch information
phodal committed May 31, 2024
1 parent c00164a commit 8dea132
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# Build plugin
- name: Build plugin
run: ./gradlew buildPlugin
run: ./gradlew :plugin:buildPlugin

# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
Expand Down
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

243 changes: 166 additions & 77 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import groovy.xml.XmlParser
import org.gradle.api.JavaVersion.VERSION_17
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.tasks.PatchPluginXmlTask
import org.jetbrains.intellij.tasks.PublishPluginTask
import org.jetbrains.intellij.tasks.RunIdeTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun properties(key: String) = providers.gradleProperty(key)
Expand All @@ -16,6 +20,14 @@ plugins {
id("org.jetbrains.grammarkit") version "2022.3.2.2"
}

fun prop(name: String): String =
extra.properties[name] as? String
?: error("Property `$name` is not defined in gradle.properties")

val ideaPlatformVersion = prop("ideaVersion").toInt()
val pluginProjects: List<Project> get() = rootProject.allprojects.toList()
val basePluginArchiveName = "intellij-shire"

// Configure project's dependencies
repositories {
mavenCentral()
Expand All @@ -33,9 +45,11 @@ allprojects {
mavenCentral()
}

// Set the JVM language level used to build the project.
kotlin {
jvmToolchain(17)
intellij {
version = prop("platformVersion")
type = prop("platformType")
instrumentCode.set(false)
sandboxDir.set("${layout.projectDirectory}/build/idea-sandbox-$ideaPlatformVersion")
}

idea {
Expand All @@ -46,25 +60,27 @@ allprojects {
}
}

// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
kover {
reports {
total {
xml {
onCheck = true
}
}
configure<JavaPluginExtension> {
sourceCompatibility = VERSION_17
targetCompatibility = VERSION_17
}

tasks {
withType<PatchPluginXmlTask> {
sinceBuild.set(prop("pluginSinceBuild"))
untilBuild.set(prop("pluginUntilBuild"))
}

// All these tasks don't make sense for non-root subprojects
// Root project (i.e. `:plugin`) enables them itself if needed
runIde { enabled = false }
prepareSandbox { enabled = false }
buildSearchableOptions { enabled = false }
}

}

project(":core") {
intellij {
version = properties("platformVersion")
type = properties("platformType")
}

dependencies {
}
}
Expand All @@ -75,8 +91,7 @@ project(":language") {
}

intellij {
version = properties("platformVersion")
type = properties("platformType")
version = prop("platformVersion")
plugins.set((listOf<String>() + "org.intellij.plugins.markdown" + "com.jetbrains.sh" + "Git4Idea"))
}

Expand Down Expand Up @@ -104,97 +119,171 @@ project(":language") {
}
}

project(":") {
project(":plugin") {
apply {
plugin("org.jetbrains.changelog")
}

group = properties("pluginGroup").get()
version = properties("pluginVersion").get()
version = prop("pluginVersion") + "-" + prop("ideaVersion")

// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
pluginName = properties("pluginName")
version = properties("platformVersion")
type = properties("platformType")

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }
}

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

dependencies {
implementation(project(":"))
implementation(project(":core"))
implementation(project(":language"))
}

// Collects all jars produced by compilation of project modules and merges them into singe one.
// We need to put all plugin manifest files into single jar to make new plugin model work
val mergePluginJarTask = task<Jar>("mergePluginJars") {
duplicatesStrategy = DuplicatesStrategy.FAIL
archiveBaseName.set(basePluginArchiveName)

exclude("META-INF/MANIFEST.MF")
exclude("**/classpath.index")

val pluginLibDir by lazy {
val sandboxTask = tasks.prepareSandbox.get()
sandboxTask.destinationDir.resolve("${sandboxTask.pluginName.get()}/lib")
}

val pluginJars by lazy {
pluginLibDir.listFiles().orEmpty().filter {
it.isPluginJar()
}
}

destinationDirectory.set(project.layout.dir(provider { pluginLibDir }))

doFirst {
for (file in pluginJars) {
from(zipTree(file))
}
}

doLast {
delete(pluginJars)
}
}

// Add plugin sources to the plugin ZIP.
// gradle-intellij-plugin will use it as a plugin sources if the plugin is used as a dependency
val createSourceJar = task<Jar>("createSourceJar") {
for (prj in pluginProjects) {
from(prj.kotlin.sourceSets.main.get().kotlin) {
include("**/*.java")
include("**/*.kt")
}
}

destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveBaseName.set(basePluginArchiveName)
archiveClassifier.set("src")
}

tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
buildPlugin {
dependsOn(createSourceJar)
from(createSourceJar) { into("lib/src") }
// Set proper name for final plugin zip.
// Otherwise, base name is the same as gradle module name
archiveBaseName.set(basePluginArchiveName)
}

patchPluginXml {
version = properties("pluginVersion")
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
runIde { enabled = true }

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

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)
}
buildSearchableOptions {
// Force `mergePluginJarTask` be executed before `buildSearchableOptions`
// Otherwise, `buildSearchableOptions` task can't load the plugin and searchable options are not built.
// Should be dropped when jar merging is implemented in `gradle-intellij-plugin` itself
dependsOn(mergePluginJarTask)
enabled = false
}

withType<RunIdeTask> {
// Default args for IDEA installation
jvmArgs("-Xmx768m", "-XX:+UseG1GC", "-XX:SoftRefLRUPolicyMSPerMB=50")
// Disable plugin auto reloading. See `com.intellij.ide.plugins.DynamicPluginVfsListener`
jvmArgs("-Didea.auto.reload.plugins=false")
// Don't show "Tip of the Day" at startup
jvmArgs("-Dide.show.tips.on.startup.default.value=false")
// uncomment if `unexpected exception ProcessCanceledException` prevents you from debugging a running IDE
// jvmArgs("-Didea.ProcessCanceledException=disabled")
}

withType<PatchPluginXmlTask> {
pluginDescription.set(provider { file("description.html").readText() })

changelog {
version.set(properties("pluginVersion"))
groups.empty()
path.set(rootProject.file("CHANGELOG.md").toString())
repositoryUrl.set(properties("pluginRepositoryUrl"))
}

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

Changelog.OutputType.HTML,
)
}
}
})
}

// Configure UI tests plugin
// Read more: https://github.com/JetBrains/intellij-ui-test-robot
runIdeForUiTests {
systemProperty("robot-server.port", "8082")
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
systemProperty("jb.consents.confirmation.enabled", "false")
withType<PublishPluginTask> {
dependsOn("patchChangelog")
token.set(environment("PUBLISH_TOKEN"))
channels.set(properties("pluginVersion").map {
listOf(it.split('-').getOrElse(1) { "default" }.split('.').first())
})
}
}
}

signPlugin {
certificateChain = environment("CERTIFICATE_CHAIN")
privateKey = environment("PRIVATE_KEY")
password = environment("PRIVATE_KEY_PASSWORD")
}
project(":") {
dependencies {
implementation(project(":core"))
implementation(project(":language"))
}

publishPlugin {
dependsOn("patchChangelog")
token = environment("PUBLISH_TOKEN")
// The 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" })
}
task("resolveDependencies") {
doLast {
rootProject.allprojects
.map { it.configurations }
.flatMap { it.filter { c -> c.isCanBeResolved } }
.forEach { it.resolve() }
}
}
}
}

fun File.isPluginJar(): Boolean {
if (!isFile) return false
if (extension != "jar") return false
return zipTree(this).files.any { it.isManifestFile() }
}

fun File.isManifestFile(): Boolean {
if (extension != "xml") return false
val rootNode = try {
val parser = XmlParser()
parser.parse(this)
} catch (e: Exception) {
logger.error("Failed to parse $path", e)
return false
}
return rootNode.name() == "idea-plugin"
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pluginUntilBuild = 242.*
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IU
platformVersion = 2024.1
ideaVersion=241

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
Expand Down
4 changes: 1 addition & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[versions]
# libraries
exampleLibrary = "24.1.0"

# plugins
kotlin = "2.0.0"
changelog = "2.2.0"
gradleIntelliJPlugin = "1.17.3"
gradleIntelliJPlugin = "1.17.2"
qodana = "2024.1.5"
kover = "0.8.0"

[libraries]
exampleLibrary = { group = "com.example", name = "exampleLibrary", version.ref = "exampleLibrary" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
Expand Down
1 change: 1 addition & 0 deletions plugin/description.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Shire - AI Agent Language for AI Driven programming
File renamed without changes.
File renamed without changes
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = "shire"
rootProject.name = "intellij-shire"

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
Expand All @@ -7,6 +7,7 @@ plugins {
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include(
"plugin",
"core",
"language",
)

0 comments on commit 8dea132

Please sign in to comment.