From 0cc3fd1664b0d177a44c3c98f27463e7e2c24944 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Wed, 15 Apr 2020 13:53:33 +0200 Subject: Use relevant application/instance/deployment names in mojos --- .../vespa/hosted/plugin/AbstractVespaDeploymentMojo.java | 16 +++++++++++++--- .../java/ai/vespa/hosted/plugin/AbstractVespaMojo.java | 5 ++++- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'vespa-maven-plugin') 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")); -- cgit v1.2.3