View Javadoc

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  import java.util.List;
19  
20  import org.apache.maven.plugin.MojoExecutionException;
21  import org.apache.maven.wagon.Wagon;
22  import org.apache.maven.wagon.WagonException;
23  import org.codehaus.mojo.wagon.shared.WagonFileSet;
24  
25  /**
26   * List the files under a specified directory for a repository
27   *
28   * @goal list
29   * @requiresProject false
30   */
31  public class ListMojo extends AbstractWagonListMojo {
32  
33      /**
34       * If true, any files found are logged to the console
35       *
36       * @parameter expression="${wagon.showFiles}" default-value="true"
37       */
38      protected boolean showFiles;
39  
40      @Override
41      protected void execute(Wagon wagon) throws MojoExecutionException, WagonException {
42          WagonFileSet wagonFileSet = getWagonFileSet();
43          List<String> files = wagonDownload.getFileList(wagon, wagonFileSet, getLog());
44          if (showFiles) {
45              for (String file : files) {
46                  getLog().info(file);
47              }
48          }
49      }
50  
51      public boolean isShowFiles() {
52          return showFiles;
53      }
54  
55      public void setShowFiles(boolean showFiles) {
56          this.showFiles = showFiles;
57      }
58  }