| 1 |
package org.apache.maven.scm.provider; |
| 2 |
|
| 3 |
/* |
| 4 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 5 |
* or more contributor license agreements. See the NOTICE file |
| 6 |
* distributed with this work for additional information |
| 7 |
* regarding copyright ownership. The ASF licenses this file |
| 8 |
* to you under the Apache License, Version 2.0 (the |
| 9 |
* "License"); you may not use this file except in compliance |
| 10 |
* with the License. You may obtain a copy of the License at |
| 11 |
* |
| 12 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
* |
| 14 |
* Unless required by applicable law or agreed to in writing, |
| 15 |
* software distributed under the License is distributed on an |
| 16 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 |
* KIND, either express or implied. See the License for the |
| 18 |
* specific language governing permissions and limitations |
| 19 |
* under the License. |
| 20 |
*/ |
| 21 |
|
| 22 |
/** |
| 23 |
* @author <a href="mailto:[email protected]">Trygve Laugstøl</a> |
| 24 |
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a> |
| 25 |
* @author <a href="mailto:[email protected]">Chris Graham</a> |
| 26 |
* |
| 27 |
*/ |
| 28 |
public abstract class ScmProviderRepository |
| 29 |
{ |
| 30 |
private String user; |
| 31 |
|
| 32 |
private String password; |
| 33 |
|
| 34 |
private boolean persistCheckout = false; |
| 35 |
|
| 36 |
/** |
| 37 |
* @since 1.4 |
| 38 |
*/ |
| 39 |
private boolean pushChanges = true; |
| 40 |
|
| 41 |
/** |
| 42 |
* Some SCMs have the concept of a work item (or task) which may need to be |
| 43 |
* specified to allow changes to be pushed or delivered to a target. |
| 44 |
* This allows you to answer the question: For this workItem, what changed? |
| 45 |
* Auditors have been known to love this... :) |
| 46 |
* SCMs known to implement this are: |
| 47 |
* <ul> |
| 48 |
* <li>IBM Rational Team Concert (workItem) |
| 49 |
* <li>Microsoft Team Foundation Server (workItem) |
| 50 |
* <li>IBM Rational ClearQuest Enabled UCM ClearCase (task) |
| 51 |
* </ul> |
| 52 |
* There may be others that support this feature. |
| 53 |
* <P> |
| 54 |
* These SCMs can be configured to reject a push/deliver unless additional |
| 55 |
* information (by way of a workItem/task) is supplied. |
| 56 |
* <P> |
| 57 |
* This field is only relevant when pushChanges = true. |
| 58 |
* <P> |
| 59 |
* It should be noted however, when pushChanges = true, a workItem does not |
| 60 |
* need to be set, as the need for a workItem may be optional. |
| 61 |
* |
| 62 |
* @since 1.9.5 |
| 63 |
*/ |
| 64 |
private String workItem; |
| 65 |
|
| 66 |
/** |
| 67 |
* @return The user. |
| 68 |
*/ |
| 69 |
public String getUser() |
| 70 |
{ |
| 71 |
return user; |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Set the user. |
| 76 |
* |
| 77 |
* @param user The user |
| 78 |
*/ |
| 79 |
public void setUser( String user ) |
| 80 |
{ |
| 81 |
this.user = user; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* @return The password. |
| 86 |
*/ |
| 87 |
public String getPassword() |
| 88 |
{ |
| 89 |
return password; |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Set the password. |
| 94 |
* |
| 95 |
* @param password The user password |
| 96 |
*/ |
| 97 |
public void setPassword( String password ) |
| 98 |
{ |
| 99 |
this.password = password; |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Should distributed changes be pushed to the central repository? |
| 104 |
* For many distributed SCMs like Git, a change like a commit |
| 105 |
* is only stored in your local copy of the repository. Pushing |
| 106 |
* the change allows your to more easily share it with other users. |
| 107 |
* @return TODO |
| 108 |
* @since 1.4 |
| 109 |
*/ |
| 110 |
public boolean isPushChanges() |
| 111 |
{ |
| 112 |
return pushChanges; |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* @since 1.4 |
| 117 |
* @param pushChanges TODO |
| 118 |
*/ |
| 119 |
public void setPushChanges( boolean pushChanges ) |
| 120 |
{ |
| 121 |
this.pushChanges = pushChanges; |
| 122 |
} |
| 123 |
|
| 124 |
/** |
| 125 |
* @return The workItem. |
| 126 |
* @since 1.9.5 |
| 127 |
*/ |
| 128 |
public String getWorkItem() |
| 129 |
{ |
| 130 |
return workItem; |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
* Set the workItem. |
| 135 |
* |
| 136 |
* @param workItem The workItem. |
| 137 |
* @since 1.9.5 |
| 138 |
*/ |
| 139 |
public void setWorkItem( String workItem ) |
| 140 |
{ |
| 141 |
this.workItem = workItem; |
| 142 |
} |
| 143 |
|
| 144 |
/** |
| 145 |
* Will checkouts using this repository be persisted so they can |
| 146 |
* be refreshed in the future? This property is of concern to SCMs |
| 147 |
* like Perforce and Clearcase where the server must track where a |
| 148 |
* user checks out to. If false, the server entry (clientspec in Perforce |
| 149 |
* terminology) will be deleted after the checkout is complete so the |
| 150 |
* files will not be able to be updated. |
| 151 |
* <p> |
| 152 |
* This setting can be overriden by using the system property |
| 153 |
* "maven.scm.persistcheckout" to true. |
| 154 |
* <p> |
| 155 |
* The default is false. See SCM-113 for more detail. |
| 156 |
* @return TODO |
| 157 |
*/ |
| 158 |
public boolean isPersistCheckout() |
| 159 |
{ |
| 160 |
String persist = System.getProperty( "maven.scm.persistcheckout" ); |
| 161 |
if ( persist != null ) |
| 162 |
{ |
| 163 |
return Boolean.valueOf( persist ).booleanValue(); |
| 164 |
} |
| 165 |
return persistCheckout; |
| 166 |
} |
| 167 |
|
| 168 |
public void setPersistCheckout( boolean persistCheckout ) |
| 169 |
{ |
| 170 |
this.persistCheckout = persistCheckout; |
| 171 |
} |
| 172 |
|
| 173 |
/** |
| 174 |
* Get a {@link ScmProviderRepository} that represents the parent folder in the repository. |
| 175 |
* Useful when the repository does not exist yet and we need to create it from the parent. |
| 176 |
* |
| 177 |
* @return the parent repository |
| 178 |
* @throws UnsupportedOperationException unless overridden by subclass |
| 179 |
*/ |
| 180 |
public ScmProviderRepository getParent() |
| 181 |
{ |
| 182 |
throw new UnsupportedOperationException(); |
| 183 |
} |
| 184 |
|
| 185 |
/** |
| 186 |
* Get the relative path between the repository provided as argument and the current repository. |
| 187 |
* |
| 188 |
* @param ancestor another repository that should be ancestor of this one |
| 189 |
* @return the relative path or <code>null</code> if it can't be resolved |
| 190 |
* @throws UnsupportedOperationException unless overridden by subclass |
| 191 |
*/ |
| 192 |
public String getRelativePath( ScmProviderRepository ancestor ) |
| 193 |
{ |
| 194 |
throw new UnsupportedOperationException(); |
| 195 |
} |
| 196 |
} |