1 package org.codehaus.mojo.wagon;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.util.Arrays;
25
26 import org.apache.maven.plugins.annotations.Component;
27 import org.apache.maven.plugins.annotations.Mojo;
28 import org.apache.maven.plugins.annotations.Parameter;
29 import org.apache.maven.shared.model.fileset.FileSet;
30 import org.apache.maven.wagon.Wagon;
31 import org.apache.maven.wagon.WagonException;
32 import org.codehaus.mojo.wagon.shared.WagonUpload;
33 import org.codehaus.plexus.util.StringUtils;
34
35
36
37
38 @Mojo( name = "upload" )
39 public class UploadMojo
40 extends AbstractSingleWagonMojo
41 {
42
43
44
45 @Parameter( property = "wagon.fromDir", defaultValue = "${project.basedir}")
46 private File fromDir;
47
48
49
50
51 @Parameter( property = "wagon.excludes")
52 private String excludes;
53
54
55
56
57 @Parameter( property = "wagon.includes")
58 private String includes;
59
60
61
62
63 @Parameter( property = "wagon.followSymLink", defaultValue = "false")
64 private boolean followSymLink = false;
65
66
67
68
69 @Parameter( property = "wagon.useDefaultExcludes", defaultValue = "true")
70 private boolean useDefaultExcludes = true;
71
72
73
74
75 @Parameter( property = "wagon.toDir")
76 private String toDir = "";
77
78
79
80
81
82 @Parameter( property = "wagon.optimize", defaultValue = "false")
83 private boolean optimize = false;
84
85 @Component
86 protected WagonUpload wagonUpload;
87
88 @Override
89 protected void execute( Wagon wagon )
90 throws WagonException, IOException
91 {
92 FileSet fileSet = new FileSet();
93
94 fileSet.setDirectory( this.fromDir.getAbsolutePath() );
95
96 if ( !StringUtils.isBlank( includes ) )
97 {
98 fileSet.setIncludes( Arrays.asList( StringUtils.split( this.includes, "," ) ) );
99 }
100
101 if ( !StringUtils.isBlank( excludes ) )
102 {
103 fileSet.setExcludes( Arrays.asList( StringUtils.split( this.excludes, "," ) ) );
104 }
105
106 fileSet.setFollowSymlinks( this.followSymLink );
107
108 fileSet.setUseDefaultExcludes( this.useDefaultExcludes );
109
110 fileSet.setOutputDirectory( toDir );
111
112 this.wagonUpload.upload( wagon, fileSet, optimize, this.getLog() );
113 }
114
115 }