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 public void execute() throws MojoExecutionException {
48 super.execute();
49
50 try {
51 ScmRepository repository = getScmRepository();
52
53 AddScmResult result = getScmManager().add(repository, getFileSet());
54
55 checkResult(result);
56
57 getLog().info("" + result.getAddedFiles().size() + " files successfully added.");
58
59 } catch (IOException | ScmException e) {
60 throw new MojoExecutionException("Cannot run add command : ", e);
61 }
62 }
63 }