1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven.scm.command.checkout;
20
21 import java.util.List;
22
23 import org.apache.maven.scm.ScmFile;
24 import org.apache.maven.scm.ScmResult;
25
26 /**
27 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
28 * @author Olivier Lamy
29 */
30 public class CheckOutScmResult extends ScmResult {
31
32 private static final long serialVersionUID = 3345964619749320210L;
33
34 private List<ScmFile> checkedOutFiles;
35
36 /**
37 * @since 1.8
38 */
39 private String revision;
40
41 /**
42 * The relative path of the directory of the checked out project in comparison to the checkout directory, or
43 * an empty String in case the checkout directory equals the project directory.
44 * <p>
45 * With most SCMs, this is just an empty String, meaning that the checkout directory equals the project directory.
46 * But there are cases where within the checkout directory, the directory structure of the
47 * SCM system is repeated. E.g. if you check out the project "my/project" to "/some/dir", the project sources
48 * are actually checked out to "my/project/some/dir". In this example, relativePathProjectDirectory would
49 * contain "my/project".
50 */
51 protected String relativePathProjectDirectory = "";
52
53 public CheckOutScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) {
54 super(commandLine, providerMessage, commandOutput, success);
55 }
56
57 public CheckOutScmResult(String commandLine, List<ScmFile> checkedOutFiles) {
58 this(commandLine, null, checkedOutFiles);
59 }
60
61 public CheckOutScmResult(String commandLine, String revision, List<ScmFile> checkedOutFiles) {
62 super(commandLine, null, null, true);
63
64 this.revision = revision;
65
66 this.checkedOutFiles = checkedOutFiles;
67 }
68
69 public CheckOutScmResult(String commandLine, List<ScmFile> checkedOutFiles, String relativePathProjectDirectory) {
70 this(commandLine, null, checkedOutFiles);
71 if (relativePathProjectDirectory != null) {
72 this.relativePathProjectDirectory = relativePathProjectDirectory;
73 }
74 }
75
76 public CheckOutScmResult(
77 String commandLine, String revision, List<ScmFile> checkedOutFiles, String relativePathProjectDirectory) {
78 this(commandLine, revision, checkedOutFiles);
79 if (relativePathProjectDirectory != null) {
80 this.relativePathProjectDirectory = relativePathProjectDirectory;
81 }
82 }
83
84 public CheckOutScmResult(List<ScmFile> checkedOutFiles, ScmResult result) {
85 super(result);
86
87 this.checkedOutFiles = checkedOutFiles;
88 }
89
90 public List<ScmFile> getCheckedOutFiles() {
91 return checkedOutFiles;
92 }
93
94 /**
95 * @return the contents of {@link #relativePathProjectDirectory}
96 * @see #relativePathProjectDirectory
97 */
98 public String getRelativePathProjectDirectory() {
99 return relativePathProjectDirectory;
100 }
101
102 /**
103 * Checked-out revision.
104 * SCM's that have no revision per repository (or branch) should store <code>null</code> here.
105 *
106 * @return the revision that was checked out
107 * @since 1.8
108 */
109 public String getRevision() {
110 return revision;
111 }
112 }