1   package org.apache.maven.plugin.testing;
2   
3   import org.apache.maven.artifact.repository.ArtifactRepository;
4   import org.apache.maven.plugin.AbstractMojo;
5   import org.apache.maven.plugin.MojoExecutionException;
6   import org.apache.maven.plugin.MojoFailureException;
7   import org.codehaus.plexus.util.StringUtils;
8   
9   /**
10   * @author Edwin Punzalan
11   */
12  public class ExpressionEvaluatorMojo
13      extends AbstractMojo
14  {
15      private String basedir;
16  
17      private ArtifactRepository localRepository;
18  
19      private String workdir;
20  
21      public void execute()
22          throws MojoExecutionException, MojoFailureException
23      {
24          if ( StringUtils.isEmpty( basedir ) )
25          {
26              throw new MojoExecutionException( "basedir was not injected." );
27          }
28  
29          if ( localRepository == null )
30          {
31              throw new MojoExecutionException( "localRepository was not injected." );
32          }
33  
34          if ( StringUtils.isEmpty( workdir ) )
35          {
36              throw new MojoExecutionException( "workdir was not injected." );
37          }
38          else if ( !workdir.startsWith( basedir ) )
39          {
40              throw new MojoExecutionException( "workdir does not start with basedir." );
41          }
42      }
43  }