View Javadoc

1   package org.codehaus.mojo.wagon;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
5    * agreements. See the NOTICE file distributed with this work for additional information regarding
6    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance with the License. You may obtain a
8    * copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software distributed under the License
13   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14   * or implied. See the License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  
18  import org.apache.maven.artifact.manager.WagonManager;
19  import org.apache.maven.plugin.AbstractMojo;
20  import org.apache.maven.plugin.MojoExecutionException;
21  import org.apache.maven.project.MavenProject;
22  import org.apache.maven.settings.Settings;
23  import org.apache.maven.wagon.Wagon;
24  import org.codehaus.mojo.wagon.shared.WagonFileSet;
25  import org.codehaus.mojo.wagon.shared.WagonUtils;
26  
27  /**
28   * Provides base functionality for dealing with I/O using wagon.
29   *
30   */
31  public abstract class AbstractWagonMojo extends AbstractMojo {
32  
33      /**
34       * @component
35       */
36      protected WagonManager wagonManager;
37  
38      /**
39       * The current user system settings for use in Maven.
40       *
41       * @parameter expression="${settings}"
42       * @readonly
43       */
44      protected Settings settings;
45  
46      /**
47       * Internal Maven's project
48       *
49       * @parameter expression="${project}"
50       * @readonly
51       */
52      protected MavenProject project;
53  
54      /**
55       * When <code>true</code>, skip the execution.
56       *
57       * @parameter expression="${wagon.skip}" default-value="false"
58       */
59      protected boolean skip = false;
60  
61      /**
62       * Convenient method to create a wagon
63       *
64       * @param id
65       * @param url
66       * @param wagonManager
67       * @param settings
68       * @param logger
69       * @return
70       * @throws MojoExecutionException
71       */
72      protected Wagon createWagon(String id, String url) throws MojoExecutionException {
73          try {
74              return WagonUtils.createWagon(id, url, wagonManager, settings, this.getLog());
75          } catch (Exception e) {
76              throw new MojoExecutionException("Unable to create a Wagon instance for " + url, e);
77          }
78  
79      }
80  
81      protected WagonFileSet getWagonFileSet(String fromDir, String includes, String excludes, boolean caseSensitive,
82              String toDir) {
83          return WagonUtils.getWagonFileSet(fromDir, includes, excludes, caseSensitive, toDir);
84      }
85  
86  }