1   package com.atlassian.maven.plugins.amps;
2   
3   import com.atlassian.maven.plugins.amps.product.ProductHandlerFactory;
4   import org.apache.maven.plugin.MojoExecutionException;
5   import org.jfrog.maven.annomojo.annotations.MojoParameter;
6   
7   public abstract class AbstractProductAwareMojo extends AbstractAmpsMojo
8   {
9       /**
10       * Product id
11       */
12      @MojoParameter(expression = "${product}")
13      private String product;
14  
15      protected String getDefaultProductId() throws MojoExecutionException
16      {
17          return null;
18      }
19  
20      protected final String getProductId() throws MojoExecutionException
21      {
22          if (product == null)
23          {
24              product = getDefaultProductId();
25              if (product == null && ProductHandlerFactory.getIds().contains(getPluginInformation().getId()))
26              {
27                  product = getPluginInformation().getId();
28              }
29              else if (product == null)
30              {
31                  product = ProductHandlerFactory.REFAPP;
32              }
33          }
34          return product;
35      }
36  }