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