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.model.building; 20 21 import java.io.File; 22 import java.util.Date; 23 import java.util.List; 24 import java.util.Properties; 25 import org.apache.maven.model.Model; 26 import org.apache.maven.model.Profile; 27 import org.apache.maven.model.resolution.ModelResolver; 28 import org.apache.maven.model.resolution.WorkspaceModelResolver; 29 30 /** 31 * Collects settings that control the building of effective models. 32 * 33 * @author Benjamin Bentmann 34 */ 35 public interface ModelBuildingRequest { 36 37 /** 38 * Denotes minimal validation of POMs. This validation level is meant for processing of POMs from repositories 39 * during metadata retrieval. 40 */ 41 int VALIDATION_LEVEL_MINIMAL = 0; 42 43 /** 44 * Denotes validation as performed by Maven 2.0. This validation level is meant as a compatibility mode to allow 45 * users to migrate their projects. 46 */ 47 int VALIDATION_LEVEL_MAVEN_2_0 = 20; 48 49 /** 50 * Denotes validation as performed by Maven 3.0. This validation level is meant for existing projects. 51 */ 52 int VALIDATION_LEVEL_MAVEN_3_0 = 30; 53 54 /** 55 * Denotes validation as performed by Maven 3.1. This validation level is meant for new projects. 56 */ 57 int VALIDATION_LEVEL_MAVEN_3_1 = 31; 58 59 /** 60 * Denotes strict validation as recommended by the current Maven version. 61 */ 62 int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_1; 63 64 /** 65 * Gets the file model to build (with profile activation). 66 * If not set, model source will be used to load file model. 67 * 68 * @return The file model to build or {@code null} if not set. 69 * @since 4.0.0 70 */ 71 Model getFileModel(); 72 73 /** 74 * Set the file model with profile activation 75 * 76 * @param fileModel 77 * @return This request, never {@code null}. 78 * @since 4.0.0 79 */ 80 ModelBuildingRequest setFileModel(Model fileModel); 81 82 /** 83 * @deprecated rawModel is never set, instead the fileModel is set 84 */ 85 @Deprecated 86 Model getRawModel(); 87 88 /** 89 * @deprecated setting the rawModel has no effect, instead the fileModel of phase one will be set 90 */ 91 @Deprecated 92 ModelBuildingRequest setRawModel(Model rawModel); 93 94 /** 95 * Gets the source of the POM to process. 96 * 97 * @return The source of the POM or {@code null} if not set. 98 */ 99 ModelSource getModelSource(); 100 101 /** 102 * Sets the source of the POM to process. Eventually, either {@link #setModelSource(ModelSource)} or 103 * {@link #setPomFile(File)} must be set. 104 * 105 * @param modelSource The source of the POM to process, may be {@code null}. 106 * @return This request, never {@code null}. 107 */ 108 ModelBuildingRequest setModelSource(ModelSource modelSource); 109 110 /** 111 * Gets the POM file of the project to build. 112 * 113 * @return The POM file of the project or {@code null} if not applicable (i.e. when processing a POM from the 114 * repository). 115 */ 116 File getPomFile(); 117 118 /** 119 * Sets the POM file of the project to build. Note that providing the path to a POM file via this method will make 120 * the model builder operate in project mode. This mode is meant for effective models that are employed during the 121 * build process of a local project. Hence the effective model will support the notion of a project directory. To 122 * build the model for a POM from the repository, use {@link #setModelSource(ModelSource)} in combination with a 123 * {@link FileModelSource} instead. 124 * 125 * @param pomFile The POM file of the project to build the effective model for, may be {@code null} to build the 126 * model of some POM from the repository. 127 * @return This request, never {@code null}. 128 */ 129 ModelBuildingRequest setPomFile(File pomFile); 130 131 /** 132 * Gets the level of validation to perform on processed models. 133 * 134 * @return The level of validation to perform on processed models. 135 */ 136 int getValidationLevel(); 137 138 /** 139 * Sets the level of validation to perform on processed models. For building of projects, 140 * {@link #VALIDATION_LEVEL_STRICT} should be used to ensure proper building. For the mere retrieval of dependencies 141 * during artifact resolution, {@link #VALIDATION_LEVEL_MINIMAL} should be used to account for models of poor 142 * quality. By default, models are validated in strict mode. 143 * 144 * @param validationLevel The level of validation to perform on processed models. 145 * @return This request, never {@code null}. 146 */ 147 ModelBuildingRequest setValidationLevel(int validationLevel); 148 149 /** 150 * Indicates whether plugin executions and configurations should be processed. If enabled, lifecycle-induced plugin 151 * executions will be injected into the model and common plugin configuration will be propagated to individual 152 * executions. 153 * 154 * @return {@code true} if plugins should be processed, {@code false} otherwise. 155 */ 156 boolean isProcessPlugins(); 157 158 /** 159 * Controls the processing of plugin executions and configurations. 160 * 161 * @param processPlugins {@code true} to enable plugin processing, {@code false} otherwise. 162 * @return This request, never {@code null}. 163 */ 164 ModelBuildingRequest setProcessPlugins(boolean processPlugins); 165 166 /** 167 * Indicates whether the model building should happen in two phases. If enabled, the initial invocation of the model 168 * builder will only produce an interim result which may be used to analyze inter-model dependencies before the 169 * final invocation of the model builder is performed. 170 * 171 * @return {@code true} if two-phase building is enabled, {@code false} if the model should be build in a single 172 * step. 173 */ 174 boolean isTwoPhaseBuilding(); 175 176 /** 177 * Enables/disables two-phase building. If enabled, the initial invocation of the model builder will only produce an 178 * interim result which may be used to analyze inter-model dependencies before the final invocation of the model 179 * builder is performed. 180 * 181 * @param twoPhaseBuilding {@code true} to enable two-phase building, {@code false} if the model should be build in 182 * a single step. 183 * @return This request, never {@code null}. 184 */ 185 ModelBuildingRequest setTwoPhaseBuilding(boolean twoPhaseBuilding); 186 187 /** 188 * Indicates whether the model should track the line/column number of the model source from which it was parsed. 189 * 190 * @return {@code true} if location tracking is enabled, {@code false} otherwise. 191 */ 192 boolean isLocationTracking(); 193 194 /** 195 * Enables/disables the tracking of line/column numbers for the model source being parsed. By default, input 196 * locations are not tracked. 197 * 198 * @param locationTracking {@code true} to enable location tracking, {@code false} to disable it. 199 * @return This request, never {@code null}. 200 */ 201 ModelBuildingRequest setLocationTracking(boolean locationTracking); 202 203 /** 204 * Gets the external profiles that should be considered for model building. 205 * 206 * @return The external profiles that should be considered for model building, never {@code null}. 207 */ 208 List<Profile> getProfiles(); 209 210 /** 211 * Sets the external profiles that should be considered for model building. 212 * 213 * @param profiles The external profiles that should be considered for model building, may be {@code null}. 214 * @return This request, never {@code null}. 215 */ 216 ModelBuildingRequest setProfiles(List<Profile> profiles); 217 218 /** 219 * Gets the identifiers of those profiles that should be activated by explicit demand. 220 * 221 * @return The identifiers of those profiles to activate, never {@code null}. 222 */ 223 List<String> getActiveProfileIds(); 224 225 /** 226 * Sets the identifiers of those profiles that should be activated by explicit demand. 227 * 228 * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}. 229 * @return This request, never {@code null}. 230 */ 231 ModelBuildingRequest setActiveProfileIds(List<String> activeProfileIds); 232 233 /** 234 * Gets the identifiers of those profiles that should be deactivated by explicit demand. 235 * 236 * @return The identifiers of those profiles to deactivate, never {@code null}. 237 */ 238 List<String> getInactiveProfileIds(); 239 240 /** 241 * Sets the identifiers of those profiles that should be deactivated by explicit demand. 242 * 243 * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}. 244 * @return This request, never {@code null}. 245 */ 246 ModelBuildingRequest setInactiveProfileIds(List<String> inactiveProfileIds); 247 248 /** 249 * Gets the system properties to use for interpolation and profile activation. The system properties are collected 250 * from the runtime environment like {@link System#getProperties()} and environment variables. 251 * 252 * @return The system properties, never {@code null}. 253 */ 254 Properties getSystemProperties(); 255 256 /** 257 * Sets the system properties to use for interpolation and profile activation. The system properties are collected 258 * from the runtime environment like {@link System#getProperties()} and environment variables. 259 * 260 * @param systemProperties The system properties, may be {@code null}. 261 * @return This request, never {@code null}. 262 */ 263 ModelBuildingRequest setSystemProperties(Properties systemProperties); 264 265 /** 266 * Gets the user properties to use for interpolation and profile activation. The user properties have been 267 * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command 268 * line. 269 * 270 * @return The user properties, never {@code null}. 271 */ 272 Properties getUserProperties(); 273 274 /** 275 * Sets the user properties to use for interpolation and profile activation. The user properties have been 276 * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command 277 * line. 278 * 279 * @param userProperties The user properties, may be {@code null}. 280 * @return This request, never {@code null}. 281 */ 282 ModelBuildingRequest setUserProperties(Properties userProperties); 283 284 /** 285 * Gets the start time of the build. 286 * 287 * @return The start time of the build or {@code null} if unknown. 288 */ 289 Date getBuildStartTime(); 290 291 /** 292 * Sets the start time of the build. 293 * 294 * @param buildStartTime The start time of the build, may be {@code null}. 295 * @return This request, never {@code null}. 296 */ 297 ModelBuildingRequest setBuildStartTime(Date buildStartTime); 298 299 /** 300 * Gets the model resolver to use for resolution of mixins or parents that are not locally reachable from the 301 * project directory. 302 * 303 * @return The model resolver or {@code null} if not set. 304 */ 305 ModelResolver getModelResolver(); 306 307 /** 308 * Sets the model resolver to use for resolution of mixins or parents that are not locally reachable from the 309 * project directory. 310 * 311 * @param modelResolver The model resolver to use, never {@code null}. 312 * @return This request, never {@code null}. 313 */ 314 ModelBuildingRequest setModelResolver(ModelResolver modelResolver); 315 316 /** 317 * Gets the model building listener to notify during the build process. 318 * 319 * @return The model building listener to notify or {@code null} if none. 320 */ 321 ModelBuildingListener getModelBuildingListener(); 322 323 /** 324 * Sets the model building listener to notify during the build process. 325 * 326 * @param modelBuildingListener The model building listener to notify, may be {@code null}. 327 * @return This request, never {@code null}. 328 */ 329 ModelBuildingRequest setModelBuildingListener(ModelBuildingListener modelBuildingListener); 330 331 /** 332 * Gets the model cache to use for reuse of previously built models. 333 * 334 * @return The model cache or {@code null} if not set. 335 */ 336 ModelCache getModelCache(); 337 338 /** 339 * Sets the model cache to use for reuse of previously built models. This is an optional component that serves 340 * performance optimizations. 341 * 342 * @param modelCache The model cache to use, may be {@code null}. 343 * @return This request, never {@code null}. 344 */ 345 ModelBuildingRequest setModelCache(ModelCache modelCache); 346 347 WorkspaceModelResolver getWorkspaceModelResolver(); 348 349 ModelBuildingRequest setWorkspaceModelResolver(WorkspaceModelResolver workspaceResolver); 350 351 TransformerContextBuilder getTransformerContextBuilder(); 352 353 ModelBuildingRequest setTransformerContextBuilder(TransformerContextBuilder contextBuilder); 354 }