Skip to content

Commit

Permalink
Merge pull request #58 from coyotesqrl/ij-2024.2-redo
Browse files Browse the repository at this point in the history
Upgrades plugin for IJ 2024.2
  • Loading branch information
brcosta authored Aug 20, 2024
2 parents 39219ea + a850995 commit 736e749
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.idea
.qodana
build
/.intellijPlatform/
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

## 0.8.0
- Update Built-in clj-kondo -> v2024.08.01
- Upgrade plugin for IJ 2024.2
- Locks plugin to IJ 2024.2 and matching Cursive release; this version will not work with any prior versions of IJ/Cursive
- Upgrades plugin build system

## 0.7.13
- Update Built-in clj-kondo -> v2024.08.01
- Upgrade plugin for IJ 2024.2
Expand Down
90 changes: 58 additions & 32 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

fun properties(key: String) = project.findProperty(key).toString()

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.6.0"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.15.0"
id("org.jetbrains.kotlin.jvm") version "2.0.10"
// IntelliJ Platform Gradle Plugin
id("org.jetbrains.intellij.platform") version "2.0.1"

// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "1.3.1"
}
Expand All @@ -20,6 +23,9 @@ version = properties("pluginVersion")
// Configure project's dependencies
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
maven {
url = uri("https://clojars.org/repo")
}
Expand All @@ -30,21 +36,58 @@ repositories {
}

dependencies {
implementation("clj-kondo:clj-kondo:2024.08.01") {
implementation(providers.gradleProperty("kondoVersion")) {
exclude("org.clojure", "clojure")
}
intellijPlatform {
create(properties("platformType"), properties("platformVersion"))
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
instrumentationTools()
}
}

// Useful to override another IC platforms from env
val platformVersion = System.getenv("PLATFORM_VERSION") ?: properties("platformVersion")
val platformPlugins = System.getenv("PLATFORM_PLUGINS") ?: properties("platformPlugins")

// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(properties("pluginName"))
version.set(platformVersion)
type.set(properties("platformType"))
plugins.set(platformPlugins.split(',').map(String::trim).filter(String::isNotEmpty))
// Configure UI tests plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-tasks.html#runIdeForUiTests
val runIdeForUiTests by intellijPlatformTesting.runIde.registering {
task {
jvmArgumentProviders += CommandLineArgumentProvider {
listOf(
"-Drobot-server.port=8082",
"-Dide.mac.message.dialogs.as.sheets=false",
"-Djb.privacy.policy.text=<!--999.999-->",
"-Djb.consents.confirmation.enabled=false",
)
}
}
plugins {
robotServerPlugin()
}
}

intellijPlatform {
pluginConfiguration {
name = properties("pluginName")
}

pluginVerification {
// To run the verifier, install the latest version from https://github.com/JetBrains/intellij-plugin-verifier
// locally, and point cliPath to it
// cliPath = file("")
freeArgs = listOf("-mute", "TemplateWordInPluginName")
ides {
recommended()
select {
types = listOf(IntelliJPlatformType.IntellijIdeaCommunity, IntelliJPlatformType.IntellijIdeaUltimate)
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = providers.gradleProperty("pluginUntilBuild")
}
}
}
}

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
Expand All @@ -53,11 +96,10 @@ changelog {
groups.set(emptyList())
}

tasks.withType(KotlinCompile::class).all {
kotlinOptions {
jvmTarget = "11"
// For creation of default methods in interfaces
tasks.withType<KotlinJvmCompile> {
compilerOptions {
freeCompilerArgs = listOf("-Xjvm-default=all")
jvmTarget = JvmTarget.JVM_21
}
}

Expand All @@ -68,17 +110,14 @@ tasks {
sourceCompatibility = it
targetCompatibility = it
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = it
}
}

wrapper {
gradleVersion = properties("gradleVersion")
}

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

Expand All @@ -103,19 +142,6 @@ tasks {
})
}

runPluginVerifier {
ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty))
}

// 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")
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
Expand Down
22 changes: 14 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,38 @@

pluginGroup = com.github.brcosta.cljstuffplugin
pluginName = clj-extras-plugin
pluginVersion = 0.7.13
pluginVersion = 0.8.0

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 203
pluginSinceBuild = 242
pluginUntilBuild = 242.*

# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions.
pluginVerifierIdeVersions = 2020.3.4, 2021.1.3, 2021.2.4, 2021.3.3, 2022.1, 2022.2, 2022.3, 2023.1, 2023.2, 2023.3, 2024.1, 2024.2
pluginVerifierIdeVersions = 2024.2

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
platformType = IC
platformVersion = 2020.3.4
platformVersion = 2024.2

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.cursiveclojure.cursive:1.12.2-2020.3, com.intellij.java
platformPlugins = com.cursiveclojure.cursive:1.13.5-2024.2
# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins = com.intellij.java

# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
javaVersion = 11
# Java language level used to compile sources and to generate the files for - Java 17 is required
# for the upgraded IntelliJ Platform Gradle Plugin
javaVersion = 21

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

# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency = false

# clj-kondo embedded version
kondoVersion = clj-kondo:clj-kondo:2024.08.01
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import com.intellij.util.ConcurrencyUtil
import com.intellij.util.ui.JBUI
import cursive.file.ClojureFileType
import cursive.psi.ClojurePsiElement
import cursive.repl.StyledOutputBuffer
import cursive.repl.`print$ansi_output`
import cursive.repl.StyledPrinter
import cursive.repl.ansiOutput
import cursive.repl.actions.ReplAction
import java.awt.Component
import java.awt.Dimension
Expand Down Expand Up @@ -85,7 +85,7 @@ open class EvaluateInlineBaseAction(private val formFn: IFn) : AnAction() {
val prettyPrint = settings.prettyPrint
val redirectStdout = settings.redirectStdoutToRepl

val stateAtom = ReplAction.replState(editor.project)?.deref() as ILookup? ?: return "(x) Repl is not connected"
val stateAtom = editor.project?.let { ReplAction.replState(it)?.deref() } as ILookup? ?: return "(x) Repl is not connected"

val replState = (stateAtom.valAt(Keyword.intern("repl-state")) as Atom?)?.deref() as ILookup?
val host = replState?.valAt(Keyword.intern("host")) as String?
Expand Down Expand Up @@ -168,14 +168,10 @@ open class EvaluateInlineBaseAction(private val formFn: IFn) : AnAction() {
result: Map<String, Any?>,
) {
try {
`print$ansi_output`.invokeStatic(
ReplAction.replState(editor.project),
result["out"],
Clojure.read(":output-attributes")
)
ansiOutput(ReplAction.replState(editor.project!!)!!, result["out"] as String)
} catch (e: Exception) {
val outputBuffer =
(stateAtom.valAt(Keyword.intern("output-buffer"))) as StyledOutputBuffer
(stateAtom.valAt(Keyword.intern("output-buffer"))) as StyledPrinter
outputBuffer.print(result["out"] as String, null)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ open class OpenReplBufferAction : AnAction() {
if (event.project != null) {

val project = event.project!!
val stateAtom = ReplAction.replState(event.project)?.deref() as ILookup?
val stateAtom = ReplAction.replState(event.project!!)?.deref() as ILookup?

val outputBuffer = (stateAtom?.valAt(Keyword.intern("console"))) as ClojureConsole?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.UserDataHolderBase
import com.intellij.openapi.vfs.VirtualFile
import cursive.repl.ClojureConsole
import cursive.repl.StyledOutputBuffer
import cursive.repl.StyledPrinter
import cursive.repl.actions.ReplAction
import java.beans.PropertyChangeListener
import java.util.concurrent.Executors
Expand Down Expand Up @@ -56,7 +56,7 @@ class ReplFileEditorProvider : FileEditorProvider, DumbAware {
val stateAtom = ReplAction.replState(proj)?.deref() as ILookup?

val buffer =
(stateAtom?.valAt(Keyword.intern("output-buffer"))) as StyledOutputBuffer
(stateAtom?.valAt(Keyword.intern("output-buffer"))) as StyledPrinter

val factory = EditorFactory.getInstance()
edit = factory.createViewer(
Expand Down Expand Up @@ -91,7 +91,7 @@ class ReplFileEditorProvider : FileEditorProvider, DumbAware {

}

private fun updateHighlighters(buffer: StyledOutputBuffer, delayMs: Long) {
private fun updateHighlighters(buffer: StyledPrinter, delayMs: Long) {
Executors.newCachedThreadPool().submit {
ApplicationManager.getApplication().invokeLater {
Thread.sleep(delayMs)
Expand All @@ -112,7 +112,7 @@ class ReplFileEditorProvider : FileEditorProvider, DumbAware {
}

override fun getFile(): VirtualFile? {
val stateAtom = ReplAction.replState(proj)?.deref() as ILookup?
val stateAtom = proj?.let { ReplAction.replState(it)?.deref() } as ILookup?
return ((stateAtom?.valAt(Keyword.intern("console"))) as ClojureConsole?)?.clojureVirtualFile
}

Expand All @@ -121,7 +121,7 @@ class ReplFileEditorProvider : FileEditorProvider, DumbAware {
edit = null
}

private fun StyledOutputBuffer.getEditor(): EditorEx {
private fun StyledPrinter.getEditor(): EditorEx {
return javaClass.getDeclaredField("destination").let {
it.isAccessible = true
return@let it.get(this) as EditorEx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.intellij.openapi.options.colors.ColorDescriptor
import com.intellij.openapi.options.colors.ColorSettingsPage
import cursive.ClojureIcons
import cursive.highlighter.ClojureSyntaxHighlighter
import org.jetbrains.annotations.NonNls
import javax.swing.Icon

@Suppress("unused")
Expand All @@ -18,7 +17,7 @@ class ClojureColorsAndFontsPageEx : ColorSettingsPage {
}

override fun getIcon(): Icon? {
return ClojureIcons.CLOJURE
return ClojureIcons.Clojure
}

override fun getAttributeDescriptors(): Array<AttributesDescriptor> {
Expand All @@ -33,7 +32,7 @@ class ClojureColorsAndFontsPageEx : ColorSettingsPage {
return ClojureSyntaxHighlighter()
}

override fun getDemoText(): @NonNls String {
override fun getDemoText(): String {
return "; No preview available"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.intellij.openapi.project.ProjectManagerListener


class ProjectListener : ProjectManagerListener {
@Deprecated("Deprecated in Java")
override fun projectOpened(project: Project) {
LOG.debug("Project Opened ${project.name}")

Expand Down

0 comments on commit 736e749

Please sign in to comment.