use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel 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);
}
}
use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel in project mule by mulesoft.
the class ApplicationStartedSplashScreenTestCase method setUp.
@Before
public void setUp() {
splashScreen = new ApplicationStartedSplashScreen();
ClassLoaderModel.ClassLoaderModelBuilder classLoaderModelBuilder = new ClassLoaderModel.ClassLoaderModelBuilder();
runtimeLibs.stream().forEach(classLoaderModelBuilder::containing);
ClassLoaderModel classLoaderModel = classLoaderModelBuilder.build();
ArtifactPluginDescriptor pluginDescriptor = new ArtifactPluginDescriptor(PLUGIN_NAME);
pluginDescriptor.setBundleDescriptor(new BundleDescriptor.Builder().setGroupId(PLUGIN_GROUP_ID).setArtifactId(PLUGIN_ARTIFACT_ID).setVersion(PLUGIN_VERSION).build());
when(descriptor.getName()).thenReturn(APP_NAME);
when(descriptor.getAppProperties()).thenReturn(new HashMap<>());
when(descriptor.getPlugins()).thenReturn(newHashSet(pluginDescriptor));
when(descriptor.getClassLoaderModel()).thenReturn(classLoaderModel);
}
use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel in project mule by mulesoft.
the class DeployableArtifactDescriptorFactoryTestCase method classLoaderModelWithIncludeTestDependencies.
@Test
public void classLoaderModelWithIncludeTestDependencies() throws Exception {
D desc = createArtifactDescriptor(getArtifactRootFolder() + "include-test-dependencies");
ClassLoaderModel classLoaderModel = desc.getClassLoaderModel();
assertThat(classLoaderModel.isIncludeTestDependencies(), is(true));
}
use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel in project mule by mulesoft.
the class DeployableArtifactDescriptorFactoryTestCase method classLoaderModelWithPluginDependency.
@Test
public void classLoaderModelWithPluginDependency() throws Exception {
D desc = createArtifactDescriptor(getArtifactRootFolder() + "plugin-dependency");
ClassLoaderModel classLoaderModel = desc.getClassLoaderModel();
assertThat(classLoaderModel.getDependencies().size(), is(1));
assertThat(classLoaderModel.getDependencies(), hasItem(socketsPluginDependencyMatcher()));
assertThat(classLoaderModel.getUrls().length, is(1));
assertThat(asList(classLoaderModel.getUrls()), not(hasItem(classLoaderModel.getDependencies().iterator().next())));
}
use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel in project mule by mulesoft.
the class DeployableArtifactDescriptorFactoryTestCase method classLoaderModelDefaultIncludeTestDependencies.
@Test
public void classLoaderModelDefaultIncludeTestDependencies() throws Exception {
D desc = createArtifactDescriptor(getArtifactRootFolder() + "custom-config-files");
ClassLoaderModel classLoaderModel = desc.getClassLoaderModel();
assertThat(classLoaderModel.isIncludeTestDependencies(), is(false));
}
Aggregations