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    import java.io.File;
019    
020    import org.apache.maven.wagon.Wagon;
021    import org.apache.maven.wagon.WagonException;
022    import org.codehaus.mojo.wagon.shared.WagonFileSet;
023    
024    /**
025     * Transfers a set of files from a remote URL to a specified local directory.
026     *
027     * @goal download
028     * @requiresProject false
029     */
030    public class DownloadMojo extends AbstractWagonListMojo {
031    
032        /**
033         * Local directory that files are downloaded to
034         *
035         * @parameter expression="${wagon.toDir}" default-value="${project.build.directory}/wagon-plugin"
036         */
037        private File toDir;
038    
039        /**
040         * If true, files that already exist on the local file system are not downloaded
041         *
042         * @parameter expression="${wagon.skipExisting}" default-value="false"
043         */
044        private boolean skipExisting;
045    
046        @Override
047        protected void execute(Wagon wagon) throws WagonException {
048            WagonFileSet fileSet = this.getWagonFileSet();
049            fileSet.setDownloadDirectory(this.toDir);
050            this.wagonDownload.download(wagon, fileSet, this.getLog(), skipExisting);
051        }
052    
053    }