Skip to content

Commit

Permalink
Merge pull request #3688 from Hannah-Sten/update-intellij-platform
Browse files Browse the repository at this point in the history
Update intellij platform plugin to 2.0
  • Loading branch information
PHPirates authored Oct 14, 2024
2 parents 76236aa + 1d99b9c commit 18a9242
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 80 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ jflex-*.jar
scripts/venv
results/
gen/
**/node_modules
**/node_modules
.intellijPlatform
2 changes: 1 addition & 1 deletion Writerside/topics/Contributing-to-the-source-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ If you get the error `Caused by: org.gradle.process.internal.ExecException: Proc

### The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3)

Please make sure you’re using at least JDK 17, both as project SDK and in <ui-path>Settings | Build, Execution, Deployment | Build Tools | Gradle | Gradle JVM</ui-path>.
Please make sure you’re using at least JDK 21, both as project SDK and in <ui-path>Settings | Build, Execution, Deployment | Build Tools | Gradle | Gradle JVM</ui-path>.

### `Gtk-WARNING **: Unable to locate theme engine in module_path: "murrine"`

Expand Down
143 changes: 66 additions & 77 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.changelog.Changelog
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.intellij.platform.gradle.TestFrameworkType

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

// Include the Gradle plugins which help building everything.
// Supersedes the use of "buildscript" block and "apply plugin:"
plugins {
id("org.jetbrains.intellij") version "1.17.4"
id("org.jetbrains.intellij.platform") version "2.1.0"
kotlin("jvm") version ("1.9.20")
kotlin("plugin.serialization") version ("1.9.20")

// Plugin which can check for Gradle dependencies, use the help/dependencyUpdates task.
id("com.github.ben-manes.versions") version "0.51.0"
Expand Down Expand Up @@ -42,6 +42,9 @@ version = properties("pluginVersion")

repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}

sourceSets {
Expand Down Expand Up @@ -84,6 +87,29 @@ configurations {
}

dependencies {
intellijPlatform {
instrumentationTools()
zipSigner()
pluginVerifier()
testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.Plugin.Java)

// Comment out to use the latest EAP snapshot
// Docs: https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
// All snapshot versions: https://www.jetbrains.com/intellij-repository/snapshots/
intellijIdeaCommunity("2024.1")
// Example to use a different, locally installed, IDE
// If you get the error "Cannot find builtin plugin java for IDE", remove the "java" plugin above
// Also disable "version" above
// If it doesn't work (Could not resolve all files for configuration ':detachedConfiguration4'.), specify 'version' instead
// localPath.set("/home/thomas/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/213.6777.50/")

bundledPlugin("com.intellij.java")
bundledPlugin("tanvd.grazi")
plugin("com.firsttimeinforever.intellij.pdf.viewer.intellij-pdf-viewer:0.16.1")
plugin("com.jetbrains.hackathon.indices.viewer:1.27")
}

// Local dependencies
implementation(files("lib/pretty-tools-JDDE-2.1.0.jar"))
// These lines can sometimes be problematic on Linux, but are required for SumatraPDF
Expand Down Expand Up @@ -159,16 +185,6 @@ tasks.processResources {
}
}

// https://plugins.jetbrains.com/docs/intellij/dynamic-plugins.html#diagnosing-leaks
tasks.runIde {
jvmArgs = mutableListOf("-XX:+UnlockDiagnosticVMOptions", "-Xmx2g", "-Djava.system.class.loader=com.intellij.util.lang.PathClassLoader")

// Set to true to generate hprof files on unload fails
systemProperty("ide.plugins.snapshot.on.unload.fail", "false")
// Some warning asked for this to be set explicitly
systemProperty("idea.log.path", file("build/idea-sandbox/system/log").absolutePath)
}

// Avoid ClassNotFoundException: com.maddyhome.idea.copyright.psi.UpdateCopyrightsProvider
tasks.buildSearchableOptions {
jvmArgs = listOf("-Djava.system.class.loader=com.intellij.util.lang.PathClassLoader")
Expand All @@ -181,69 +197,43 @@ changelog {
itemPrefix.set("*")
}

tasks.patchPluginXml {
dependsOn("patchChangelog")

// Required to run pluginVerifier
sinceBuild.set(properties("pluginSinceBuild"))

// Get the latest available change notes from the changelog file
changeNotes.set(
provider {
with(changelog) {
renderItem(
getOrNull(properties("pluginVersion")) ?: getLatest(),
Changelog.OutputType.HTML
)
intellijPlatform {
pluginConfiguration {
name = "TeXiFy-IDEA"
// Get the latest available change notes from the changelog file
changeNotes = (
provider {
with(changelog) {
renderItem(
getOrNull(properties("pluginVersion")) ?: getLatest(),
Changelog.OutputType.HTML
)
}
}
}
)
}
)
}

intellij {
pluginName.set("TeXiFy-IDEA")

// indices plugin doesn't work in tests
plugins.set(
listOf(
"tanvd.grazi",
"java",
"com.firsttimeinforever.intellij.pdf.viewer.intellij-pdf-viewer:0.16.1",
"com.jetbrains.hackathon.indices.viewer:1.27"
)
)

// Use the since build number from plugin.xml
updateSinceUntilBuild.set(false)
// Keep an open until build, to avoid automatic downgrades to very old versions of the plugin
sameSinceUntilBuild.set(true)

// Comment out to use the latest EAP snapshot
// Docs: https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
// All snapshot versions: https://www.jetbrains.com/intellij-repository/snapshots/
version.set("2024.1")
// type = "PY"

// Example to use a different, locally installed, IDE
// If you get the error "Cannot find builtin plugin java for IDE", remove the "java" plugin above
// Also disable "version" above
// If it doesn't work (Could not resolve all files for configuration ':detachedConfiguration4'.), specify 'version' instead
// localPath.set("/home/thomas/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/213.6777.50/")
}
publishing {
// Allow publishing to the Jetbrains repo via a Gradle task
// This requires to put a Jetbrains Hub token, see http://www.jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html for more details
// Generate a Hub token at https://hub.jetbrains.com/users/me?tab=authentification
// You should provide it either via environment variables (ORG_GRADLE_PROJECT_intellijPublishToken) or Gradle task parameters (-Dorg.gradle.project.intellijPublishToken=mytoken)
token.set(properties["intellijPublishToken"].toString())

// Allow publishing to the Jetbrains repo via a Gradle task
// This requires to put a Jetbrains Hub token, see http://www.jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html for more details
// Generate a Hub token at https://hub.jetbrains.com/users/me?tab=authentification
// You should provide it either via environment variables (ORG_GRADLE_PROJECT_intellijPublishToken) or Gradle task parameters (-Dorg.gradle.project.intellijPublishToken=mytoken)
tasks.publishPlugin {
dependsOn("useLatestVersions")
// dependsOn("dependencyCheckAnalyze")
// Specify channel as per the tutorial.
// More documentation: https://github.com/JetBrains/gradle-intellij-plugin/blob/master/README.md#publishing-dsl
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "stable" }.split('.').first()))
}
}

token.set(properties["intellijPublishToken"].toString())
// https://plugins.jetbrains.com/docs/intellij/dynamic-plugins.html#diagnosing-leaks
tasks.runIde {
jvmArgs = mutableListOf("-XX:+UnlockDiagnosticVMOptions", "-Xmx2g", "-Djava.system.class.loader=com.intellij.util.lang.PathClassLoader")

// Specify channel as per the tutorial.
// More documentation: https://github.com/JetBrains/gradle-intellij-plugin/blob/master/README.md#publishing-dsl
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "stable" }.split('.').first()))
// Set to true to generate hprof files on unload fails
systemProperty("ide.plugins.snapshot.on.unload.fail", "false")
// Some warning asked for this to be set explicitly
systemProperty("idea.log.path", file("build/idea-sandbox/system/log").absolutePath)
}

tasks.test {
Expand Down Expand Up @@ -293,11 +283,6 @@ tasks.useLatestVersions {

tasks {

// https://github.com/JetBrains/gradle-grammar-kit-plugin/issues/168
withType<GenerateParserTask> {
classpath(setupDependencies.flatMap { it.idea.map { idea -> idea.classes.resolve("lib/opentelemetry.jar") } })
}

val generateLatexParserTask = register<GenerateParserTask>("generateLatexParser") {
sourceFile.set(File("src/nl/hannahsten/texifyidea/grammar/Latex.bnf"))
targetRootOutputDir.set(File("gen"))
Expand All @@ -322,14 +307,18 @@ tasks {
targetOutputDir.set(File("gen/nl/hannahsten/texifyidea/grammar/"))
}

initializeIntelliJPlugin {
initializeIntellijPlatformPlugin {
dependsOn(generateLatexParserTask)
dependsOn(generateBibtexParserTask)
dependsOn(generateLatexLexerTask)
dependsOn(generateBibtexLexerTask)
}

runKtlintCheckOverMainSourceSet {
dependsOn(initializeIntelliJPlugin)
dependsOn(initializeIntellijPlatformPlugin)
}

compileKotlin {
dependsOn(initializeIntellijPlatformPlugin)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LatexParserDefinition : ParserDefinition {
val FILE: IStubFileElementType<*> = object : IStubFileElementType<LatexFileStub>(
"LatexStubFileElementType", Language.findInstance(LatexLanguage::class.java)
) {
override fun getStubVersion(): Int = 73
override fun getStubVersion(): Int = 74
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nl.hannahsten.texifyidea.index.stub

import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.stubs.*
import com.intellij.testFramework.LightVirtualFile
import nl.hannahsten.texifyidea.grammar.LatexLanguage
Expand All @@ -23,6 +24,20 @@ class LatexCommandsStubElementType(debugName: String) :

override fun createPsi(latexCommandsStub: LatexCommandsStub): LatexCommands {
return object : LatexCommandsImpl(latexCommandsStub, this) {

override fun getElementType(): IStubElementType<*, *> {
return this@LatexCommandsStubElementType
}

override fun getStub(): LatexCommandsStub {
return latexCommandsStub
}

override fun setName(name: String): PsiElement {
this.name = name
return this
}

init {
this.name = latexCommandsStub.name!!
}
Expand Down

0 comments on commit 18a9242

Please sign in to comment.