aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-maven-plugin
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-04-15 13:53:33 +0200
committerJon Marius Venstad <venstad@gmail.com>2020-04-15 13:53:33 +0200
commit0cc3fd1664b0d177a44c3c98f27463e7e2c24944 (patch)
tree2f43faca6d33804a7f86d5a8519a3cde2656f24f /vespa-maven-plugin
parent43f1f598ad89f7a787a311ddb8a4e86dc0958055 (diff)
Use relevant application/instance/deployment names in mojos
Diffstat (limited to 'vespa-maven-plugin')
-rw-r--r--vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaDeploymentMojo.java16
-rw-r--r--vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java5
2 files changed, 17 insertions, 4 deletions
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaDeploymentMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaDeploymentMojo.java
index d9ac88c6ff4..f9c07d29ee1 100644
--- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaDeploymentMojo.java
+++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaDeploymentMojo.java
@@ -12,6 +12,8 @@ import org.apache.maven.plugins.annotations.Parameter;
*/
public abstract class AbstractVespaDeploymentMojo extends AbstractVespaMojo {
+ protected ZoneId zone;
+
@Parameter(property = "environment")
protected String environment;
@@ -20,13 +22,21 @@ public abstract class AbstractVespaDeploymentMojo extends AbstractVespaMojo {
protected ZoneId zoneOf(String environment, String region) {
if (region == null)
- return controller.defaultZone(environment != null ? Environment.from(environment)
- : Environment.dev);
+ return zone = controller.defaultZone(environment != null ? Environment.from(environment)
+ : Environment.dev);
if (environment == null)
throw new IllegalArgumentException("Environment must be specified if region is specified");
- return ZoneId.from(environment, region);
+ return zone = ZoneId.from(environment, region);
+ }
+
+ @Override
+ protected String name() {
+ return super.name() + "." + instance + " in " +
+ (zone != null ? zone.region() + " in " + zone.environment()
+ : (region == null ? "default region" : region) + " in " +
+ (environment == null ? "default environment (dev)" : environment));
}
}
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java
index 8602d89c90c..0adb139f2c1 100644
--- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java
+++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java
@@ -63,13 +63,16 @@ public abstract class AbstractVespaMojo extends AbstractMojo {
throw e;
}
catch (Exception e) {
- throw new MojoExecutionException("Execution failed for application '" + id + "':", e);
+ throw new MojoExecutionException("Execution failed for application " + name() + ":", e);
}
}
/** Override this in subclasses, instead of {@link #execute()}. */
protected abstract void doExecute() throws Exception;
+ /** Return the name of the relevant entity, e.g., application with or without instance. */
+ protected String name() { return tenant + "." + application; }
+
protected void setup() {
tenant = firstNonBlank(tenant, project.getProperties().getProperty("tenant"));
application = firstNonBlank(application, project.getProperties().getProperty("application"));