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