Search in sources :

Example 1 with ClassLoaderModel

use of org.mule.tools.api.classloader.model.ClassLoaderModel 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 ClassLoaderModel

use of org.mule.tools.api.classloader.model.ClassLoaderModel 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)

Aggregations

LinkedList (java.util.LinkedList)2 AbstractDependencyFileBuilder (org.mule.runtime.module.artifact.builder.AbstractDependencyFileBuilder)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 File (java.io.File)1 Path (java.nio.file.Path)1 ClassLoaderModelJsonSerializer.serializeToFile (org.mule.tools.api.classloader.ClassLoaderModelJsonSerializer.serializeToFile)1