use of org.mule.runtime.module.extension.internal.loader.java.property.LicenseModelProperty in project mule by mulesoft.
the class MulePluginDescriptorGenerator method generateResource.
/**
* {@inheritDoc}
*/
@Override
public Optional<GeneratedResource> generateResource(ExtensionModel extensionModel) {
final Optional<ExtensionTypeDescriptorModelProperty> typeProperty = extensionModel.getModelProperty(ExtensionTypeDescriptorModelProperty.class);
if (!typeProperty.isPresent()) {
return empty();
}
final ExportedArtifactsCollector exportCollector = new ExportedArtifactsCollector(extensionModel, new DefaultClassPackageFinder(processingEnvironment));
final MulePluginModelBuilder builder = new MulePluginModelBuilder();
// Set only for testing purposes, the value will be reset by the plugin packager.
builder.setName(extensionModel.getName());
builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().setId(MULE_LOADER_ID).addProperty(EXPORTED_PACKAGES, exportCollector.getExportedPackages()).addProperty(EXPORTED_RESOURCES, exportCollector.getExportedResources()).addProperty(PRIVILEGED_EXPORTED_PACKAGES, exportCollector.getPrivilegedExportedPackages()).addProperty(PRIVILEGED_ARTIFACTS_IDS, exportCollector.getPrivilegedArtifacts()).build());
builder.withExtensionModelDescriber().setId(getLoaderId(extensionModel)).addProperty(TYPE_PROPERTY_NAME, typeProperty.get().getType().getTypeName()).addProperty("version", extensionModel.getVersion());
builder.withBundleDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
final Optional<LicenseModelProperty> licenseModelPropertyOptional = extensionModel.getModelProperty(LicenseModelProperty.class);
builder.setRequiredProduct(extensionModel.getCategory().equals(COMMUNITY) ? MULE : MULE_EE);
licenseModelPropertyOptional.ifPresent(licenseModelProperty -> {
builder.setRequiredProduct(licenseModelProperty.requiresEeLicense() ? MULE_EE : MULE);
if (licenseModelProperty.requiresEeLicense()) {
builder.withLicenseModel().setAllowsEvaluationLicense(licenseModelProperty.isAllowsEvaluationLicense());
licenseModelProperty.getRequiredEntitlement().ifPresent(requiredEntitlement -> builder.withLicenseModel().setProvider(extensionModel.getVendor()).setRequiredEntitlement(requiredEntitlement));
}
});
final String descriptorJson = new MulePluginModelJsonSerializer().serialize(builder.build());
return of(new GeneratedResource(AUTO_GENERATED_MULE_ARTIFACT_DESCRIPTOR, descriptorJson.getBytes()));
}
use of org.mule.runtime.module.extension.internal.loader.java.property.LicenseModelProperty in project mule by mulesoft.
the class DefaultJavaModelLoaderDelegate method processLicenseRequirements.
private void processLicenseRequirements(ExtensionDeclarer declarer) {
Optional<RequiresEntitlement> requiresEntitlementOptional = extensionElement.getAnnotation(RequiresEntitlement.class);
Optional<RequiresEnterpriseLicense> requiresEnterpriseLicenseOptional = extensionElement.getAnnotation(RequiresEnterpriseLicense.class);
boolean requiresEnterpriseLicense = requiresEnterpriseLicenseOptional.isPresent();
boolean allowsEvaluationLicense = requiresEnterpriseLicenseOptional.map(RequiresEnterpriseLicense::allowEvaluationLicense).orElse(true);
Optional<String> requiredEntitlement = requiresEntitlementOptional.map(RequiresEntitlement::name);
declarer.withModelProperty(new LicenseModelProperty(requiresEnterpriseLicense, allowsEvaluationLicense, requiredEntitlement));
}
Aggregations