Search in sources :

Example 1 with BundleDescriptor

use of org.mule.runtime.module.artifact.api.descriptor.BundleDescriptor in project mule by mulesoft.

the class BundlePluginDependenciesResolverTestCase method resolvesSnapshotPluginDependencyWithCompatibleMinorVersion.

@Test
public void resolvesSnapshotPluginDependencyWithCompatibleMinorVersion() throws Exception {
    ArtifactPluginDescriptor updatedFooPlugin = new ArtifactPluginDescriptor(FOO_PLUGIN);
    updatedFooPlugin.setBundleDescriptor(createTestBundleDescriptor(FOO_PLUGIN, "1.1"));
    final List<ArtifactPluginDescriptor> pluginDescriptors = createPluginDescriptors(updatedFooPlugin, barPlugin);
    BundleDescriptor fooBundleDescriptor = createTestBundleDescriptor(FOO_PLUGIN, "1.0-SNAPSHOT");
    barPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(createBundleDependency(fooBundleDescriptor))).build());
    final List<ArtifactPluginDescriptor> resolvedPluginDescriptors = dependenciesResolver.resolve(emptySet(), pluginDescriptors);
    assertResolvedPlugins(resolvedPluginDescriptors, updatedFooPlugin, barPlugin);
}
Also used : BundleDescriptor(org.mule.runtime.module.artifact.api.descriptor.BundleDescriptor) ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) ClassLoaderModelBuilder(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel.ClassLoaderModelBuilder) Test(org.junit.Test)

Example 2 with BundleDescriptor

use of org.mule.runtime.module.artifact.api.descriptor.BundleDescriptor in project mule by mulesoft.

the class DefaultApplicationFactoryTestCase method createClassLoaderModelWithDomain.

private ClassLoaderModel createClassLoaderModelWithDomain() {
    BundleDescriptor domainDescriptor = new BundleDescriptor.Builder().setArtifactId(DOMAIN_NAME).setGroupId("test").setVersion("1.0.0").setClassifier(MULE_DOMAIN_CLASSIFIER).build();
    Set<BundleDependency> domainDependency = Collections.singleton(new BundleDependency.Builder().setDescriptor(domainDescriptor).build());
    return new ClassLoaderModel.ClassLoaderModelBuilder().dependingOn(domainDependency).build();
}
Also used : BundleDescriptor(org.mule.runtime.module.artifact.api.descriptor.BundleDescriptor) BundleDependency(org.mule.runtime.module.artifact.api.descriptor.BundleDependency)

Example 3 with BundleDescriptor

use of org.mule.runtime.module.artifact.api.descriptor.BundleDescriptor in project mule by mulesoft.

the class RepositorySystemTestCase method noExistentResource.

@Test
public void noExistentResource() throws Exception {
    executeTestWithDefaultRemoteRepo(() -> {
        RepositoryService defaultRepositoryService = new RepositoryServiceFactory().createRepositoryService();
        BundleDescriptor bundleDescriptor = new BundleDescriptor.Builder().setGroupId("no").setArtifactId("existent").setVersion("bundle").build();
        expectedException.expect(BundleNotFoundException.class);
        defaultRepositoryService.lookupBundle(new BundleDependency.Builder().setDescriptor(bundleDescriptor).build());
    });
}
Also used : BundleDescriptor(org.mule.runtime.module.artifact.api.descriptor.BundleDescriptor) BundleDependency(org.mule.runtime.module.artifact.api.descriptor.BundleDependency) RepositoryService(org.mule.runtime.module.repository.api.RepositoryService) Test(org.junit.Test)

Example 4 with BundleDescriptor

use of org.mule.runtime.module.artifact.api.descriptor.BundleDescriptor in project mule by mulesoft.

the class BundlePluginDependenciesResolver method resolvePluginsDependencies.

private List<ArtifactPluginDescriptor> resolvePluginsDependencies(List<ArtifactPluginDescriptor> descriptors) {
    Set<BundleDescriptor> knownPlugins = descriptors.stream().map(ArtifactPluginDescriptor::getBundleDescriptor).collect(toSet());
    descriptors = getArtifactsWithDependencies(descriptors, knownPlugins);
    List<ArtifactPluginDescriptor> sortedDescriptors = new ArrayList<>(descriptors);
    sortedDescriptors.sort((d1, d2) -> (d1.getName().compareTo(d2.getName())));
    List<ArtifactPluginDescriptor> resolvedPlugins = new LinkedList<>();
    List<ArtifactPluginDescriptor> unresolvedPlugins = new LinkedList<>(sortedDescriptors);
    boolean continueResolution = true;
    while (continueResolution) {
        int initialResolvedCount = resolvedPlugins.size();
        List<ArtifactPluginDescriptor> pendingUnresolvedPlugins = new LinkedList<>();
        for (ArtifactPluginDescriptor unresolvedPlugin : unresolvedPlugins) {
            if (isResolvedPlugin(unresolvedPlugin, resolvedPlugins)) {
                sanitizeExportedPackages(unresolvedPlugin, resolvedPlugins);
                resolvedPlugins.add(unresolvedPlugin);
            } else {
                pendingUnresolvedPlugins.add(unresolvedPlugin);
            }
        }
        // Will try to resolve the plugins that are still unresolved
        unresolvedPlugins = pendingUnresolvedPlugins;
        continueResolution = resolvedPlugins.size() > initialResolvedCount;
    }
    if (unresolvedPlugins.size() != 0) {
        throw new PluginResolutionError(createResolutionErrorMessage(unresolvedPlugins, resolvedPlugins));
    }
    return resolvedPlugins;
}
Also used : BundleDescriptor(org.mule.runtime.module.artifact.api.descriptor.BundleDescriptor) ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList)

Aggregations

BundleDescriptor (org.mule.runtime.module.artifact.api.descriptor.BundleDescriptor)4 Test (org.junit.Test)2 ArtifactPluginDescriptor (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor)2 BundleDependency (org.mule.runtime.module.artifact.api.descriptor.BundleDependency)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 ClassLoaderModelBuilder (org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel.ClassLoaderModelBuilder)1 RepositoryService (org.mule.runtime.module.repository.api.RepositoryService)1