Search in sources :

Example 1 with AbstractDependencyFileBuilder

use of org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder 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());
}
Also used : Path(java.nio.file.Path) ArtifactCoordinates(org.mule.tools.api.classloader.model.ArtifactCoordinates) AbstractDependencyFileBuilder(org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder) ClassLoaderModel(org.mule.tools.api.classloader.model.ClassLoaderModel) Artifact(org.mule.tools.api.classloader.model.Artifact) LinkedList(java.util.LinkedList)

Example 2 with AbstractDependencyFileBuilder

use of org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder 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);
}
Also used : ArtifactCoordinates(org.mule.tools.api.classloader.model.ArtifactCoordinates) AbstractDependencyFileBuilder(org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder) ClassLoaderModelJsonSerializer.serializeToFile(org.mule.tools.api.classloader.ClassLoaderModelJsonSerializer.serializeToFile) File(java.io.File) ClassLoaderModel(org.mule.tools.api.classloader.model.ClassLoaderModel) Artifact(org.mule.tools.api.classloader.model.Artifact) LinkedList(java.util.LinkedList)

Example 3 with AbstractDependencyFileBuilder

use of org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder in project mule by mulesoft.

the class DeployableFileBuilder method getCustomResources.

@Override
protected final List<ZipUtils.ZipResource> getCustomResources() {
    final List<ZipUtils.ZipResource> customResources = new LinkedList<>();
    if (useHeavyPackage) {
        for (AbstractDependencyFileBuilder dependencyFileBuilder : getAllCompileDependencies()) {
            if (MULE_DOMAIN_CLASSIFIER.equals(dependencyFileBuilder.getClassifier())) {
                continue;
            }
            customResources.add(new ZipUtils.ZipResource(dependencyFileBuilder.getArtifactFile().getAbsolutePath(), Paths.get(REPOSITORY_FOLDER, dependencyFileBuilder.getArtifactFileRepositoryPath()).toString()));
            if (MULE_PLUGIN_CLASSIFIER.equals(dependencyFileBuilder.getClassifier())) {
                File pluginClassLoaderModel = createClassLoaderModelJsonFile(dependencyFileBuilder);
                customResources.add(new ZipUtils.ZipResource(pluginClassLoaderModel.getAbsolutePath(), Paths.get(REPOSITORY_FOLDER, dependencyFileBuilder.getArtifactFileRepositoryFolderPath(), CLASSLOADER_MODEL_JSON_DESCRIPTOR).toString()));
            } else {
                customResources.add(new ZipUtils.ZipResource(dependencyFileBuilder.getArtifactPomFile().getAbsolutePath(), Paths.get(REPOSITORY_FOLDER, dependencyFileBuilder.getArtifactFilePomRepositoryPath()).toString()));
            }
        }
        customResources.add(new ZipUtils.ZipResource(getClassLoaderModelFile().getAbsolutePath(), CLASSLOADER_MODEL_JSON_DESCRIPTOR_LOCATION));
    }
    customResources.addAll(doGetCustomResources());
    return customResources;
}
Also used : AbstractDependencyFileBuilder(org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder) ZipUtils(org.mule.tck.ZipUtils) ClassLoaderModelJsonSerializer.serializeToFile(org.mule.tools.api.classloader.ClassLoaderModelJsonSerializer.serializeToFile) File(java.io.File) LinkedList(java.util.LinkedList)

Example 4 with AbstractDependencyFileBuilder

use of org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder in project mule by mulesoft.

the class ServiceFileBuilder method getCustomResources.

@Override
protected final List<ZipUtils.ZipResource> getCustomResources() {
    final List<ZipUtils.ZipResource> customResources = new LinkedList<>();
    for (AbstractDependencyFileBuilder dependencyFileBuilder : getAllCompileDependencies()) {
        customResources.add(new ZipUtils.ZipResource(dependencyFileBuilder.getArtifactFile().getAbsolutePath(), Paths.get(REPOSITORY_FOLDER, dependencyFileBuilder.getArtifactFileRepositoryPath()).toString()));
        customResources.add(new ZipUtils.ZipResource(dependencyFileBuilder.getArtifactPomFile().getAbsolutePath(), Paths.get(REPOSITORY_FOLDER, dependencyFileBuilder.getArtifactFilePomRepositoryPath()).toString()));
    }
    File serviceDescriptor = createServiceJsonDescriptorFile();
    customResources.add(new ZipUtils.ZipResource(serviceDescriptor.getAbsolutePath(), MULE_ARTIFACT_JSON_DESCRIPTOR_LOCATION));
    return customResources;
}
Also used : AbstractDependencyFileBuilder(org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder) ZipUtils(org.mule.tck.ZipUtils) File(java.io.File) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)4 AbstractDependencyFileBuilder (org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder)4 File (java.io.File)3 ZipUtils (org.mule.tck.ZipUtils)2 ClassLoaderModelJsonSerializer.serializeToFile (org.mule.tools.api.classloader.ClassLoaderModelJsonSerializer.serializeToFile)2 Artifact (org.mule.tools.api.classloader.model.Artifact)2 ArtifactCoordinates (org.mule.tools.api.classloader.model.ArtifactCoordinates)2 ClassLoaderModel (org.mule.tools.api.classloader.model.ClassLoaderModel)2 Path (java.nio.file.Path)1