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 org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugins.annotations.Parameter;
24 import org.apache.maven.wagon.ConnectionException;
25 import org.apache.maven.wagon.Wagon;
26 import org.apache.maven.wagon.WagonException;
27
28 import java.io.IOException;
29
30
31
32
33 public abstract class AbstractSingleWagonMojo
34 extends AbstractWagonMojo
35 {
36
37
38
39
40 @Parameter( property = "wagon.url", required = true )
41 protected String url;
42
43
44
45
46 @Parameter( property = "wagon.serverId", defaultValue = "serverId")
47 private String serverId;
48
49 @Override
50 public void execute()
51 throws MojoExecutionException
52 {
53 if ( this.skip )
54 {
55 this.getLog().info( "Skip execution." );
56 return;
57 }
58
59 Wagon wagon = null;
60 try
61 {
62 wagon = createWagon( serverId, url );
63 execute( wagon );
64 }
65 catch ( WagonException | IOException e )
66 {
67 throw new MojoExecutionException( "Error handling resource", e );
68 } finally
69 {
70 try
71 {
72 if ( wagon != null )
73 {
74 wagon.disconnect();
75 }
76 }
77 catch ( ConnectionException e )
78 {
79 getLog().debug( "Error disconnecting wagon - ignored", e );
80 }
81 }
82 }
83
84
85
86
87
88
89
90
91
92 protected abstract void execute( Wagon wagon )
93 throws MojoExecutionException, WagonException, IOException;
94
95 }