1 package org.apache.maven.scm.provider.cvslib.cvsexe.command.add;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.List;
23
24 import org.apache.maven.scm.ScmException;
25 import org.apache.maven.scm.ScmFile;
26 import org.apache.maven.scm.command.add.AddScmResult;
27 import org.apache.maven.scm.provider.cvslib.command.add.AbstractCvsAddCommand;
28 import org.codehaus.plexus.util.cli.CommandLineException;
29 import org.codehaus.plexus.util.cli.CommandLineUtils;
30 import org.codehaus.plexus.util.cli.Commandline;
31
32
33
34
35
36 public class CvsExeAddCommand
37 extends AbstractCvsAddCommand
38 {
39
40 protected AddScmResult executeCvsCommand( Commandline cl, List<ScmFile> addedFiles )
41 throws ScmException
42 {
43 CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer();
44
45 CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
46
47 int exitCode;
48
49 try
50 {
51 exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
52 }
53 catch ( CommandLineException ex )
54 {
55 throw new ScmException( "Error while executing command.", ex );
56 }
57
58
59 if ( exitCode != 0 )
60 {
61 return new AddScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false );
62 }
63
64 return new AddScmResult( cl.toString(), addedFiles );
65 }
66 }