Skip to content

Commit 672af62

Browse files
authored
Adding support for 2024.3 (#24)
* Show paparazzi options only for Test module * Remove modules.asSequence * Adding support for 2024.3
1 parent b1e852a commit 672af62

File tree

7 files changed

+130
-37
lines changed

7 files changed

+130
-37
lines changed

build.gradle.kts

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,96 @@
1+
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
2+
13
plugins {
2-
id("java")
3-
id("org.jetbrains.kotlin.jvm") version "1.9.24" // https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
4-
id("org.jetbrains.intellij.platform") version "2.0.1" // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html
4+
id("java") // Java support
5+
alias(libs.plugins.kotlin) // Kotlin support
6+
alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin
57
}
68

7-
group = "com.getyourguide"
8-
version = "1.2.2024.2"
9+
group = providers.gradleProperty("pluginGroup").get()
10+
version = providers.gradleProperty("pluginVersion").get()
911

10-
val ideaVersion = "2024.2"
12+
// Set the JVM language level used to build the project.
13+
kotlin {
14+
jvmToolchain(21)
15+
}
1116

17+
// Configure project's dependencies
1218
repositories {
1319
mavenCentral()
1420

21+
// IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
1522
intellijPlatform {
1623
defaultRepositories()
1724
}
1825
}
1926

27+
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
2028
dependencies {
29+
testImplementation(libs.junit)
30+
31+
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
2132
intellijPlatform {
22-
intellijIdeaCommunity(ideaVersion)
23-
bundledPlugins("org.jetbrains.kotlin", "com.intellij.java", "com.intellij.gradle")
33+
intellijIdeaUltimate(providers.gradleProperty("platformVersion"))
34+
35+
// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
36+
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
37+
38+
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
39+
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })
2440

2541
pluginVerifier()
2642
zipSigner()
27-
instrumentationTools()
43+
testFramework(TestFrameworkType.Platform)
2844
}
45+
46+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
2947
}
3048

31-
tasks {
32-
runIde {
33-
jvmArgs("-Xmx1g")
34-
}
35-
// Set the JVM compatibility versions
36-
withType<JavaCompile> {
37-
sourceCompatibility = "11"
38-
targetCompatibility = "11"
49+
// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
50+
intellijPlatform {
51+
pluginConfiguration {
52+
version = providers.gradleProperty("pluginVersion")
53+
54+
ideaVersion {
55+
sinceBuild = providers.gradleProperty("pluginSinceBuild")
56+
untilBuild = providers.gradleProperty("pluginUntilBuild")
57+
}
3958
}
40-
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
41-
kotlinOptions.jvmTarget = "11"
59+
60+
pluginVerification {
61+
ides {
62+
recommended()
63+
}
4264
}
65+
}
4366

44-
patchPluginXml {
45-
sinceBuild.set("241")
46-
untilBuild.set("242.*")
67+
tasks {
68+
wrapper {
69+
gradleVersion = providers.gradleProperty("gradleVersion").get()
4770
}
4871

49-
signPlugin {
50-
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
51-
privateKey.set(System.getenv("PRIVATE_KEY"))
52-
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
72+
buildSearchableOptions {
73+
enabled = false
5374
}
75+
}
76+
77+
intellijPlatformTesting {
78+
runIde {
79+
register("runIdeForUiTests") {
80+
task {
81+
jvmArgumentProviders += CommandLineArgumentProvider {
82+
listOf(
83+
"-Drobot-server.port=8082",
84+
"-Dide.mac.message.dialogs.as.sheets=false",
85+
"-Djb.privacy.policy.text=<!--999.999-->",
86+
"-Djb.consents.confirmation.enabled=false",
87+
)
88+
}
89+
}
5490

55-
publishPlugin {
56-
token.set(System.getenv("PUBLISH_TOKEN"))
91+
plugins {
92+
robotServerPlugin()
93+
}
94+
}
5795
}
5896
}

gradle.properties

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
2+
3+
pluginGroup = com.getyourguide
4+
pluginName = Paparazzi
5+
pluginVersion = 1.2.2024.3
6+
7+
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
8+
pluginSinceBuild = 243
9+
pluginUntilBuild = 243.*
10+
11+
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
12+
platformVersion = 2024.3
13+
14+
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
15+
# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP
16+
platformPlugins =
17+
# Example: platformBundledPlugins = com.intellij.java
18+
platformBundledPlugins = org.jetbrains.kotlin,com.intellij.java,com.intellij.gradle
19+
20+
# Gradle Releases -> https://github.com/gradle/gradle/releases
21+
gradleVersion = 8.10.2
22+
23+
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
24+
kotlin.stdlib.default.dependency = false
25+
26+
# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
27+
org.gradle.configuration-cache = true
28+
29+
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
30+
org.gradle.caching = true

gradle/libs.versions.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[versions]
2+
# libraries
3+
junit = "4.13.2"
4+
5+
# plugins
6+
intelliJPlatform = "2.3.0"
7+
kotlin = "2.1.10"
8+
9+
[libraries]
10+
junit = { group = "junit", name = "junit", version.ref = "junit" }
11+
12+
[plugins]
13+
intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" }
14+
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

src/main/kotlin/com/getyourguide/paparazzi/Utils.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ internal fun VirtualFile.methods(project: Project): List<String> {
6363
}
6464

6565
internal fun Project.modulePath(file: VirtualFile): String? {
66-
return modules.asSequence().map { it.getModuleDir() }.firstOrNull { file.path.startsWith(it) }
67-
?: basePath?.let { projectPath ->
66+
return basePath?.let { projectPath ->
6867
val relativePath = FileUtil.getRelativePath(projectPath, file.path, File.separatorChar)
6968
val moduleName = relativePath?.split(File.separator)?.firstOrNull()
7069
if (moduleName != null) projectPath + File.separator + moduleName else null

src/main/kotlin/com/getyourguide/paparazzi/actions/group/GroupAction.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.getyourguide.paparazzi.actions.group
22

33
import com.getyourguide.paparazzi.isPaparazziClass
4+
import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode
45
import com.intellij.openapi.actionSystem.ActionUpdateThread
56
import com.intellij.openapi.actionSystem.AnAction
67
import com.intellij.openapi.actionSystem.AnActionEvent
78
import com.intellij.openapi.actionSystem.LangDataKeys
8-
import com.intellij.openapi.module.ModuleUtilCore
9+
import com.intellij.openapi.module.Module
10+
import com.intellij.openapi.roots.ModuleRootManager
11+
import com.intellij.openapi.roots.ProjectRootManager
912
import com.intellij.psi.PsiDirectory
1013
import com.intellij.psi.PsiFile
1114
import com.intellij.psi.PsiRecursiveElementVisitor
@@ -45,12 +48,21 @@ abstract class GroupAction(name: String, icon: Icon) : AnAction(name, null, icon
4548
}
4649

4750
protected fun getPaparazziModule(e: AnActionEvent): PsiDirectory? {
48-
val psiDirectory = LangDataKeys.IDE_VIEW.getData(e.dataContext)?.directories?.firstOrNull() ?: return null
49-
ModuleUtilCore.findModuleForPsiElement(psiDirectory) ?: return null
50-
return psiDirectory
51+
val selectedItem = LangDataKeys.SELECTED_ITEMS.getData(e.dataContext)?.firstOrNull()
52+
return if (selectedItem is PsiDirectoryNode && isTestModule(selectedItem.value)) selectedItem.value else null
5153
}
5254

5355
private fun PsiDirectory.isPackage(): Boolean {
5456
return getPackage()?.qualifiedName?.isNotEmpty() == true
5557
}
58+
59+
private fun isTestModule(directory: PsiDirectory): Boolean {
60+
val project = directory.project
61+
val fileIndex = ProjectRootManager.getInstance(project).fileIndex
62+
val module: Module? = fileIndex.getModuleForFile(directory.virtualFile)
63+
64+
return module?.let {
65+
ModuleRootManager.getInstance(it).fileIndex.isInTestSourceContent(directory.virtualFile)
66+
} ?: false
67+
}
5668
}

src/main/resources/META-INF/plugin.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<idea-plugin>
22
<id>com.getyourguide.paparazzi</id>
3-
43
<name>Paparazzi</name>
5-
64
<vendor email="nativeapps-android@getyourguide.com" url="https://code.getyourguide.com/">GetYourGuide</vendor>
75

86
<description><![CDATA[

0 commit comments

Comments
 (0)