Search in sources :

Example 6 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class DomainFileBuilder method definedBy.

/**
 * Sets the configuration file used for the domain.
 *
 * @param configFile domain configuration from a external file or test resource. Non empty.
 * @return the same builder instance
 */
public DomainFileBuilder definedBy(String configFile) {
    checkImmutable();
    checkArgument(!StringUtils.isEmpty(configFile), "Config file cannot be empty");
    this.resources.add(new ZipResource(configFile, DEFAULT_CONFIGURATION_RESOURCE));
    return this;
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource)

Example 7 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class AbstractArtifactFileBuilder method containingResource.

/**
 * Adds a resource file to the plugin root folder.
 *
 * @param resourceFile resource file from a external file or test resource.
 * @return the same builder instance
 */
public T containingResource(String resourceFile, String alias) {
    checkImmutable();
    checkArgument(!isEmpty(resourceFile), "Resource file cannot be empty");
    resources.add(new ZipResource(resourceFile, alias));
    return getThis();
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource)

Example 8 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class AbstractArtifactFileBuilder method usingLibrary.

/**
 * Adds a jar file to the artifact lib folder.
 *
 * @param jarFile jar file from a external file or test resource.
 * @return the same builder instance
 */
public T usingLibrary(String jarFile) {
    checkImmutable();
    checkArgument(!isEmpty(jarFile), "Jar file cannot be empty");
    resources.add(new ZipResource(jarFile, "lib/" + getName(jarFile)));
    return getThis();
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource)

Example 9 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class AbstractArtifactFileBuilder method containingClass.

/**
 * Adds a class file to the artifact classes folder.
 *
 * @param classFile class file to include. Non null.
 * @param alias path where the file must be added inside the app file
 * @return the same builder instance
 */
public T containingClass(File classFile, String alias) {
    checkImmutable();
    checkArgument(classFile != null, "Class file cannot be null");
    resources.add(new ZipResource(classFile.getAbsolutePath(), alias));
    return getThis();
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource)

Example 10 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class AbstractArtifactFileBuilder method getArtifactFile.

@Override
public File getArtifactFile() {
    if (artifactFile == null) {
        String fileName = getArtifactFileName();
        final File tempFile = new File(getTempFolder(), fileName);
        tempFile.deleteOnExit();
        if (corrupted) {
            buildBrokenJarFile(tempFile);
        } else {
            final List<ZipResource> zipResources = new LinkedList<>(resources);
            zipResources.add(new ZipResource(getArtifactPomFile().getAbsolutePath(), getArtifactFileBundledPomPath()));
            zipResources.addAll(getCustomResources());
            compress(tempFile, zipResources.toArray(new ZipResource[0]));
        }
        artifactFile = new File(tempFile.getAbsolutePath());
    }
    return artifactFile;
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource) File(java.io.File) LinkedList(java.util.LinkedList)

Aggregations

ZipResource (org.mule.tck.ZipUtils.ZipResource)17 File (java.io.File)10 LinkedList (java.util.LinkedList)5 Test (org.junit.Test)4 FileUtils.readFileToString (org.apache.commons.io.FileUtils.readFileToString)3 FileUtils.writeStringToFile (org.apache.commons.io.FileUtils.writeStringToFile)3 IOException (java.io.IOException)2 MuleArtifactLoaderDescriptor (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor)1 MuleArtifactLoaderDescriptorBuilder (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder)1 MulePluginModel (org.mule.runtime.api.deployment.meta.MulePluginModel)1 MulePluginModelJsonSerializer (org.mule.runtime.api.deployment.persistence.MulePluginModelJsonSerializer)1 MulePolicyModelJsonSerializer (org.mule.runtime.api.deployment.persistence.MulePolicyModelJsonSerializer)1