@Test public void additionalPluginDependenciesVersionConflictLatestDeclaredRemains() throws Exception { doAnswer(invocationOnMock -> { List<BundleDescriptor> dependencies = invocationOnMock.getArgument(0); return dependencies.stream() .map(dep -> resolveBundleDescriptor(dep)) .filter(dependencyOptional -> dependencyOptional.isPresent()) .map(dependencyOptional -> dependencyOptional.get()) .skip(1) .collect(toList()); }).when(mockedMavenClient).resolveArtifactDependencies(any(), any(), any()); DECLARED_POM_PLUGIN.setAdditionalDependencies(ImmutableList.of(declaredPomDependencyX10, declaredPomDependencyX11)); Map<BundleDependency, List<BundleDependency>> resolvedAdditionalDependencies = createAdditionalPluginDependenciesResolver(of(DECLARED_POM_PLUGIN)) .resolveDependencies(of(RESOLVED_BUNDLE_PLUGIN), of(resolvedPluginClassLoaderModel)); assertThat(resolvedAdditionalDependencies.size(), is(1)); assertThat(resolvedAdditionalDependencies, hasKey(equalTo(RESOLVED_BUNDLE_PLUGIN))); assertThat(resolvedAdditionalDependencies.get(RESOLVED_BUNDLE_PLUGIN), hasSize(1)); assertThat(resolvedAdditionalDependencies.get(RESOLVED_BUNDLE_PLUGIN), hasItem(resolvedDependencyX11)); }
public Map<BundleDependency, List<BundleDependency>> resolveDependencies(List<BundleDependency> applicationDependencies, Collection<ClassLoaderModel> mulePluginsClassLoaderModels) { addPluginDependenciesAdditionalLibraries(applicationDependencies); Map<BundleDependency, List<BundleDependency>> pluginsWithAdditionalDeps = new LinkedHashMap<>(); for (Plugin pluginWithAdditionalDependencies : pluginsWithAdditionalDependencies) { BundleDependency pluginBundleDependency = getPluginBundleDependency(pluginWithAdditionalDependencies, applicationDependencies); ClassLoaderModel pluginClassLoaderModel = getPluginClassLoaderModel(pluginWithAdditionalDependencies, mulePluginsClassLoaderModels); List<BundleDependency> additionalDependencies = resolveDependencies(pluginWithAdditionalDependencies.getAdditionalDependencies().stream() .filter(additionalDep -> !isPresentInClassLoaderModel(pluginClassLoaderModel, additionalDep)) .collect(toList())); if (!additionalDependencies.isEmpty()) { pluginsWithAdditionalDeps.put(pluginBundleDependency, additionalDependencies); } } return pluginsWithAdditionalDeps; }
AdditionalPluginDependenciesResolver { public Map<BundleDependency, List<BundleDependency>> resolveDependencies(List<BundleDependency> applicationDependencies, Collection<ClassLoaderModel> mulePluginsClassLoaderModels) { addPluginDependenciesAdditionalLibraries(applicationDependencies); Map<BundleDependency, List<BundleDependency>> pluginsWithAdditionalDeps = new LinkedHashMap<>(); for (Plugin pluginWithAdditionalDependencies : pluginsWithAdditionalDependencies) { BundleDependency pluginBundleDependency = getPluginBundleDependency(pluginWithAdditionalDependencies, applicationDependencies); ClassLoaderModel pluginClassLoaderModel = getPluginClassLoaderModel(pluginWithAdditionalDependencies, mulePluginsClassLoaderModels); List<BundleDependency> additionalDependencies = resolveDependencies(pluginWithAdditionalDependencies.getAdditionalDependencies().stream() .filter(additionalDep -> !isPresentInClassLoaderModel(pluginClassLoaderModel, additionalDep)) .collect(toList())); if (!additionalDependencies.isEmpty()) { pluginsWithAdditionalDeps.put(pluginBundleDependency, additionalDependencies); } } return pluginsWithAdditionalDeps; } }
AdditionalPluginDependenciesResolver { public Map<BundleDependency, List<BundleDependency>> resolveDependencies(List<BundleDependency> applicationDependencies, Collection<ClassLoaderModel> mulePluginsClassLoaderModels) { addPluginDependenciesAdditionalLibraries(applicationDependencies); Map<BundleDependency, List<BundleDependency>> pluginsWithAdditionalDeps = new LinkedHashMap<>(); for (Plugin pluginWithAdditionalDependencies : pluginsWithAdditionalDependencies) { BundleDependency pluginBundleDependency = getPluginBundleDependency(pluginWithAdditionalDependencies, applicationDependencies); ClassLoaderModel pluginClassLoaderModel = getPluginClassLoaderModel(pluginWithAdditionalDependencies, mulePluginsClassLoaderModels); List<BundleDependency> additionalDependencies = resolveDependencies(pluginWithAdditionalDependencies.getAdditionalDependencies().stream() .filter(additionalDep -> !isPresentInClassLoaderModel(pluginClassLoaderModel, additionalDep)) .collect(toList())); if (!additionalDependencies.isEmpty()) { pluginsWithAdditionalDeps.put(pluginBundleDependency, additionalDependencies); } } return pluginsWithAdditionalDeps; } AdditionalPluginDependenciesResolver(AetherMavenClient muleMavenPluginClient,
                                              List<Plugin> additionalPluginDependencies,
                                              File temporaryFolder); }
AdditionalPluginDependenciesResolver { public Map<BundleDependency, List<BundleDependency>> resolveDependencies(List<BundleDependency> applicationDependencies, Collection<ClassLoaderModel> mulePluginsClassLoaderModels) { addPluginDependenciesAdditionalLibraries(applicationDependencies); Map<BundleDependency, List<BundleDependency>> pluginsWithAdditionalDeps = new LinkedHashMap<>(); for (Plugin pluginWithAdditionalDependencies : pluginsWithAdditionalDependencies) { BundleDependency pluginBundleDependency = getPluginBundleDependency(pluginWithAdditionalDependencies, applicationDependencies); ClassLoaderModel pluginClassLoaderModel = getPluginClassLoaderModel(pluginWithAdditionalDependencies, mulePluginsClassLoaderModels); List<BundleDependency> additionalDependencies = resolveDependencies(pluginWithAdditionalDependencies.getAdditionalDependencies().stream() .filter(additionalDep -> !isPresentInClassLoaderModel(pluginClassLoaderModel, additionalDep)) .collect(toList())); if (!additionalDependencies.isEmpty()) { pluginsWithAdditionalDeps.put(pluginBundleDependency, additionalDependencies); } } return pluginsWithAdditionalDeps; } AdditionalPluginDependenciesResolver(AetherMavenClient muleMavenPluginClient,
                                              List<Plugin> additionalPluginDependencies,
                                              File temporaryFolder); Map<BundleDependency, List<BundleDependency>> resolveDependencies(List<BundleDependency> applicationDependencies,
                                                                           Collection<ClassLoaderModel> mulePluginsClassLoaderModels); }
AdditionalPluginDependenciesResolver { public Map<BundleDependency, List<BundleDependency>> resolveDependencies(List<BundleDependency> applicationDependencies, Collection<ClassLoaderModel> mulePluginsClassLoaderModels) { addPluginDependenciesAdditionalLibraries(applicationDependencies); Map<BundleDependency, List<BundleDependency>> pluginsWithAdditionalDeps = new LinkedHashMap<>(); for (Plugin pluginWithAdditionalDependencies : pluginsWithAdditionalDependencies) { BundleDependency pluginBundleDependency = getPluginBundleDependency(pluginWithAdditionalDependencies, applicationDependencies); ClassLoaderModel pluginClassLoaderModel = getPluginClassLoaderModel(pluginWithAdditionalDependencies, mulePluginsClassLoaderModels); List<BundleDependency> additionalDependencies = resolveDependencies(pluginWithAdditionalDependencies.getAdditionalDependencies().stream() .filter(additionalDep -> !isPresentInClassLoaderModel(pluginClassLoaderModel, additionalDep)) .collect(toList())); if (!additionalDependencies.isEmpty()) { pluginsWithAdditionalDeps.put(pluginBundleDependency, additionalDependencies); } } return pluginsWithAdditionalDeps; } AdditionalPluginDependenciesResolver(AetherMavenClient muleMavenPluginClient,
                                              List<Plugin> additionalPluginDependencies,
                                              File temporaryFolder); Map<BundleDependency, List<BundleDependency>> resolveDependencies(List<BundleDependency> applicationDependencies,
                                                                           Collection<ClassLoaderModel> mulePluginsClassLoaderModels);  }