Skip to content

Commit

Permalink
migrated to K2, intellij platform v2.*.*, fixed bugs with gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil.Karol committed Jan 2, 2025
1 parent 73ae87c commit 845da13
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 49 deletions.
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
id(libs.plugins.kotlin.jvm.get().pluginId) version libs.versions.kotlin.get()
alias(libs.plugins.buildconfig) apply false
alias(libs.plugins.detekt)
alias(libs.plugins.serialization)
alias(libs.plugins.serialization) apply false
alias(libs.plugins.changelog)
}

Expand All @@ -32,6 +32,7 @@ allprojects {
implementation(rootProject.libs.csv)
detektPlugins(rootProject.libs.detekt.formatting)
implementation(rootProject.libs.joda)
implementation(rootProject.libs.kotlin.serialization)
testImplementation(kotlin("test"))
}

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ pluginVersion = 0.1.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 223
pluginUntilBuild = 242
pluginUntilBuild = 243.*

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IC
platformVersion = 2022.3.3
platformVersion = 2024.3

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins =

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

# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
# suppress inspection "UnusedProperty"
Expand Down
17 changes: 10 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
kotlin = "1.8.10"
intellij = "1.16.1"
detekt = "1.22.0"
kotlin = "2.1.0"
intellij = "2.1.0"
detekt = "1.23.7"
buildconfig = "3.1.0"
jdk17 = "17"
jdk21 = "21"
jdk11 = "11"
kaml = "0.52.0"
serialization = "1.8.10"
serialization = "1.7.3"
snakeyaml = "2.0"
csv = "1.10.0"
joda = "2.12.4"
Expand All @@ -20,6 +20,7 @@ postgres = "42.3.1"
logback = "1.4.11"
exposed = "0.44.0"
h2 = "2.2.224"
opentest4j="1.3.0"

[libraries]
detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
Expand All @@ -39,6 +40,8 @@ ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx
ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" }
ktor-server-netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" }
ktor-server-tests = { module = "io.ktor:ktor-server-tests-jvm", version.ref = "ktor" }
opentest4j = { module = "org.opentest4j:opentest4j", version.ref = "opentest4j" }
kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }

slf4j = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
postgres = { module = "org.postgresql:postgresql", version.ref = "postgres" }
Expand All @@ -51,10 +54,10 @@ h2 = { module = "com.h2database:h2", version.ref = "h2" }


[plugins]
intellij = { id = "org.jetbrains.intellij", version.ref = "intellij" }
intellij = { id = "org.jetbrains.intellij.platform", version.ref = "intellij" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "serialization" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
54 changes: 41 additions & 13 deletions ij-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.incremental.createDirectory
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

group = rootProject.group
version = rootProject.version
Expand All @@ -12,9 +13,36 @@ plugins {
alias(libs.plugins.intellij)
}

val jdkVersion = libs.versions.jdk17.get()
repositories {
intellijPlatform {
defaultRepositories()
}
}

intellijPlatform {
buildSearchableOptions = false
projectName = project.name
pluginConfiguration {
id = project.name
name = properties("pluginName")
version = properties("pluginVersion")
ideaVersion {
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}
}
}

val jdkVersion = libs.versions.jdk21.get()

dependencies {
intellijPlatform {
create(properties("platformType"), properties("platformVersion"))
instrumentationTools()
testFramework(TestFrameworkType.Platform)
plugins(properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) })
}

implementation(rootProject.libs.kaml)
implementation(rootProject.libs.snakeyaml)
implementation(rootProject.libs.kinference)
Expand All @@ -27,17 +55,20 @@ dependencies {
implementation(rootProject.libs.ktor.serialization.kotlinx.json)
implementation(rootProject.libs.slf4j)
implementation(rootProject.libs.opencv)
// Due to the IJPL-157292 issue
testImplementation(rootProject.libs.opentest4j)
}

intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
plugins.set(properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) })

configurations {
all {
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core")
}
}

val defaultPropertiesDirectory = project.file("src/main/resources/properties/default")
val actualPropertiesDirectory = project.file("src/main/resources/properties/actual").also { if (!it.exists()) it.createDirectory() }
val actualPropertiesDirectory =
project.file("src/main/resources/properties/actual").also { if (!it.exists()) it.mkdirs() }

tasks {
val checkPropertiesExist = register("checkPropertiesExist") {
Expand All @@ -58,9 +89,6 @@ tasks {
}
}

withType<org.jetbrains.intellij.tasks.BuildSearchableOptionsTask>()
.forEach { it.enabled = false }

patchPluginXml {
val description = """
TaskTracker-3 - a revolutionary plugin for collecting detailed data during education.
Expand All @@ -77,10 +105,10 @@ tasks {

withType<JavaCompile> {
sourceCompatibility = jdkVersion
targetCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_21.toString()
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
}

withType<Detekt>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class InspectionHandler(override val config: InspectionConfig, override val proj
}
}

private fun initTaskProfile(project: Project): InspectionProfileImpl {
fun initTaskProfile(project: Project): InspectionProfileImpl {
val inspectionProfileManager = ProjectInspectionProfileManager.getInstance(project)
val inspectionProfile = InspectionProfileImpl(
PROFILE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object TaskFileHandler {
}

private fun addVirtualFileListener(project: Project, virtualFile: VirtualFile) {
ApplicationManager.getApplication().invokeAndWait {
ApplicationManager.getApplication().runWriteAction {
val document = FileDocumentManager.getInstance().getDocument(virtualFile)
document?.let {
it.addDocumentListener(getListener())
Expand All @@ -87,7 +87,7 @@ object TaskFileHandler {

private fun removeVirtualFileListener(project: Project, virtualFiles: List<VirtualFile>) {
virtualFiles.forEach { file ->
ApplicationManager.getApplication().invokeAndWait {
ApplicationManager.getApplication().runWriteAction {
val document = FileDocumentManager.getInstance().getDocument(file)
document?.let {
DocumentLogger.removeDocumentLogPrinter(project, document)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ class MainPluginWindow(service: MainWindowService) {

private fun getJsElementByIdCommand(elementId: String) = "document.getElementById('$elementId')"

fun getElementValue(elementId: String): Promise<JsExpressionResult> =
windowBrowser.executeJavaScriptAsync("${getJsElementByIdCommand(elementId)}.value")
fun getElementValue(elementId: String): Promise<String> =
windowBrowser.executeJavaScriptAsync("${getJsElementByIdCommand(elementId)}.value") as Promise<String>

fun checkIfRadioButtonChecked(elementId: String): Promise<JsExpressionResult> =
windowBrowser.executeJavaScriptAsync("${getJsElementByIdCommand(elementId)}.checked")
fun checkIfRadioButtonChecked(elementId: String): Promise<String> =
windowBrowser.executeJavaScriptAsync("${getJsElementByIdCommand(elementId)}.checked") as Promise<String>

fun executeJavaScriptAsync(@Language("JavaScript") code: String) = windowBrowser.executeJavaScriptAsync(code)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jetbrains.research.tasktracker.ui.main.panel.panelStates

import com.intellij.openapi.application.ApplicationManager
import com.intellij.util.alsoIfNull
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -32,12 +31,14 @@ fun Panel.agreementAcceptance() {
checkAgreementInputs().runOnSuccess {
if (!it) {
GlobalPluginStorage.agreementChecker?.let { agreement ->
GlobalPluginStorage.userId = IdRequests.getUserId(agreement.name, agreement.email).alsoIfNull {
notifyError(
project,
UIBundle.message("ui.connection.lose")
)
return@runOnSuccess
GlobalPluginStorage.userId = IdRequests.getUserId(agreement.name, agreement.email).also {
if (it == null) {
notifyError(
project,
UIBundle.message("ui.connection.lose")
)
return@runOnSuccess
}
}
}
GlobalPluginStorage.currentResearchId = IdRequests.getResearchId()
Expand Down Expand Up @@ -69,7 +70,7 @@ private fun Panel.selectTask(taskIds: List<String>, allRequired: Boolean = true)
loadBasePage(TasksPageTemplate(tasks), isVisiblePauseButton = false)
setNextAction {
mainWindow.getElementValue("tasks").runOnSuccess { name ->
solveTask(name.toString(), if (allRequired) taskIds.filter { it != name } else emptyList())
solveTask(name, if (allRequired) taskIds.filter { it != name } else emptyList())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class InspectionConfigTest : LightPlatformTestCase() {
fun testAddSelectedInspections() {
val profile = getProfile("addSelected")
val enabledTools = profile.getAllEnabledToolIds()
println(profile.getAllDisabledToolIds())
assert(enabledTools.size == ADD_SELECTED_ENABLED_INSPECTION_SIZE) {
"add selected tools size is $ADD_SELECTED_ENABLED_INSPECTION_SIZE, but ${enabledTools.size} has been found"
}
Expand Down Expand Up @@ -124,9 +123,9 @@ class InspectionConfigTest : LightPlatformTestCase() {
}

companion object {
const val DEFAULT_ENABLED_INSPECTION_SIZE = 56
const val DISABLE_SELECTED_ENABLED_INSPECTION_SIZE = 54
const val ADD_SELECTED_ENABLED_INSPECTION_SIZE = 58
const val DEFAULT_ENABLED_INSPECTION_SIZE = 48
const val DISABLE_SELECTED_ENABLED_INSPECTION_SIZE = 46
const val ADD_SELECTED_ENABLED_INSPECTION_SIZE = 50
val enableSelectedTools = listOf("LongLine", "TodoComment")
val disableSelectedTools = listOf("CheckTagEmptyBody", "RegExpRedundantEscape")
val addSelectedTools = listOf("EmptyDirectory", "ProblematicWhitespace")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.jetbrains.research.tasktracker.config.MainTaskTrackerConfig.Companion
import org.jetbrains.research.tasktracker.config.content.task.base.Task
import org.jetbrains.research.tasktracker.config.content.task.base.TaskWithFiles
import org.jetbrains.research.tasktracker.tracking.mock.*
import kotlin.test.assertFailsWith

class TaskFileHandlerTest : CodeInsightFixtureTestCase<ModuleFixtureBuilder<*>>() {

Expand Down Expand Up @@ -37,7 +36,7 @@ class TaskFileHandlerTest : CodeInsightFixtureTestCase<ModuleFixtureBuilder<*>>(

fun testInitExistingTask() {
TaskFileHandler.initTask(project, task1)
assertFailsWith<Throwable>("Expected Throwable on second initialization of $task1") {
assertNoThrowable {
TaskFileHandler.initTask(project, task1)
}
}
Expand Down
3 changes: 2 additions & 1 deletion ij-server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

group = rootProject.group
version = rootProject.version
Expand Down Expand Up @@ -36,7 +37,7 @@ tasks{
targetCompatibility = JavaVersion.VERSION_11.toString()
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
}

withType<Detekt>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ suspend inline fun PipelineContext<Unit, ApplicationCall>.createLogFile(
val fileName = part.originalFileName as String
val fileBytes = part.streamProvider().readBytes()
file = file ?: getAndCreateFile(directoryPath, fileName)
file?.appendBytes(fileBytes)
file.appendBytes(fileBytes)
}
part.dispose()
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginManagement {
repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
gradlePluginPortal()
}
}
Expand Down

0 comments on commit 845da13

Please sign in to comment.