001 /**
002 * Copyright 2008-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.codehaus.mojo.wagon;
017
018 /*
019 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
020 * agreements. See the NOTICE file distributed with this work for additional information regarding
021 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
022 * "License"); you may not use this file except in compliance with the License. You may obtain a
023 * copy of the License at
024 *
025 * http://www.apache.org/licenses/LICENSE-2.0
026 *
027 * Unless required by applicable law or agreed to in writing, software distributed under the License
028 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
029 * or implied. See the License for the specific language governing permissions and limitations under
030 * the License.
031 */
032
033 import org.apache.maven.artifact.manager.WagonManager;
034 import org.apache.maven.plugin.AbstractMojo;
035 import org.apache.maven.plugin.MojoExecutionException;
036 import org.apache.maven.project.MavenProject;
037 import org.apache.maven.settings.Settings;
038 import org.apache.maven.wagon.Wagon;
039 import org.codehaus.mojo.wagon.shared.WagonFileSet;
040 import org.codehaus.mojo.wagon.shared.WagonUtils;
041
042 /**
043 * Provides base functionality for dealing with I/O using wagon.
044 *
045 */
046 public abstract class AbstractWagonMojo extends AbstractMojo {
047
048 /**
049 * @component
050 */
051 protected WagonManager wagonManager;
052
053 /**
054 * The current user system settings for use in Maven.
055 *
056 * @parameter expression="${settings}"
057 * @readonly
058 */
059 protected Settings settings;
060
061 /**
062 * Internal Maven's project
063 *
064 * @parameter expression="${project}"
065 * @readonly
066 */
067 protected MavenProject project;
068
069 /**
070 * When <code>true</code>, skip the execution.
071 *
072 * @parameter expression="${wagon.skip}" default-value="false"
073 */
074 protected boolean skip = false;
075
076 /**
077 * Convenient method to create a wagon
078 *
079 * @param id
080 * @param url
081 * @param wagonManager
082 * @param settings
083 * @param logger
084 * @return
085 * @throws MojoExecutionException
086 */
087 protected Wagon createWagon(String id, String url) throws MojoExecutionException {
088 try {
089 return WagonUtils.createWagon(id, url, wagonManager, settings, this.getLog());
090 } catch (Exception e) {
091 throw new MojoExecutionException("Unable to create a Wagon instance for " + url, e);
092 }
093
094 }
095
096 protected WagonFileSet getWagonFileSet(String fromDir, String includes, String excludes, boolean caseSensitive,
097 String toDir) {
098 return WagonUtils.getWagonFileSet(fromDir, includes, excludes, caseSensitive, toDir);
099 }
100
101 }