Search in sources :

Example 11 with ArtifactDescriptor

use of co.cask.cdap.internal.app.runtime.artifact.ArtifactDescriptor in project cdap by caskdata.

the class AppFabricTestHelper method deployApplicationWithManager.

public static ApplicationWithPrograms deployApplicationWithManager(Id.Namespace namespace, Class<?> appClass, Supplier<File> folderSupplier, Config config) throws Exception {
    ensureNamespaceExists(namespace.toEntityId());
    Location deployedJar = createAppJar(appClass, folderSupplier);
    ArtifactVersion artifactVersion = new ArtifactVersion(String.format("1.0.%d", System.currentTimeMillis()));
    ArtifactId artifactId = new ArtifactId(appClass.getSimpleName(), artifactVersion, ArtifactScope.USER);
    ArtifactDescriptor artifactDescriptor = new ArtifactDescriptor(artifactId, deployedJar);
    ArtifactRepository artifactRepository = getInjector().getInstance(ArtifactRepository.class);
    artifactRepository.addArtifact(Artifacts.toArtifactId(namespace.toEntityId(), artifactId).toId(), new File(deployedJar.toURI()));
    AppDeploymentInfo info = new AppDeploymentInfo(artifactDescriptor, namespace.toEntityId(), appClass.getName(), null, null, config == null ? null : new Gson().toJson(config));
    return getLocalManager().deploy(info).get();
}
Also used : ArtifactVersion(co.cask.cdap.api.artifact.ArtifactVersion) ArtifactId(co.cask.cdap.api.artifact.ArtifactId) AppDeploymentInfo(co.cask.cdap.internal.app.deploy.pipeline.AppDeploymentInfo) ArtifactDescriptor(co.cask.cdap.internal.app.runtime.artifact.ArtifactDescriptor) Gson(com.google.gson.Gson) ArtifactRepository(co.cask.cdap.internal.app.runtime.artifact.ArtifactRepository) File(java.io.File) Location(org.apache.twill.filesystem.Location)

Aggregations

ArtifactDescriptor (co.cask.cdap.internal.app.runtime.artifact.ArtifactDescriptor)11 ArtifactVersion (co.cask.cdap.api.artifact.ArtifactVersion)8 ArtifactId (co.cask.cdap.proto.id.ArtifactId)6 IOException (java.io.IOException)6 Test (org.junit.Test)6 ArtifactId (co.cask.cdap.api.artifact.ArtifactId)5 AppDeploymentInfo (co.cask.cdap.internal.app.deploy.pipeline.AppDeploymentInfo)5 Id (co.cask.cdap.proto.Id)4 NamespaceId (co.cask.cdap.proto.id.NamespaceId)4 File (java.io.File)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Location (org.apache.twill.filesystem.Location)4 PluginClass (co.cask.cdap.api.plugin.PluginClass)3 ArtifactDetail (co.cask.cdap.internal.app.runtime.artifact.ArtifactDetail)3 ConfigTestApp (co.cask.cdap.ConfigTestApp)2 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)2 Program (co.cask.cdap.app.program.Program)2 ProgramDescriptor (co.cask.cdap.app.program.ProgramDescriptor)2 ArtifactNotFoundException (co.cask.cdap.common.ArtifactNotFoundException)2