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  /**
19   * Information to control the gathering of SCM meta data.
20   *
21   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
22   * @version $Revision:591 $
23   */
24  public final class ScmControl
25  {
26    // ********************************* Fields *********************************
27  
28    // --- constants ------------------------------------------------------------
29  
30    // --- members --------------------------------------------------------------
31  
32    /**
33     * Flag to fail if local modifications have been found. The value is
34     * <code>true</code> if the build should fail if there are modifications (any
35     * files not in-sync with the remote repository), <code>false</code> if the
36     * fact is only to be noted in the build properties.
37     */
38    private final boolean failOnLocalModifications;
39  
40    /**
41     * The flag to ignore files and directories starting with a dot for checking
42     * modified files. This implicates that any files or directories, starting
43     * with a dot, are ignored when the check on changed files is run. If the
44     * value is <code>true</code>, dot files are ignored, if it is set to
45     * <code>false</code>, dot files are respected.
46     */
47    private final boolean ignoreDotFilesInBaseDir;
48  
49    /**
50     * In offline mode the plugin will not generate revision information.
51     */
52    private final boolean offline;
53  
54    /**
55     * Add SCM information if set to <code>true</code>, skip it, if set to
56     * <code>false</code>. If you are not interested in SCM information, set this
57     * to <code>false</code>.
58     */
59    private final boolean addScmInfo;
60  
61    /**
62     * If it should be checked if the local files are up-to-date with the remote
63     * files in the SCM repository. If the value is <code>true</code> the result
64     * of the check, including the list of changed files, is added to the build
65     * meta data.
66     */
67    private final boolean validateCheckout;
68  
69    /**
70     * Fail if revision is requested to be retrieved, access to SCM is provided,
71     * system is online, nothing should prevent the build from fetching the
72     * information.
73     * <p>
74     * If set to <code>true</code> the build will fail, if revision cannot be
75     * fetched, <code>false</code> will continue so that the meta data do not
76     * contain the revision.
77     * </p>
78     */
79    private final boolean failOnMissingRevision;
80  
81    // ****************************** Initializer *******************************
82  
83    // ****************************** Constructors ******************************
84  
85    // CHECKSTYLE:OFF
86  
87    /**
88     * Default constructor.
89     *
90     * @param failOnLocalModifications the value for failOnLocalModifications.
91     * @param ignoreDotFilesInBaseDir the flag to ignore files and directories
92     *          starting with a dot for checking modified files.
93     * @param offline the value for offline.
94     * @param addScmInfo the value for addScmInfo.
95     * @param validateCheckout the value for validateCheckout.
96     * @param failOnMissingRevision the value for failOnMissingRevision.
97     */
98    public ScmControl(// NOPMD
99        final boolean failOnLocalModifications,
100       final boolean ignoreDotFilesInBaseDir, final boolean offline,
101       final boolean addScmInfo, final boolean validateCheckout,
102       final boolean failOnMissingRevision)
103   {
104     this.failOnLocalModifications = failOnLocalModifications;
105     this.ignoreDotFilesInBaseDir = ignoreDotFilesInBaseDir;
106     this.offline = offline;
107     this.addScmInfo = addScmInfo;
108     this.validateCheckout = validateCheckout;
109     this.failOnMissingRevision = failOnMissingRevision;
110   }
111 
112   // CHECKSTYLE:ON
113 
114   // ****************************** Inner Classes *****************************
115 
116   // ********************************* Methods ********************************
117 
118   // --- init -----------------------------------------------------------------
119 
120   // --- get&set --------------------------------------------------------------
121 
122   /**
123    * Returns the value for failOnLocalModifications.
124    * <p>
125    * Flag to fail if local modifications have been found. The value is
126    * <code>true</code> if the build should fail if there are modifications (any
127    * files not in-sync with the remote repository), <code>false</code> if the
128    * fact is only to be noted in the build properties.
129    * </p>
130    *
131    * @return the value for failOnLocalModifications.
132    */
133   public boolean isFailOnLocalModifications()
134   {
135     return failOnLocalModifications;
136   }
137 
138   /**
139    * Returns the flag to ignore files and directories starting with a dot for
140    * checking modified files. This implicates that any files or directories,
141    * starting with a dot, are ignored when the check on changed files is run. If
142    * the value is <code>true</code>, dot files are ignored, if it is set to
143    * <code>false</code>, dot files are respected.
144    *
145    * @return the flag to ignore files and directories starting with a dot for
146    *         checking modified files.
147    */
148   public boolean isIgnoreDotFilesInBaseDir()
149   {
150     return ignoreDotFilesInBaseDir;
151   }
152 
153   /**
154    * Returns the value for offline.
155    * <p>
156    * In offline mode the plugin will not generate revision information.
157    * </p>
158    *
159    * @return the value for offline.
160    */
161   public boolean isOffline()
162   {
163     return offline;
164   }
165 
166   /**
167    * Returns the value for addScmInfo.
168    * <p>
169    * Add SCM information if set to <code>true</code>, skip it, if set to
170    * <code>false</code>. If you are not interested in SCM information, set this
171    * to <code>false</code>.
172    * </p>
173    *
174    * @return the value for addScmInfo.
175    */
176   public boolean isAddScmInfo()
177   {
178     return addScmInfo;
179   }
180 
181   /**
182    * Returns the value for validateCheckout.
183    * <p>
184    * If it should be checked if the local files are up-to-date with the remote
185    * files in the SCM repository. If the value is <code>true</code> the result
186    * of the check, including the list of changed files, is added to the build
187    * meta data.
188    * </p>
189    *
190    * @return the value for validateCheckout.
191    */
192   public boolean isValidateCheckout()
193   {
194     return validateCheckout;
195   }
196 
197   /**
198    * Returns the value for failOnMissingRevision.
199    * <p>
200    * Fail if revision is requested to be retrieved, access to SCM is provided,
201    * system is online, nothing should prevent the build from fetching the
202    * information.
203    * </p>
204    * <p>
205    * If set to <code>true</code> the build will fail, if revision cannot be
206    * fetched, <code>false</code> will continue so that the meta data do not
207    * contain the revision.
208    * </p>
209    *
210    * @return the value for failOnMissingRevision.
211    */
212   public boolean isFailOnMissingRevision()
213   {
214     return failOnMissingRevision;
215   }
216 
217   // --- business -------------------------------------------------------------
218 
219   // --- object basics --------------------------------------------------------
220 
221 }