com.jetbrains.plugin.structure.intellij.verifiers.DependenciesVerifiers.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of structure-intellij Show documentation
Show all versions of structure-intellij Show documentation
Library for parsing JetBrains IDE plugins. Can be used to verify that plugin complies with the JetBrains Marketplace requirements.
package com.jetbrains.plugin.structure.intellij.verifiers
import com.jetbrains.plugin.structure.base.problems.PluginProblem
import com.jetbrains.plugin.structure.base.problems.ReusedDescriptorInMultipleDependencies
import com.jetbrains.plugin.structure.intellij.beans.PluginDependencyBean
/**
* Validates if each dependency in `` provides a unique `config-file`, if such file is declared.
*
* Multiple dependencies specified in the same plugin descriptor cannot redeclare same `config-file`.
*/
class ReusedDescriptorVerifier(private val descriptorPath: String? = null) {
fun verify(dependencies: Collection, problemConsumer: (PluginProblem) -> Unit) {
dependencies.groupBy { it.configFile }
.filterKeys { it != null }
.filterValues { it.size > 1 }
.forEach { (configFile, dependencies) ->
val dependencyIdentifiers = dependencies.map { it.dependencyId }
problemConsumer(ReusedDescriptorInMultipleDependencies(descriptorPath, configFile, dependencyIdentifiers))
}
}
}