001    package org.codehaus.mojo.wagon;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
005     * agreements. See the NOTICE file distributed with this work for additional information regarding
006     * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance with the License. You may obtain a
008     * copy of the License at
009     * 
010     * http://www.apache.org/licenses/LICENSE-2.0
011     * 
012     * Unless required by applicable law or agreed to in writing, software distributed under the License
013     * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
014     * or implied. See the License for the specific language governing permissions and limitations under
015     * the License.
016     */
017    
018    import java.io.IOException;
019    
020    import org.apache.maven.wagon.Wagon;
021    import org.apache.maven.wagon.WagonException;
022    import org.codehaus.mojo.wagon.shared.WagonDownload;
023    
024    /**
025     * Check for the existing of remote resource.
026     * 
027     * @goal exist
028     * @requiresProject true
029     */
030    public class ExistMojo
031        extends AbstractSingleWagonMojo
032    {
033        /**
034         * relative path to a remote resource
035         * @parameter expression="${wagon.resource}" default-value=""
036         */
037        private String resource = "";
038        
039        /**
040         * @component
041         */
042        protected WagonDownload wagonDownload;
043    
044        
045        protected void execute( Wagon wagon )
046            throws WagonException, IOException
047        {
048            if ( this.wagonDownload.exists( wagon, resource ) )
049            {
050                this.getLog().info( resource + " exists. " );
051            }
052            else
053            {
054                this.getLog().info( resource + " does not exists. " );
055            }
056        }
057    
058    }