View Javadoc
1   package org.codehaus.mojo.wagon;
2   
3   import org.apache.maven.plugin.AbstractMojo;
4   import org.apache.maven.plugin.MojoExecutionException;
5   import org.apache.maven.plugins.annotations.Component;
6   import org.apache.maven.plugins.annotations.Parameter;
7   import org.apache.maven.project.MavenProject;
8   import org.apache.maven.settings.Settings;
9   import org.apache.maven.wagon.Wagon;
10  import org.codehaus.mojo.wagon.shared.WagonFactory;
11  import org.codehaus.mojo.wagon.shared.WagonFileSet;
12  import org.codehaus.mojo.wagon.shared.WagonUtils;
13  
14  /**
15   * Provides base functionality for dealing with I/O using wagon.
16   */
17  public abstract class AbstractWagonMojo
18      extends AbstractMojo
19  {
20  
21      @Component
22      protected WagonFactory wagonFactory;
23  
24      /**
25       * The current user system settings for use in Maven.
26       */
27      @Parameter( defaultValue = "${settings}", readonly = true )
28      protected Settings settings;
29  
30      /**
31       * Internal Maven's project.
32       */
33      @Parameter( defaultValue = "${project}", readonly = true )
34      protected MavenProject project;
35  
36      /**
37       * When <code>true</code>, skip the execution.
38       * @since 2.0.0
39       */
40      @Parameter( property = "wagon.skip" )
41      protected boolean skip = false;
42  
43      /////////////////////////////////////////////////////////////////////////
44  
45      protected Wagon createWagon( String id, String url )
46          throws MojoExecutionException
47      {
48          try
49          {
50              return wagonFactory.create( url, id, settings );
51          }
52          catch ( Exception e )
53          {
54              throw new MojoExecutionException( "Unable to create a Wagon instance for " + url, e );
55          }
56  
57      }
58  
59      protected WagonFileSet getWagonFileSet( String fromDir, String includes, String excludes, boolean caseSensitive,
60                                              String toDir )
61      {
62          return WagonUtils.getWagonFileSet( fromDir, includes, excludes, caseSensitive, toDir );
63      }
64  }