Skip to content

Commit

Permalink
Merge pull request #80 from VirtusLab/multi-plugin-resolver
Browse files Browse the repository at this point in the history
Allow multiple plugin resolvers
  • Loading branch information
lukaszwawrzyk authored Nov 13, 2020
2 parents 2804477 + b594e33 commit 6f79e58
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@ final class IntelliJDependencyProvider(
}

final class PluginDependencyProvider(
pluginResolver: DependencyResolver[Plugin],
pluginResolvers: Seq[DependencyResolver[Plugin]],
resources: ResourceProvider
) {
def fetch(plugin: Plugin): Path = {
pluginResolver.resolve(plugin) match {
val noResolversError = Try[Path](error("Dependency resolver list is empty"))
pluginResolvers
.foldLeft(noResolversError) { (result, resolver) =>
result.orElse(Try(resolve(plugin, resolver)))
}
.get
}

private def resolve(plugin: Plugin, resolver: DependencyResolver[Plugin]): Path = {
resolver.resolve(plugin) match {
case Artifact(uri) =>
resources.get(uri)
case Sources(id, config) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,22 @@ object IntelliJFactory {
new IntelliJFactory(
new DependencyProvider(
new IntelliJDependencyProvider(Seq(IntelliJZipResolver.Community), ResourceProvider.Default),
new PluginDependencyProvider(PluginResolver.Official, ResourceProvider.Default)
new PluginDependencyProvider(Seq(PluginResolver.Official), ResourceProvider.Default)
),
IdeProbePaths.Default,
DriverConfig()
)

def from(resolversConfig: DependenciesConfig.Resolvers, paths: IdeProbePaths, driverConfig: DriverConfig): IntelliJFactory = {
def from(
resolversConfig: DependenciesConfig.Resolvers,
paths: IdeProbePaths,
driverConfig: DriverConfig
): IntelliJFactory = {
val intelliJResolver = IntelliJZipResolver.from(resolversConfig.intellij)
val pluginResolver = PluginResolver.from(resolversConfig.plugins)
val resourceProvider = ResourceProvider.from(paths)
val intelliJDependencyProvider = new IntelliJDependencyProvider(Seq(intelliJResolver), resourceProvider)
val pluginDependencyProvider = new PluginDependencyProvider(pluginResolver, resourceProvider)
val pluginDependencyProvider = new PluginDependencyProvider(Seq(pluginResolver), resourceProvider)
val dependencyProvider = new DependencyProvider(intelliJDependencyProvider, pluginDependencyProvider)
new IntelliJFactory(dependencyProvider, paths, driverConfig)
}
Expand Down

0 comments on commit 6f79e58

Please sign in to comment.