1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.scm.plugin;
20
21 import javax.inject.Inject;
22
23 import java.io.IOException;
24
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.scm.ScmException;
28 import org.apache.maven.scm.command.add.AddScmResult;
29 import org.apache.maven.scm.manager.ScmManager;
30 import org.apache.maven.scm.repository.ScmRepository;
31 import org.apache.maven.settings.crypto.SettingsDecrypter;
32
33
34
35
36
37
38 @Mojo(name = "add", aggregator = true)
39 public class AddMojo extends AbstractScmMojo {
40
41 @Inject
42 public AddMojo(ScmManager manager, SettingsDecrypter settingsDecrypter) {
43 super(manager, settingsDecrypter);
44 }
45
46
47
48
49 public void execute() throws MojoExecutionException {
50 super.execute();
51
52 try {
53 ScmRepository repository = getScmRepository();
54
55 AddScmResult result = getScmManager().add(repository, getFileSet());
56
57 checkResult(result);
58
59 getLog().info(result.getAddedFiles().size() + " files successfully added.");
60
61 } catch (IOException | ScmException e) {
62 throw new MojoExecutionException("Cannot run add command : ", e);
63 }
64 }
65 }