View Javadoc

1   /*
2    * Copyright 2006-2012 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.maven.plugin.buildmetadata.common;
17  
18  import java.io.File;
19  
20  import org.apache.maven.scm.manager.ScmManager;
21  
22  /**
23   * Bundles the SCM information to be passed to meta data providers.
24   *
25   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
26   * @version $Revision:591 $
27   */
28  public final class ScmInfo
29  {
30    // ********************************* Fields *********************************
31  
32    // --- constants ------------------------------------------------------------
33  
34    // --- members --------------------------------------------------------------
35  
36    /**
37     * The manager instance to access the SCM system. Provides access to the
38     * repository and the provider information.
39     */
40    private final ScmManager scmManager;
41  
42    /**
43     * Allows the user to choose which scm connection to use when connecting to
44     * the scm. Can either be "connection" or "developerConnection".
45     */
46    private final String connectionType;
47  
48    /**
49     * Used to specify the date format of the log entries that are retrieved from
50     * your SCM system.
51     */
52    private final String scmDateFormat;
53  
54    /**
55     * Input dir. Directory where the files under SCM control are located.
56     */
57    private final File basedir;
58  
59    /**
60     * The authentication for the SCM server.
61     */
62    private final ScmCredentials scmCrendentials;
63  
64    /**
65     * The url of tags base directory (used by svn protocol).
66     */
67    private final String tagBase;
68  
69    /**
70     * The range of the query in days to fetch change log entries from the SCM. If
71     * no change logs have been found, the range is incremented up to
72     * {@value de.smartics.maven.plugin.buildmetadata.scm.maven.ScmAccessInfo#DEFAULT_RETRY_COUNT}
73     * times. If no change log has been found after these
74     * {@value de.smartics.maven.plugin.buildmetadata.scm.maven.ScmAccessInfo#DEFAULT_RETRY_COUNT}
75     * additional queries, the revision number will not be set with a valid value.
76     */
77    private final int queryRangeInDays;
78  
79    /**
80     * The date pattern to use to format the build and revision dates. Please
81     * refer to the <a href =
82     * "http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html"
83     * >SimpleDateFormat</a> class for valid patterns.
84     */
85    private final String buildDatePattern;
86  
87    /**
88     * The information to control the gathering of SCM meta data.
89     */
90    private final ScmControl scmControl;
91  
92    // ****************************** Initializer *******************************
93  
94    // ****************************** Constructors ******************************
95  
96    // CHECKSTYLE:OFF
97    /**
98     * Default constructor.
99     *
100    * @param scmManager the manager instance to access the SCM system.
101    * @param connectionType the value for connectionType.
102    * @param scmDateFormat the value for scmDateFormat.
103    * @param basedir the value for basedir.
104    * @param scmCrendentials the authentication for the SCM server.
105    * @param tagBase the url of tags base directory (used by svn protocol).
106    * @param queryRangeInDays the range of the query in days to fetch change log
107    *          entries from the SCM.
108    * @param buildDatePattern the date pattern to use to format the build and
109    *          revision dates.
110    * @param scmControl the information to control the gathering of SCM meta
111    *          data.
112    * @note This argument list is quite long. The next time we touch this class,
113    *       we should provide a builder.
114    */
115   public ScmInfo(final ScmManager scmManager, final String connectionType, // NOPMD
116       final String scmDateFormat, final File basedir,
117       final ScmCredentials scmCrendentials, final String tagBase,
118       final int queryRangeInDays, final String buildDatePattern,
119       final ScmControl scmControl)
120   {
121     this.scmManager = scmManager;
122     this.connectionType = connectionType;
123     this.scmDateFormat = scmDateFormat;
124     this.basedir = basedir;
125     this.scmCrendentials = scmCrendentials;
126     this.tagBase = tagBase;
127     this.queryRangeInDays = queryRangeInDays;
128     this.buildDatePattern = buildDatePattern;
129     this.scmControl = scmControl;
130   }
131   // CHECKSTYLE:ON
132 
133   // ****************************** Inner Classes *****************************
134 
135   // ********************************* Methods ********************************
136 
137   // --- init -----------------------------------------------------------------
138 
139   // --- get&set --------------------------------------------------------------
140 
141   /**
142    * Returns the manager instance to access the SCM system. Provides access to
143    * the repository and the provider information.
144    *
145    * @return the manager instance to access the SCM system.
146    */
147   public ScmManager getScmManager()
148   {
149     return scmManager;
150   }
151 
152   /**
153    * Returns the value for connectionType.
154    * <p>
155    * Allows the user to choose which scm connection to use when connecting to
156    * the scm. Can either be "connection" or "developerConnection".
157    *
158    * @return the value for connectionType.
159    */
160   public String getConnectionType()
161   {
162     return connectionType;
163   }
164 
165   /**
166    * Returns the value for scmDateFormat.
167    * <p>
168    * Used to specify the date format of the log entries that are retrieved from
169    * your SCM system.
170    *
171    * @return the value for scmDateFormat.
172    */
173   public String getScmDateFormat()
174   {
175     return scmDateFormat;
176   }
177 
178   /**
179    * Returns the value for basedir.
180    * <p>
181    * Input dir. Directory where the files under SCM control are located.
182    *
183    * @return the value for basedir.
184    */
185   public File getBasedir()
186   {
187     return basedir;
188   }
189 
190   /**
191    * Returns the authentication for the SCM server.
192    *
193    * @return the authentication for the SCM server.
194    */
195   public ScmCredentials getScmCrendentials()
196   {
197     return scmCrendentials;
198   }
199 
200   /**
201    * Returns the url of tags base directory (used by svn protocol).
202    *
203    * @return the url of tags base directory (used by svn protocol).
204    */
205   public String getTagBase()
206   {
207     return tagBase;
208   }
209 
210   /**
211    * Returns the range of the query in days to fetch change log entries from the
212    * SCM. If no change logs have been found, the range is incremented up to
213    * {@value de.smartics.maven.plugin.buildmetadata.scm.maven.ScmAccessInfo#DEFAULT_RETRY_COUNT}
214    * times. If no change log has been found after these
215    * {@value de.smartics.maven.plugin.buildmetadata.scm.maven.ScmAccessInfo#DEFAULT_RETRY_COUNT}
216    * additional queries, the revision number will not be set with a valid value.
217    *
218    * @return the range of the query in days to fetch change log entries from the
219    *         SCM.
220    */
221   public int getQueryRangeInDays()
222   {
223     return queryRangeInDays;
224   }
225 
226   /**
227    * Returns the date pattern to use to format the build and revision dates.
228    * Please refer to the <a href =
229    * "http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html"
230    * >SimpleDateFormat</a> class for valid patterns.
231    *
232    * @return the date pattern to use to format the build and revision dates.
233    */
234   public String getBuildDatePattern()
235   {
236     return buildDatePattern;
237   }
238 
239   /**
240    * Returns the information to control the gathering of SCM meta data.
241    *
242    * @return the information to control the gathering of SCM meta data.
243    */
244   public ScmControl getScmControl()
245   {
246     return scmControl;
247   }
248 
249   // --- business -------------------------------------------------------------
250 
251   // --- object basics --------------------------------------------------------
252 
253 }