Source:
private Application doCreateApplication(File toolingApplicationContent, Optional<Properties> deploymentProperties) throws IOException { Optional<Properties> mergedDeploymentProperties = of(createDeploymentProperties(deploymentProperties)); MuleApplicationModel.MuleApplicationModelBuilder applicationArtifactModelBuilder = applicationDescriptorFactory.createArtifactModelBuilder(toolingApplicationContent); String domainName = mergedDeploymentProperties.get().getProperty(DEPLOYMENT_DOMAIN_NAME_REF); if (domainName != null) { try { Domain domain = domainRepository.getDomain(createBundleDescriptorFromName(domainName)); MuleArtifactLoaderDescriptor classLoaderModelDescriptorLoader = applicationArtifactModelBuilder.getClassLoaderModelDescriptorLoader(); Map<String, Object> extendedAttributes = new HashMap<>(classLoaderModelDescriptorLoader.getAttributes()); Properties pomProperties = getPomPropertiesFolder(domain.getLocation()); extendedAttributes.put(CLASSLOADER_MODEL_MAVEN_REACTOR_RESOLVER, new DomainMavenReactorResolver(domain.getLocation(), new BundleDescriptor.Builder() .setGroupId(pomProperties.getProperty("groupId")) .setArtifactId(pomProperties.getProperty("artifactId")) .setVersion(pomProperties.getProperty("version")) .setClassifier(MULE_DOMAIN_CLASSIFIER) .build())); applicationArtifactModelBuilder .withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(classLoaderModelDescriptorLoader.getId(), extendedAttributes)); ApplicationDescriptor applicationDescriptor = applicationDescriptorFactory.createArtifact(toolingApplicationContent, mergedDeploymentProperties, applicationArtifactModelBuilder.build()); applicationDescriptor.setDomainName(domain.getArtifactName()); return new ToolingApplicationWrapper(doCreateApplication(applicationDescriptor)); } catch (DomainNotFoundException e) { throw new IllegalArgumentException(format("Domain '%s' is expected to be deployed", domainName), e); } catch (IncompatibleDomainVersionException e) { throw new IllegalArgumentException("Incompatible domain found", e); } } return new ToolingApplicationWrapper(doCreateApplication(applicationDescriptorFactory.create(toolingApplicationContent, mergedDeploymentProperties))); }

Target:
private Application doCreateApplication(File toolingApplicationContent, Optional<Properties> deploymentProperties) throws IOException { Optional<Properties> mergedDeploymentProperties = of(createDeploymentProperties(deploymentProperties)); MuleApplicationModel.MuleApplicationModelBuilder applicationArtifactModelBuilder = applicationDescriptorFactory.createArtifactModelBuilder(toolingApplicationContent); String domainName = mergedDeploymentProperties.get().getProperty(DEPLOYMENT_DOMAIN_NAME_REF); if (domainName != null) { try { Domain domain = domainRepository.getDomain(createBundleDescriptorFromName(domainName)); MuleArtifactLoaderDescriptor classLoaderModelDescriptorLoader = applicationArtifactModelBuilder.getClassLoaderModelDescriptorLoader(); Map<String, Object> extendedAttributes = new HashMap<>(classLoaderModelDescriptorLoader.getAttributes()); Properties pomProperties = getPomPropertiesFolder(domain.getLocation()); extendedAttributes.put(CLASSLOADER_MODEL_MAVEN_REACTOR_RESOLVER, new DomainMavenReactorResolver(domain.getLocation(), new BundleDescriptor.Builder() .setGroupId(pomProperties.getProperty(GROUP_ID)) .setArtifactId(pomProperties.getProperty(ARTIFACT_ID)) .setVersion(pomProperties.getProperty(VERSION)) .setClassifier(MULE_DOMAIN_CLASSIFIER) .build())); applicationArtifactModelBuilder .withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(classLoaderModelDescriptorLoader.getId(), extendedAttributes)); ApplicationDescriptor applicationDescriptor = applicationDescriptorFactory.createArtifact(toolingApplicationContent, mergedDeploymentProperties, applicationArtifactModelBuilder.build()); applicationDescriptor.setDomainName(domain.getArtifactName()); return new ToolingApplicationWrapper(doCreateApplication(applicationDescriptor)); } catch (DomainNotFoundException e) { throw new IllegalArgumentException(format("Domain '%s' is expected to be deployed", domainName), e); } catch (IncompatibleDomainVersionException e) { throw new IllegalArgumentException("Incompatible domain found", e); } } return new ToolingApplicationWrapper(doCreateApplication(applicationDescriptorFactory.create(toolingApplicationContent, mergedDeploymentProperties))); }