Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Fix IDE info querying in gradle run tasks on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ARTI1208 committed Mar 23, 2022
1 parent d6b7158 commit 36fa067
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 43 deletions.
39 changes: 0 additions & 39 deletions buildSrc/src/main/kotlin/IdeVersion.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import com.intellij.openapi.util.BuildNumber
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import org.gradle.internal.os.OperatingSystem
import java.io.File

/*
* Copyright (c) 2019-2022, JetBrains s.r.o. and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Expand All @@ -22,11 +30,18 @@
* if you need additional information or have any questions.
*/

import kotlinx.serialization.json.*
import java.io.File
public fun isIdeVersionAtLeast(idePath: String, minVersion: String): Boolean {
val productInfo = getProductInfoFile(idePath)
if (!productInfo.exists()) return false
val jsonRoot = Json.parseToJsonElement(productInfo.readText()) as JsonObject
val versionString = jsonRoot["buildNumber"] as JsonPrimitive
val ideBuildNumber = BuildNumber.fromString(versionString.content)!!
val requiredBuildNumber = BuildNumber.fromString(minVersion)!!
return ideBuildNumber >= requiredBuildNumber
}

public fun getIdePrefix(idePath: String): String? {
val productInfo = File("$idePath/product-info.json")
val productInfo = getProductInfoFile(idePath)
if (!productInfo.exists()) return null
val jsonRoot = Json.parseToJsonElement(productInfo.readText()) as JsonObject
val launchConfigs = jsonRoot["launch"] as JsonArray
Expand All @@ -44,3 +59,8 @@ public fun getIdePrefix(idePath: String): String? {

return null
}

private fun getProductInfoFile(idePath: String): File = when {
OperatingSystem.current().isMacOsX -> File("$idePath/MacOS/product-info.json")
else -> File("$idePath/product-info.json")
}
6 changes: 5 additions & 1 deletion local.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
projectorLauncher.targetClassPath=/home/<USERNAME>/IdeaProjects/projector-demo/build/libs/projector-demo-original-1.0-SNAPSHOT.jar
projectorLauncher.classToLaunch=org.jetbrains.projector.demo.OriginalMain

# The :projector-server:runIdeaServer task requires the following single declaration. Don't forget to fix path:
# The :projector-server:runIdeaServer task requires the following single declaration. Don't forget to fix path.
# Linux example
projectorLauncher.ideaPath=/home/<USERNAME>/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-2/193.6494.35

# macOs example:
#projectorLauncher.ideaPath=/Users/<USERNAME>/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.6777.52/IntelliJ IDEA.app/Contents

# If you want to use local projector-client:projector-common module, define the following property:
useLocalProjectorClient=true

Expand Down

0 comments on commit 36fa067

Please sign in to comment.