From 6979ba715a26e859dfd484c2517c4fd3d593fb5b Mon Sep 17 00:00:00 2001 From: Jaime Wren Date: Wed, 13 Nov 2024 10:37:47 -0800 Subject: [PATCH] Re-enable the verify gradle task and have Kokoro run it again This is follow-up work for https://github.com/flutter/flutter-intellij/pull/7774 and https://github.com/flutter/flutter-intellij/issues/7670 --- build.gradle.kts | 89 ++++++++++++------- flutter-idea/build.gradle.kts | 74 +++++++++------ .../facet/AndroidFrameworkDetector.java | 40 +++++---- tool/kokoro/build.sh | 2 + tool/plugin/lib/verify.dart | 22 ++++- 5 files changed, 144 insertions(+), 83 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e67f0aff38..0cf8dc47d6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,6 +7,7 @@ import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType import org.jetbrains.intellij.platform.gradle.TestFrameworkType import org.jetbrains.intellij.platform.gradle.models.ProductRelease +import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinVersion @@ -68,12 +69,17 @@ java { dependencies { intellijPlatform { + // Documentation on the create(...) methods: + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#custom-target-platforms if (ideaProduct == "android-studio") { create(IntelliJPlatformType.AndroidStudio, ideaVersion) } else {//if (ide == "ideaIC") { create(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion) } testFramework(TestFrameworkType.Platform) + + // Plugin dependnecy documentation: + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#plugins val bundledPluginList = mutableListOf( "com.intellij.java", "com.intellij.properties", @@ -103,42 +109,57 @@ dependencies { // Please ensure the `instrumentationTools()` entry is present in the project dependencies section along with the `intellijDependencies()` entry in the repositories section. // See: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html instrumentationTools() -// pluginVerifier() + pluginVerifier() + } +} + +intellijPlatform { + pluginConfiguration { + version = flutterPluginVersion + ideaVersion { + sinceBuild = sinceBuildInput + untilBuild = untilBuildInput + } + } + + // Verifier documentation + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification-ides + pluginVerification { + // https://github.com/JetBrains/intellij-plugin-verifier/?tab=readme-ov-file#specific-options + // https://github.com/JetBrains/intellij-plugin-verifier + cliPath = file("../third_party/lib/verifier-cli-1.379-all.jar") + failureLevel = listOf( + VerifyPluginTask.FailureLevel.COMPATIBILITY_PROBLEMS, + VerifyPluginTask.FailureLevel.EXPERIMENTAL_API_USAGES, + VerifyPluginTask.FailureLevel.PLUGIN_STRUCTURE_WARNINGS, + VerifyPluginTask.FailureLevel.INVALID_PLUGIN, + ) + verificationReportsFormats = VerifyPluginTask.VerificationReportsFormats.ALL + subsystemsToCheck = VerifyPluginTask.Subsystems.ALL + // Mute and freeArgs documentation + // https://github.com/JetBrains/intellij-plugin-verifier/?tab=readme-ov-file#specific-options + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#mutePluginVerifierProblems + freeArgs = listOf( + "-mute", + "TemplateWordInPluginId,ForbiddenPluginIdPrefix,TemplateWordInPluginName" + ) + ides { + if (ideaProduct == "android-studio") { + ide(IntelliJPlatformType.AndroidStudio, ideaVersion) + } else { + ide(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion) + } + recommended() +// select { +// types = listOf(IntelliJPlatformType.AndroidStudio) +// channels = listOf(ProductRelease.Channel.RELEASE) +// sinceBuild = sinceBuildInput +// untilBuild = untilBuildInput +// } + } } } -//intellijPlatform { -// pluginConfiguration { -// version = flutterPluginVersion -// ideaVersion { -// sinceBuild = sinceBuildInput -// untilBuild = untilBuildInput -// } -// } -// // TODO (jwren) get the verifier to work, and enable in the github presubmit, -// // the com.teamdev dep is having the verifier fail -// // Verifier documentation: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification-ides -// pluginVerification { -// // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#mutePluginVerifierProblems -// freeArgs = listOf( -// "-mute", -// "TemplateWordInPluginId" -// ) -// ides { -// if (ideaProduct == "android-studio") { -// ide(IntelliJPlatformType.AndroidStudio, ideaVersion) -// } else { -// ide(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion) -// } -// recommended() -//// select { -//// types = listOf(IntelliJPlatformType.AndroidStudio) -//// channels = listOf(ProductRelease.Channel.RELEASE) -//// sinceBuild = sinceBuildInput -//// untilBuild = untilBuildInput -//// } -// } -// } -//} // Documentation for printProductsReleases: // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#how-to-check-the-latest-available-eap-release diff --git a/flutter-idea/build.gradle.kts b/flutter-idea/build.gradle.kts index 0b0608c4e3..874e7e4f85 100644 --- a/flutter-idea/build.gradle.kts +++ b/flutter-idea/build.gradle.kts @@ -7,6 +7,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType import org.jetbrains.intellij.platform.gradle.TestFrameworkType +import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinVersion @@ -49,12 +50,17 @@ java { dependencies { intellijPlatform { + // Documentation on the create(...) methods: + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#custom-target-platforms if (ideaProduct == "android-studio") { create(IntelliJPlatformType.AndroidStudio, ideaVersion) } else { // if (ideaProduct == "IC") { create(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion) } testFramework(TestFrameworkType.Platform) + + // Plugin dependnecy documentation: + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#plugins val bundledPluginList = mutableListOf( "com.intellij.java", "com.intellij.properties", @@ -84,7 +90,7 @@ dependencies { // Please ensure the `instrumentationTools()` entry is present in the project dependencies section along with the `intellijDependencies()` entry in the repositories section. // See: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html instrumentationTools() -// pluginVerifier() + pluginVerifier() } } @@ -96,30 +102,44 @@ intellijPlatform { untilBuild = untilBuildInput } } - // TODO (jwren) get the verifier to work, and enable in the github presubmit, - // the com.teamdev dep is having the verifier fail - // Verifier documentation: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification-ides -// pluginVerification { -// // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#mutePluginVerifierProblems -// freeArgs = listOf( -// "-mute", -// "TemplateWordInPluginId" -// ) -// ides { -// if (ideaProduct == "android-studio") { -// ide(IntelliJPlatformType.AndroidStudio, ideaVersion) -// } else { -// ide(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion) -// } -// recommended() -//// select { -//// types = listOf(IntelliJPlatformType.AndroidStudio) -//// channels = listOf(ProductRelease.Channel.RELEASE) -//// sinceBuild = sinceBuildInput -//// untilBuild = untilBuildInput -//// } -// } -// } + + // Verifier documentation + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification-ides + pluginVerification { + // https://github.com/JetBrains/intellij-plugin-verifier/?tab=readme-ov-file#specific-options + // https://github.com/JetBrains/intellij-plugin-verifier + cliPath = file("../third_party/lib/verifier-cli-1.379-all.jar") + failureLevel = listOf( + VerifyPluginTask.FailureLevel.COMPATIBILITY_PROBLEMS, + VerifyPluginTask.FailureLevel.EXPERIMENTAL_API_USAGES, + VerifyPluginTask.FailureLevel.PLUGIN_STRUCTURE_WARNINGS, + VerifyPluginTask.FailureLevel.INVALID_PLUGIN, + ) + verificationReportsFormats = VerifyPluginTask.VerificationReportsFormats.ALL + subsystemsToCheck = VerifyPluginTask.Subsystems.ALL + // Mute and freeArgs documentation + // https://github.com/JetBrains/intellij-plugin-verifier/?tab=readme-ov-file#specific-options + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#mutePluginVerifierProblems + freeArgs = listOf( + "-mute", + "TemplateWordInPluginId,ForbiddenPluginIdPrefix,TemplateWordInPluginName" + ) + ides { + if (ideaProduct == "android-studio") { + ide(IntelliJPlatformType.AndroidStudio, ideaVersion) + } else { + ide(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion) + } + recommended() +// select { +// types = listOf(IntelliJPlatformType.AndroidStudio) +// channels = listOf(ProductRelease.Channel.RELEASE) +// sinceBuild = sinceBuildInput +// untilBuild = untilBuildInput +// } + } + } } dependencies { @@ -154,11 +174,13 @@ dependencies { compileOnly("com.google.code.gson:gson:2.10.1") testImplementation("com.google.guava:guava:32.0.0-jre") testImplementation("com.google.code.gson:gson:2.10.1") + testImplementation("junit:junit:4.13.2") + runtimeOnly(fileTree(mapOf("dir" to "${project.rootDir}/third_party/lib/jxbrowser", + "include" to listOf("*.jar")))) compileOnly(fileTree(mapOf("dir" to "${project.rootDir}/third_party/lib/jxbrowser", "include" to listOf("*.jar")))) testImplementation(fileTree(mapOf("dir" to "${project.rootDir}/third_party/lib/jxbrowser", "include" to listOf("*.jar")))) - testImplementation("junit:junit:4.13.2") } sourceSets { diff --git a/flutter-idea/src/org/jetbrains/android/facet/AndroidFrameworkDetector.java b/flutter-idea/src/org/jetbrains/android/facet/AndroidFrameworkDetector.java index 7400ccf981..008567902c 100644 --- a/flutter-idea/src/org/jetbrains/android/facet/AndroidFrameworkDetector.java +++ b/flutter-idea/src/org/jetbrains/android/facet/AndroidFrameworkDetector.java @@ -54,25 +54,27 @@ private static boolean getFirstAsBoolean(@NotNull Pair pair return Boolean.parseBoolean(pair.getFirst()); } - @NotNull - public static Notification showDexOptionNotification(@NotNull Module module, @NotNull String propertyName) { - Project project = module.getProject(); - Notification notification = NotificationGroupManager.getInstance().getNotificationGroup("Android Module Importing").createNotification( - AndroidBundle.message("android.facet.importing.title", module.getName()), - "'" + propertyName + - "' property is detected in " + SdkConstants.FN_PROJECT_PROPERTIES + - " file.
You may enable related option in Settings | Compiler | Android DX", - NotificationType.INFORMATION).setListener(new NotificationListener.Adapter() { - @Override - protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) { - notification.expire(); - ShowSettingsUtil.getInstance().showSettingsDialog( - project, AndroidBundle.message("android.dex.compiler.configurable.display.name")); - } - }); - notification.notify(project); - return notification; - } + // TODO(jwren) Add this support back into the plugin or delete the code + // Method is current dead when uncommented, commented out for the `./bin/plugin verify` command + //@NotNull + //public static Notification showDexOptionNotification(@NotNull Module module, @NotNull String propertyName) { + // Project project = module.getProject(); + // Notification notification = NotificationGroupManager.getInstance().getNotificationGroup("Android Module Importing").createNotification( + // AndroidBundle.message("android.facet.importing.title", module.getName()), + // "'" + propertyName + + // "' property is detected in " + SdkConstants.FN_PROJECT_PROPERTIES + + // " file.
You may enable related option in Settings | Compiler | Android DX", + // NotificationType.INFORMATION).setListener(new NotificationListener.Adapter() { + // @Override + // protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) { + // notification.expire(); + // ShowSettingsUtil.getInstance().showSettingsDialog( + // project, AndroidBundle.message("android.dex.compiler.configurable.display.name")); + // } + // }); + // notification.notify(project); + // return notification; + //} @NotNull @Override diff --git a/tool/kokoro/build.sh b/tool/kokoro/build.sh index dae09308d8..2b6b873adc 100755 --- a/tool/kokoro/build.sh +++ b/tool/kokoro/build.sh @@ -5,6 +5,8 @@ setup echo "kokoro build start" +./bin/plugin verify + ./bin/plugin make --channel=dev echo "kokoro build finished" diff --git a/tool/plugin/lib/verify.dart b/tool/plugin/lib/verify.dart index 6cf78bf738..c8532f59bb 100644 --- a/tool/plugin/lib/verify.dart +++ b/tool/plugin/lib/verify.dart @@ -19,19 +19,33 @@ class VerifyCommand extends ProductCommand { @override Future doit() async { + // run './gradlew verifyPluginProjectConfiguration' + // run './gradlew verifyPluginStructure' + // run './gradlew verifyPluginSignature' // run './gradlew verifyPlugin' - // run './gradlew verifyPluginConfiguration' var result = 0; for (var spec in specs) { - log('\nverifyPluginConfiguration for $spec:'); + log('\nverifyPluginProjectConfiguration for $spec:'); result = await runner - .runGradleCommand(['verifyPluginConfiguration'], spec, '1', 'false'); + .runGradleCommand(['verifyPluginProjectConfiguration'], spec, '1', 'false'); + if (result != 0) { + return result; + } + log('\nverifyPluginStructure for $spec:'); + result = + await runner.runGradleCommand(['verifyPluginStructure'], spec, '1', 'false'); + if (result != 0) { + return result; + } + log('\nverifyPluginSignature for $spec:'); + result = + await runner.runGradleCommand(['verifyPluginSignature'], spec, '1', 'false'); if (result != 0) { return result; } log('\nverifyPlugin for $spec:'); result = - await runner.runGradleCommand(['verifyPlugin'], spec, '1', 'false'); + await runner.runGradleCommand(['verifyPlugin'], spec, '1', 'false'); if (result != 0) { return result; }