use of org.mule.runtime.deployment.model.api.artifact.ArtifactDescriptorConstants.EXPORTED_PACKAGES in project mule by mulesoft.
the class AbstractMavenClassLoaderModelLoader method createHeavyPackageClassLoaderModel.
private ClassLoaderModel createHeavyPackageClassLoaderModel(File artifactFile, Map<String, Object> attributes) {
File classLoaderModelDescriptor = getClassLoaderModelDescriptor(artifactFile);
org.mule.tools.api.classloader.model.ClassLoaderModel packagerClassLoaderModel = deserialize(classLoaderModelDescriptor);
File deployableArtifactRepositoryFolder = getDeployableArtifactRepositoryFolder(artifactFile);
final ClassLoaderModel.ClassLoaderModelBuilder classLoaderModelBuilder = new ClassLoaderModel.ClassLoaderModelBuilder();
classLoaderModelBuilder.exportingPackages(new HashSet<>(getAttribute(attributes, EXPORTED_PACKAGES))).exportingPrivilegedPackages(new HashSet<>(getAttribute(attributes, PRIVILEGED_EXPORTED_PACKAGES)), new HashSet<>(getAttribute(attributes, PRIVILEGED_ARTIFACTS_IDS))).exportingResources(new HashSet<>(getAttribute(attributes, EXPORTED_RESOURCES)));
Set<BundleDependency> patchBundleDependencies = getPatchedBundledDependencies(artifactFile, deployableArtifactRepositoryFolder);
Set<BundleDependency> bundleDependencies = packagerClassLoaderModel.getDependencies().stream().map(artifact -> {
Optional<BundleDependency> patchedBundledDependency = patchBundleDependencies.stream().filter(bundleDependency -> bundleDependency.getDescriptor().getGroupId().equals(artifact.getArtifactCoordinates().getGroupId()) && bundleDependency.getDescriptor().getArtifactId().equals(artifact.getArtifactCoordinates().getArtifactId())).findAny();
return patchedBundledDependency.orElse(createBundleDependencyFromPackagerDependency(deployableArtifactRepositoryFolder).apply(artifact));
}).collect(toSet());
loadUrls(artifactFile, classLoaderModelBuilder, bundleDependencies);
classLoaderModelBuilder.dependingOn(bundleDependencies);
return classLoaderModelBuilder.build();
}
use of org.mule.runtime.deployment.model.api.artifact.ArtifactDescriptorConstants.EXPORTED_PACKAGES in project mule by mulesoft.
the class AbstractMavenClassLoaderModelLoader method createLightPackageClassLoaderModel.
private ClassLoaderModel createLightPackageClassLoaderModel(File artifactFile, Map<String, Object> attributes, ArtifactType artifactType) {
File containerRepository;
if (isStandalone() && !getBoolean("mule.mode.embedded")) {
containerRepository = new File(getMuleHomeFolder(), "repository");
if (!containerRepository.exists()) {
if (!containerRepository.mkdirs()) {
// check again since it may have been created already.
if (!containerRepository.exists()) {
throw new MuleRuntimeException(I18nMessageFactory.createStaticMessage("Failure creating repository folder in MULE_HOME folder " + containerRepository.getAbsolutePath()));
}
}
}
}
File localMavenRepositoryLocation = mavenClient.getMavenConfiguration().getLocalMavenRepositoryLocation();
Supplier<File> compositeRepoLocationSupplier = localRepositorySupplierFactory.composeSuppliers(localRepositorySupplierFactory.artifactFolderRepositorySupplier(artifactFile, localMavenRepositoryLocation), localRepositorySupplierFactory.fixedFolderSupplier(localMavenRepositoryLocation));
File mavenRepository = compositeRepoLocationSupplier.get();
File temporaryDirectory = createTempDir();
try {
List<org.mule.maven.client.api.model.BundleDependency> dependencies = mavenClient.resolveArtifactDependencies(artifactFile, includeTestDependencies(attributes), includeProvidedDependencies(artifactType), of(mavenRepository), ofNullable((MavenReactorResolver) attributes.get(CLASSLOADER_MODEL_MAVEN_REACTOR_RESOLVER)), of(temporaryDirectory));
final ClassLoaderModel.ClassLoaderModelBuilder classLoaderModelBuilder = new ClassLoaderModel.ClassLoaderModelBuilder();
classLoaderModelBuilder.exportingPackages(new HashSet<>(getAttribute(attributes, EXPORTED_PACKAGES))).exportingPrivilegedPackages(new HashSet<>(getAttribute(attributes, PRIVILEGED_EXPORTED_PACKAGES)), new HashSet<>(getAttribute(attributes, PRIVILEGED_ARTIFACTS_IDS))).exportingResources(new HashSet<>(getAttribute(attributes, EXPORTED_RESOURCES))).includeTestDependencies(valueOf(getSimpleAttribute(attributes, INCLUDE_TEST_DEPENDENCIES, "false")));
Set<BundleDependency> bundleDependencies = dependencies.stream().filter(mavenClientDependency -> !mavenClientDependency.getScope().equals(PROVIDED)).map(mavenClientDependency -> convertBundleDependency(mavenClientDependency)).collect(toSet());
loadUrls(artifactFile, classLoaderModelBuilder, bundleDependencies);
Set<BundleDependency> allBundleDependencies = dependencies.stream().map(mavenClientDependency -> convertBundleDependency(mavenClientDependency)).collect(toSet());
classLoaderModelBuilder.dependingOn(allBundleDependencies);
return classLoaderModelBuilder.build();
} finally {
deleteQuietly(temporaryDirectory);
}
}
Aggregations