override fun exec()

in src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginTask.kt [207:293]


    override fun exec() {
        with(ides) {
            if (isEmpty) {
                val label = "No IDE versions configured for verification"
                val details = "The IntelliJ Plugin Verifier requires at least one IDE version to verify the plugin against, but none were configured. IDE versions are specified through the intellijPlatform.pluginVerification.ides block."
                val solution = "Configure IDE versions in the intellijPlatform.pluginVerification.ides block (e.g., ides { recommended() }) and ensure defaultRepositories() or at least localPlatformArtifacts() is present in the repositories section to resolve IDE artifacts."

                throw problems.reporter.reportError(
                    GradleException("$label $details $solution"),
                    Problems.VerifyPlugin.InvalidIDEs,
                    problemsReportUrl,
                ) {
                    contextualLabel(label)
                    details(details)
                    solution(solution)
                    documentedAt("https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification-ides")
                }
            }

            if (listIdes.getOrElse(false)) {
                return map { it.toPath().resolvePlatformPath() }.joinToString(
                    separator = "\n",
                    prefix = "IDEs that will be used for verification:\n",
                ) { platformPath ->
                    val productInfo = platformPath.productInfo()
                    "${productInfo.type}-${productInfo.version} - ${platformPath.safePathString}"
                }.let(::println)
            }
        }

        val file = archiveFile.orNull?.asPath
        if (file == null || !file.exists()) {
            val label = "Plugin archive file not found"
            val details = "The plugin archive file ${file ?: "is not specified"} does not exist or could not be found. This typically happens when the BuildPluginTask has not been executed or its output location was changed."
            val solution = "Ensure the BuildPluginTask has been executed successfully and verify the archiveFile property points to a valid plugin artifact."

            throw problems.reporter.reportError(
                IllegalStateException("$label $details $solution"),
                Problems.VerifyPlugin.InvalidPlugin,
                problemsReportUrl,
            ) {
                contextualLabel(label)
                details(details)
                solution(solution)
                fileLocation(file?.toString() ?: "")
            }
        }

        log.debug("Distribution file: $file")

        val executable = pluginVerifierExecutable.orNull?.asPath
            ?: run {
                val label = "IntelliJ Plugin Verifier executable not found"
                val details = "The IntelliJ Plugin Verifier CLI tool executable could not be located. This dependency is required to perform plugin verification against target IDE versions."
                val solution = "Add the pluginVerifier() dependency in the project dependencies section: dependencies { intellijPlatform { pluginVerifier() } }, or configure the intellijPlatform.pluginVerification.cliPath extension property to point to a local Plugin Verifier installation."

                throw problems.reporter.reportError(
                    GradleException("$label $details $solution"),
                    Problems.VerifyPlugin.InvalidPluginVerifier,
                    problemsReportUrl,
                ) {
                    contextualLabel(label)
                    details(details)
                    solution(solution)
                    documentedAt("https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification")
                }
            }

        log.debug("Verifier path: $executable")

        classpath = objectFactory.fileCollection().from(executable)

        args(
            listOf("check-plugin") + getOptions() + file.safePathString + ides.map {
                when {
                    it.isDirectory -> it.absolutePath
                    else -> it.readText()
                }
            },
        )

        ByteArrayOutputStream().use { os ->
            standardOutput = TeeOutputStream(System.out, os)
            super.exec()
            verifyOutput(os.toString())
        }
    }