summaryrefslogtreecommitdiffstats
path: root/vespa-maven-plugin
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-05-07 12:01:18 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-05-07 12:02:22 +0200
commitcdc7f4c72c367fb368a26058aa39b678714b2b4e (patch)
treea21d9c4cc1d99abe9f17d2b9c3256e119b0c38b3 /vespa-maven-plugin
parent01155d5d23f2dbc4589b9860df26ebf29aaf90fc (diff)
Add DeployMojo
Diffstat (limited to 'vespa-maven-plugin')
-rw-r--r--vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java58
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());
+ }
+
+}