Search in sources :

Example 11 with BundleDependency

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

the class BundlePluginDependenciesResolverTestCase method createBundleDependency.

private static BundleDependency createBundleDependency(BundleDescriptor bundleDescriptor, boolean createBundleUri) {
    try {
        final BundleDependency.Builder builder = new BundleDependency.Builder();
        builder.setDescriptor(bundleDescriptor);
        builder.setScope(BundleScope.COMPILE);
        if (createBundleUri) {
            builder.setBundleUri(temporaryFolder.newFile(bundleDescriptor.getArtifactFileName()).toURI());
        }
        return builder.build();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : BundleDependency(org.mule.runtime.module.artifact.api.descriptor.BundleDependency) ClassLoaderModelBuilder(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel.ClassLoaderModelBuilder) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 12 with BundleDependency

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

the class BundlePluginDependenciesResolver method findDependencyPackageClosure.

private Set<String> findDependencyPackageClosure(Set<BundleDependency> pluginDependencies, List<ArtifactPluginDescriptor> resolvedPlugins) {
    Set<String> exportedPackages = new HashSet<>();
    for (BundleDependency pluginDependency : pluginDependencies) {
        final Optional<String> classifier = pluginDependency.getDescriptor().getClassifier();
        if (classifier.isPresent() && MULE_PLUGIN_CLASSIFIER.equals(classifier.get())) {
            ArtifactPluginDescriptor dependencyDescriptor = findArtifactPluginDescriptor(pluginDependency, resolvedPlugins);
            exportedPackages.addAll(dependencyDescriptor.getClassLoaderModel().getExportedPackages());
            exportedPackages.addAll(findDependencyPackageClosure(dependencyDescriptor.getClassLoaderModel().getDependencies(), resolvedPlugins));
        }
    }
    return exportedPackages;
}
Also used : ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) BundleDependency(org.mule.runtime.module.artifact.api.descriptor.BundleDependency) HashSet(java.util.HashSet)

Example 13 with BundleDependency

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

the class BundlePluginDependenciesResolver method createResolutionErrorMessage.

protected static String createResolutionErrorMessage(List<ArtifactPluginDescriptor> unresolvedPlugins, List<ArtifactPluginDescriptor> resolvedPlugins) {
    StringBuilder builder = new StringBuilder("Unable to resolve plugin dependencies:");
    for (ArtifactPluginDescriptor unresolvedPlugin : unresolvedPlugins) {
        builder.append("\nPlugin: ").append(unresolvedPlugin.getName()).append(" missing dependencies:");
        List<BundleDependency> missingDependencies = new ArrayList<>();
        for (BundleDependency dependency : unresolvedPlugin.getClassLoaderModel().getDependencies()) {
            Optional<String> classifierOptional = dependency.getDescriptor().getClassifier();
            if (classifierOptional.isPresent() && MULE_PLUGIN_CLASSIFIER.equals(classifierOptional.get())) {
                final ArtifactPluginDescriptor dependencyDescriptor = findArtifactPluginDescriptor(dependency, resolvedPlugins);
                if (dependencyDescriptor == null) {
                    missingDependencies.add(dependency);
                }
            }
        }
        builder.append(missingDependencies);
    }
    return builder.toString();
}
Also used : ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) BundleDependency(org.mule.runtime.module.artifact.api.descriptor.BundleDependency) ArrayList(java.util.ArrayList)

Aggregations

BundleDependency (org.mule.runtime.module.artifact.api.descriptor.BundleDependency)13 File (java.io.File)7 ClassLoaderModel (org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel)7 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 ArtifactPluginDescriptor (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor)5 List (java.util.List)4 Map (java.util.Map)4 Set (java.util.Set)4 Test (org.junit.Test)4 LocalRepositorySupplierFactory (org.mule.maven.client.api.LocalRepositorySupplierFactory)4 MavenClient (org.mule.maven.client.api.MavenClient)4 String.format (java.lang.String.format)3 MalformedURLException (java.net.MalformedURLException)3 Paths (java.nio.file.Paths)3 Optional (java.util.Optional)3 Model (org.apache.maven.model.Model)3 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)3 I18nMessageFactory (org.mule.runtime.api.i18n.I18nMessageFactory)3 ArtifactType (org.mule.runtime.core.api.config.bootstrap.ArtifactType)3