use of org.mule.tools.api.classloader.model.Artifact 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.tools.api.classloader.model.Artifact in project mule by mulesoft.
the class DeployableFileBuilder method createClassLoaderModelJsonFile.
private File createClassLoaderModelJsonFile(AbstractDependencyFileBuilder dependencyFileBuilder) {
ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(dependencyFileBuilder.getGroupId(), dependencyFileBuilder.getArtifactId(), dependencyFileBuilder.getVersion(), dependencyFileBuilder.getType(), dependencyFileBuilder.getClassifier());
ClassLoaderModel classLoaderModel = new ClassLoaderModel("1.0", artifactCoordinates);
List<Artifact> artifactDependencies = new LinkedList<>();
List<AbstractDependencyFileBuilder> dependencies = dependencyFileBuilder.getDependencies();
for (AbstractDependencyFileBuilder fileBuilderDependency : dependencies) {
artifactDependencies.add(getArtifact(fileBuilderDependency));
}
classLoaderModel.setDependencies(artifactDependencies);
Path repository = Paths.get(getTempFolder(), REPOSITORY_FOLDER, dependencyFileBuilder.getArtifactFileRepositoryFolderPath());
if (repository.toFile().exists()) {
repository.toFile().delete();
} else {
if (!repository.toFile().mkdirs()) {
throw new IllegalStateException("Cannot create artifact folder inside repository");
}
}
return serializeToFile(classLoaderModel, repository.toFile());
}
use of org.mule.tools.api.classloader.model.Artifact in project mule by mulesoft.
the class DeployableFileBuilder method getClassLoaderModelFile.
private File getClassLoaderModelFile() {
ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(getGroupId(), getArtifactId(), getVersion());
ClassLoaderModel classLoaderModel = new ClassLoaderModel("1.0", artifactCoordinates);
List<Artifact> artifactDependencies = new LinkedList<>();
for (AbstractDependencyFileBuilder fileBuilderDependency : getDependencies()) {
artifactDependencies.add(getArtifact(fileBuilderDependency));
}
classLoaderModel.setDependencies(artifactDependencies);
File destinationFolder = Paths.get(getTempFolder()).resolve(META_INF).resolve(MULE_ARTIFACT).toFile();
if (!destinationFolder.exists()) {
assertThat(destinationFolder.mkdirs(), is(true));
}
return serializeToFile(classLoaderModel, destinationFolder);
}
Aggregations