Skip to content

Commit

Permalink
Mob 35191 support android studio hedgehog (#103)
Browse files Browse the repository at this point in the history
* [support_hedgehog] Обновляет версии Gradle, Kotlin, gradle-intellij-plugin, detekt

* [support_hedgehog] Поднимает максимальный объём памяти для запуска IDE из проекта с плагинами

* [support_hedgehog] Поднимает версию для запуска плагинов под Android Studio Hedgehog

* [support_hedgehog] Исправляет константы для сборки плагинов через Github Actions

* [support_hedgehog] Поднимает версии плагинов

* [support_hedgehog] Исправляет замечания detekt

* [support_hedgehog] Поднимает версию github action, запускающего detekt
  • Loading branch information
PStrelchenko committed Dec 1, 2023
1 parent d661560 commit 5678e28
Show file tree
Hide file tree
Showing 32 changed files with 87 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ on: [pull_request, workflow_call]

env:
# Link for Linux zip file from https://developer.android.com/studio/archive
ANDROID_STUDIO_URL: https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2022.3.1.18/android-studio-2022.3.1.18-linux.tar.gz
COMPILER_VERSION: 223.8836.35
ANDROID_STUDIO_URL: https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2023.1.1.26/android-studio-2023.1.1.26-linux.tar.gz
COMPILER_VERSION: 231.9392.1

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:

env:
# Link for Linux zip file from https://developer.android.com/studio/archive
ANDROID_STUDIO_URL: https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2022.3.1.18/android-studio-2022.3.1.18-linux.tar.gz
COMPILER_VERSION: 223.8836.35
ANDROID_STUDIO_URL: https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2023.1.1.26/android-studio-2023.1.1.26-linux.tar.gz
COMPILER_VERSION: 231.9392.1

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
fetch-depth: 1
- name: detekt
uses: alaegin/Detekt-Action@v1.19
uses: alaegin/Detekt-Action@v1.23.4
with:
github_token: ${{ secrets.github_token }}
detekt_config: build-logic/static-analysis-convention/rules/detekt/detekt-config.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ tasks.getByName<Zip>("buildPlugin") {
}

tasks.getByName<RunIdeTask>("runIde") {
maxHeapSize = "4g"
maxHeapSize = "8g"
minHeapSize = "4g"
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ val detektFormat by tasks.register<Detekt>("detektFormat") {

// Configuration
val staticAnalysisExtension = project.extensions.getByName<StaticAnalysisExtension>("staticAnalysis")
config.setFrom(staticAnalysisExtension.detekt.formatPath)
config.setFrom(staticAnalysisExtension.detekt.configPath)
}

val detektProjectBaseline by tasks.register<DetektCreateBaselineTask>("detektProjectBaseline") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ import java.io.File

class DetektConfigExtension(
var configPath: Iterable<*>? = null,
var formatPath: Iterable<*>? = null,
var baselinePath: File? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tasks.withType<Test>().configureEach {
}
}

plugins.withType<KotlinBasePluginWrapper>() {
plugins.withType<KotlinBasePluginWrapper> {
dependencies {
add("testImplementation", Libs.tests.kotest)
}
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ org.gradle.caching=false
kotlin.parallel.tasks.in.project=true
kotlin.code.style=official

systemProp.gradleIntellijPluginVersion=1.15.0
systemProp.gradleIntellijPluginVersion=1.16.0
systemProp.gradleChangelogPluginVersion=2.1.2
systemProp.kotlinVersion=1.9.0
systemProp.detektVersion=1.22.0
systemProp.kotlinVersion=1.9.21
systemProp.detektVersion=1.23.4

systemProp.androidStudioPath=/Applications/Android Studio.app/Contents
systemProp.androidStudioCompilerVersion=223.8836.35
systemProp.androidStudioCompilerVersion=231.9392.1
systemProp.androidStudioPluginsNames=org.jetbrains.android,org.jetbrains.kotlin,com.intellij.java,org.intellij.groovy,Git4Idea,org.intellij.intelliLang

# Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
Expand Down
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.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 4 additions & 0 deletions plugins/hh-carnival/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Carnival

## [1.6.0]
### Added
- Support for Android Studio Hedgehog | 2023.1.1

## [1.5.0]
### Added
- Support for Android Studio Giraffe | 2022.3.1
Expand Down
2 changes: 1 addition & 1 deletion plugins/hh-carnival/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pluginVersion=1.5.0
pluginVersion=1.6.0

pluginGroup=ru.hh.plugins
pluginName=hh-carnival
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class JiraSettingsConfig : PersistentStateComponent<Credentials> {
get() {
val keyFile = File(KEY_FILE_NAME)

if (!keyFile.exists())
if (!keyFile.exists()) {
keyFile.createNewFile()
}

val reader = FileReader(KEY_FILE_NAME)
val hostname = reader.readText()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class PluginConfigEditor(
initialJiraUsername != jiraUsernameTextField.text ||
initialJiraPassword != jiraPasswordTextField.text ||
initialJiraDevelopmentTeam != JiraDevelopmentTeam.fromLabel(
jiraDevelopmentTeamComboBoxModel.selected.orEmpty()
)
jiraDevelopmentTeamComboBoxModel.selected.orEmpty()
)
}

fun applyNewConfiguration(project: Project, pluginConfig: PluginConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ class PutSerializableDetector : Detector(), SourceCodeScanner {
.mapNotNull { checkIsSerializable(it.type as PsiClassReferenceType, checkedPsiClass, "${ktUltraLightClass.name}") }
.firstOrNull()
}
logger.debug("\tChecked all inner fields for inheritance, is fully serializable: is serializable ${result == null} [time: $checkTime ms]")
logger.debug(
"\tChecked all inner fields for inheritance, is fully serializable: " +
"is serializable ${result == null} [time: $checkTime ms]"
)

result?.let { pathToFirstNotSerializableObject ->
logger.debug("----- END need report issue -----")
Expand Down Expand Up @@ -137,7 +140,13 @@ class PutSerializableDetector : Detector(), SourceCodeScanner {
it.type.canonicalText.endsWith("Companion").not() &&
it.type.canonicalText.equals(ktLightClassForSourceDeclaration.type().canonicalText).not()
}
.mapNotNull { checkIsSerializable(it.type as PsiClassReferenceType, checkedClass, "$objectPath.${ktLightClassForSourceDeclaration.name}") }
.mapNotNull {
checkIsSerializable(
it.type as PsiClassReferenceType,
checkedClass,
"$objectPath.${ktLightClassForSourceDeclaration.name}"
)
}
.firstOrNull()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class EmptyObjectGeneratorService(

private fun KtClass.getEmptyObjectPropertyDeclaration(): String {
val emptyProperties = primaryConstructorParameters.joinToString(
prefix = "\n", postfix = "\n", separator = ",\n"
prefix = "\n",
postfix = "\n",
separator = ",\n"
) { parameter ->
"${parameter.name} = ${parameter.getEmptyObjectValue()}"
}
Expand Down
4 changes: 4 additions & 0 deletions plugins/hh-garcon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Garcon

## [1.5.0]
### Added
- Support for Android Studio Hedgehog | 2023.1.1

## [1.4.0]
### Added
- Support for Android Studio Giraffe | 2022.3.1
Expand Down
2 changes: 1 addition & 1 deletion plugins/hh-garcon/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pluginVersion=1.4.0
pluginVersion=1.5.0

pluginGroup=ru.hh.plugins
pluginName=hh-garcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class CollectWidgetsIntoPageObjectAction : XmlLayoutCodeInsightAction() {
if (params.openInEditor) {
params.targetClass.containingKtFile.openInEditor()
}
HHNotifications.info(message = "Collecting Kakao widgets for '${params.targetClass.name}' successfully finished")
HHNotifications.info(
message = "Collecting Kakao widgets for '${params.targetClass.name}' successfully finished"
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class CollectWidgetsIntoPageObjectDialog(
if (isFormValid()) {
targetClass?.let { aClass ->
RecentsManager.getInstance(project).registerRecentEntry(
GarconConstants.RecentsKeys.TARGET_SCREEN_CLASS, aClass.getKotlinFqName().toString()
GarconConstants.RecentsKeys.TARGET_SCREEN_CLASS,
aClass.getKotlinFqName().toString()
)
}
PropertiesComponent.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class CreateRecyclerItemPageObjectDialog(
if (isFormValid()) {
targetClass?.let { aClass ->
RecentsManager.getInstance(project).registerRecentEntry(
GarconConstants.RecentsKeys.TARGET_SCREEN_CLASS, aClass.getKotlinFqName().toString()
GarconConstants.RecentsKeys.TARGET_SCREEN_CLASS,
aClass.getKotlinFqName().toString()
)
}
PropertiesComponent.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.intellij.ide.util.ClassFilter
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiClass
import com.intellij.psi.util.InheritanceUtil
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
import org.jetbrains.kotlin.psi.KtClass
Expand All @@ -17,16 +18,19 @@ class ClassFiltersFactory {
}

fun createKakaoScreensClassFilter(): ClassFilter {
return ClassFilter { aClass ->
return@ClassFilter if (aClass is KtLightClassForSourceDeclaration) {
when (val classOrObject = aClass.kotlinOrigin) {
is KtClass -> (classOrObject.isInner() || classOrObject.isAnnotation()).not() &&
InheritanceUtil.isInheritor(aClass, GarconConstants.AGODA_SCREEN_CLASS_FQN)
else -> false
}
} else {
false
return ClassFilter { isAccepted(it) }
}

private fun isAccepted(aClass: PsiClass?): Boolean {
return if (aClass is KtLightClassForSourceDeclaration) {
when (val classOrObject = aClass.kotlinOrigin) {
is KtClass -> (classOrObject.isInner() || classOrObject.isAnnotation()).not() &&
InheritanceUtil.isInheritor(aClass, GarconConstants.AGODA_SCREEN_CLASS_FQN)

else -> false
}
} else {
false
}
}
}
3 changes: 3 additions & 0 deletions plugins/hh-geminio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Geminio

## [1.7.0]
### Added
- Support for Android Studio Hedgehog | 2023.1.1

## [1.6.1]

Expand Down
2 changes: 1 addition & 1 deletion plugins/hh-geminio/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pluginVersion=1.6.1
pluginVersion=1.7.0

pluginGroup=ru.hh.plugins
pluginName=hh-geminio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class ExecuteGeminioModuleTemplateAction(

try {
project.executeWriteCommand(COMMAND_RECIPE_EXECUTION) {

with(recipeExecutorModel) {
geminioTemplateData.androidStudioTemplate.recipe.invoke(
recipeExecutor,
Expand All @@ -139,7 +138,10 @@ class ExecuteGeminioModuleTemplateAction(
dialog.disposeIfNeeded()
dialog.close(1)

HHNotifications.error(message = "Some error occurred when '$actionText' executed. Check warnings at the bottom right corner.")
HHNotifications.error(
message = "Some error occurred when '$actionText' executed. " +
"Check warnings at the bottom right corner."
)
throw ex
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ class GeminioStartupActivity : StartupActivity {
override fun windowActivated(e: WindowEvent?) {
val lastProject = lastViewedProject.get()
if (lastProject != project) {
HHLogger.d("Project changed -> rescan Geminio's actions [old project name: `${lastProject.name}`, new project.name: `${project.name}`]")
HHLogger.d(
"Project changed -> rescan Geminio's actions " +
"[old project name: `${lastProject.name}`, new project.name: `${project.name}`]"
)
rescanTemplateActions(project)
} else {
HHLogger.d("Activated project is the same as previous -> no need to rescan Geminio's actions [project.name: `${project.name}`]")
HHLogger.d(
"Activated project is the same as previous -> " +
"no need to rescan Geminio's actions [project.name: `${project.name}`]"
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class BuildGradleModificationService(
HHLogger.e(
"Can't find `$BUILD_GRADLE_FILENAME` or `$BUILD_GRADLE_KTS_FILENAME` file in rootDir ($rootDir)"
)
@Suppress("detekt.LabeledExpression")
return@wrapInCommand
}

Expand All @@ -77,6 +78,7 @@ class BuildGradleModificationService(
isInWriteCommand: Boolean = false
) {
wrapInCommand(isInWriteCommand) {
@Suppress("detekt.LabeledExpression")
val buildGradleFile = rootDir?.findFile(BUILD_GRADLE_FILENAME)
?: rootDir?.findFile(BUILD_GRADLE_KTS_FILENAME)
?: return@wrapInCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiElement

fun AnActionEvent.getSelectedPsiElement(): PsiElement? = getData(PlatformDataKeys.PSI_ELEMENT)

@Suppress("detekt.UseCheckOrError")
fun AnActionEvent.getTargetDirectory(): VirtualFile {
val currentVirtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ interface GeminioSdk {
geminioRecipe: GeminioRecipe,
targetDirectory: VirtualFile,
): GeminioTemplateData

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ internal fun RecipeExecutor.execute(
val to = command.to.evaluateString(targetDirectory, moduleTemplateData, existingParametersMap)

HHLogger.d("Instantiate command [command: $command, from: $from, to: $to]")
if (from == null || to == null) {
throw IllegalArgumentException(
"Cannot evaluate 'from' or 'to' expressions [command: $command, from: $from, to: $to]"
)
require(from != null && to != null) {
"Cannot evaluate 'from' or 'to' expressions [command: $command, from: $from, to: $to]"
}
val fileText = freemarkerConfiguration.resolveTemplate(from, resolvedParamsMap)
save(fileText, File(to))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ internal fun RecipeExecutor.execute(
val filePath = command.file.evaluateString(targetDirectory, moduleTemplateData, existingParametersMap)

HHLogger.d("Open command [filePath: $filePath]")
if (filePath == null) {
throw IllegalArgumentException(
"Cannot find file for Open command [command: $command, evaluated path: $filePath]"
)
require(filePath != null) {
"Cannot find file for Open command [command: $command, evaluated path: $filePath]"
}

open(File(filePath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ private fun getHardcodedParamsMap(
)
}


return mapOf(
HardcodedParams.PACKAGE_NAME to packageName,
HardcodedParams.APPLICATION_PACKAGE to applicationPackage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ internal fun RecipeExpression.evaluateBoolean(
return when (expressionCommands.size) {
0 -> true
1 -> expressionCommands[0].resolveBooleanValue(existingParametersMap)
else -> throw IllegalArgumentException("Unexpected commands for boolean parameter evaluation [$expressionCommands]")
else -> throw IllegalArgumentException(
"Unexpected commands for boolean parameter evaluation [$expressionCommands]"
)
}
}

Expand Down

0 comments on commit 5678e28

Please sign in to comment.