Search in sources :

Example 1 with MuleVersion

use of org.mule.runtime.api.meta.MuleVersion in project mule by mulesoft.

the class VersionFormatArtifactDescriptorValidator method doValidate.

private void doValidate(ArtifactDescriptor descriptor) {
    String bundleDescriptorVersion = descriptor.getBundleDescriptor().getVersion();
    checkState(bundleDescriptorVersion != null, format("No version specified in the bundle descriptor of the artifact %s", descriptor.getName()));
    MuleVersion artifactVersion = new MuleVersion(bundleDescriptorVersion);
    checkState(artifactVersion.getRevision() != NO_REVISION, format("Artifact %s version %s must contain a revision number. The version format must be x.y.z and the z part is missing", descriptor.getName(), artifactVersion));
}
Also used : MuleVersion(org.mule.runtime.api.meta.MuleVersion)

Example 2 with MuleVersion

use of org.mule.runtime.api.meta.MuleVersion in project mule by mulesoft.

the class DeployableArtifactDescriptorFactoryTestCase method loadsDescriptorFromJson.

@Test
public void loadsDescriptorFromJson() throws Exception {
    String artifactPath = getArtifactRootFolder() + "no-dependencies";
    D desc = createArtifactDescriptor(artifactPath);
    assertThat(desc.getMinMuleVersion(), is(new MuleVersion("4.0.0")));
    assertThat(desc.getConfigResources(), hasSize(1));
    assertThat(desc.getConfigResources(), hasItem(getDefaultConfigurationResourceLocation()));
    ClassLoaderModel classLoaderModel = desc.getClassLoaderModel();
    assertThat(classLoaderModel.getDependencies().isEmpty(), is(true));
    assertThat(classLoaderModel.getUrls().length, is(1));
    assertThat(toFile(classLoaderModel.getUrls()[0]).getPath(), is(getArtifact(artifactPath).getAbsolutePath()));
    assertThat(classLoaderModel.getExportedPackages().isEmpty(), is(true));
    assertThat(classLoaderModel.getExportedResources().isEmpty(), is(true));
    assertThat(classLoaderModel.getDependencies().isEmpty(), is(true));
}
Also used : MuleVersion(org.mule.runtime.api.meta.MuleVersion) ClassLoaderModel(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel) Test(org.junit.Test)

Example 3 with MuleVersion

use of org.mule.runtime.api.meta.MuleVersion in project mule by mulesoft.

the class AbstractArtifactDescriptorFactory method loadFromJsonDescriptor.

/**
 * Loads a descriptor from an artifact model
 *
 * @param artifactLocation folder where the artifact is located, it can be a folder or file depending on the artifact type.
 * @param artifactModel model representing the artifact.
 * @return a descriptor matching the provided model.
 */
protected final T loadFromJsonDescriptor(File artifactLocation, M artifactModel, Optional<Properties> deploymentProperties) {
    artifactModel.validateModel(artifactLocation.getName());
    BundleDescriptor bundleDescriptor = getBundleDescriptor(artifactLocation, artifactModel);
    final T descriptor = createArtifactDescriptor(artifactLocation, artifactModel.getName(), deploymentProperties);
    if (artifactLocation.isDirectory()) {
        descriptor.setRootFolder(artifactLocation);
    }
    descriptor.setBundleDescriptor(bundleDescriptor);
    descriptor.setMinMuleVersion(new MuleVersion(artifactModel.getMinMuleVersion()));
    descriptor.setRequiredProduct(artifactModel.getRequiredProduct());
    ClassLoaderModel classLoaderModel = getClassLoaderModel(artifactLocation, artifactModel.getClassLoaderModelLoaderDescriptor());
    descriptor.setClassLoaderModel(classLoaderModel);
    doDescriptorConfig(artifactModel, descriptor, artifactLocation);
    artifactDescriptorValidator.validate(descriptor);
    return descriptor;
}
Also used : MuleVersion(org.mule.runtime.api.meta.MuleVersion)

Example 4 with MuleVersion

use of org.mule.runtime.api.meta.MuleVersion in project mule by mulesoft.

the class MinMuleVersionArtifactDescriptorValidator method validate.

@Override
public void validate(ArtifactDescriptor descriptor) {
    MuleVersion minMuleVersion = descriptor.getMinMuleVersion();
    MuleVersion runtimeVersion = new MuleVersion(muleRuntimeVersionSupplier.get());
    runtimeVersion = new MuleVersion(runtimeVersion.toCompleteNumericVersion().replace("-" + runtimeVersion.getSuffix(), ""));
    if (validateMinMuleVersionWithSemanticVersion) {
        minMuleVersion = toBaseVersion(minMuleVersion);
        runtimeVersion = toBaseVersion(runtimeVersion);
    }
    doValidation(descriptor, minMuleVersion, runtimeVersion);
}
Also used : MuleVersion(org.mule.runtime.api.meta.MuleVersion)

Aggregations

MuleVersion (org.mule.runtime.api.meta.MuleVersion)4 Test (org.junit.Test)1 ClassLoaderModel (org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel)1