1 package org.apache.maven.plugins.stage;
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.AbstractMojo;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugins.annotations.Component;
25 import org.apache.maven.plugins.annotations.Mojo;
26 import org.apache.maven.plugins.annotations.Parameter;
27 import org.apache.maven.wagon.WagonException;
28 import org.apache.maven.wagon.repository.Repository;
29
30 import java.io.IOException;
31
32
33
34
35
36
37 @Mojo( name = "copy", requiresProject = false )
38 public class CopyRepositoryMojo
39 extends AbstractMojo
40 {
41
42
43
44 @Parameter( property = "source" )
45 private String source;
46
47
48
49
50
51
52
53
54
55 @Parameter( property = "target" )
56 private String target;
57
58
59
60
61 @Parameter( property = "sourceRepositoryId", defaultValue = "source" )
62 private String sourceRepositoryId;
63
64
65
66
67 @Parameter( property = "targetRepositoryId", defaultValue = "target" )
68 private String targetRepositoryId;
69
70
71
72
73
74
75
76
77 @Parameter( property = "version", required = true )
78 private String version;
79
80
81
82
83 @Component
84 private RepositoryCopier copier;
85
86 public void execute()
87 throws MojoExecutionException
88 {
89 try
90 {
91 Repository sourceRepository = new Repository( sourceRepositoryId, source );
92 Repository targetRepository = new Repository( targetRepositoryId, target );
93 copier.copy( sourceRepository, targetRepository, version );
94 }
95 catch ( IOException e )
96 {
97 throw new MojoExecutionException(
98 "Error copying repository from " + source + " to " + target, e );
99 }
100 catch ( WagonException e )
101 {
102 throw new MojoExecutionException(
103 "Error copying repository from " + source + " to " + target, e );
104 }
105 }
106 }
107