diff options
Diffstat (limited to 'vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java')
-rw-r--r-- | vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java new file mode 100644 index 00000000000..9a2c65ef86e --- /dev/null +++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java @@ -0,0 +1,58 @@ +package ai.vespa.hosted.plugin; + +import ai.vespa.hosted.api.Deployment; +import com.yahoo.config.provision.zone.ZoneId; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + +import java.nio.file.Paths; + +/** + * Deploys a Vespa application package to the hosted Vespa API. + * + * @author jonmv + */ +@Mojo(name = "deploy") +public class DeployMojo extends AbstractVespaMojo { + + @Parameter(property = "applicationZip") + private String applicationZip; + + @Parameter(property = "vespaVersion") + private String vespaVersion; + + @Parameter(property = "ignoreValidationErrors") + private String ignoreValidationErrors; + + @Parameter(property = "environment") + private String environment; + + @Parameter(property = "region") + private String region; + + @Parameter(property = "repository") + private String repository; + + @Parameter(property = "branch") + private String branch; + + @Parameter(property = "commit") + private String commit; + + @Parameter(property = "build") + private Long build; + + @Override + protected void doExecute() { + Deployment deployment = build == null + ? Deployment.ofPackage(Paths.get(firstNonBlank(applicationZip, projectPathOf("target", "application.zip")))) + : Deployment.ofReference(repository, branch, commit, build); + if ("true".equalsIgnoreCase(ignoreValidationErrors)) deployment = deployment.ignoringValidationErrors(); + if (vespaVersion != null) deployment = deployment.atVersion(vespaVersion); + + ZoneId zone = environment == null || region == null ? controller.devZone() : ZoneId.from(environment, region); + + System.out.println(controller.deploy(deployment, id, zone).json()); + } + +} |