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.project; 20 21 import java.time.Instant; 22 import java.util.Date; 23 import java.util.List; 24 import java.util.Properties; 25 26 import org.apache.maven.artifact.repository.ArtifactRepository; 27 import org.apache.maven.model.Profile; 28 import org.eclipse.aether.RepositorySystemSession; 29 30 /** 31 * ProjectBuildingRequest 32 */ 33 public interface ProjectBuildingRequest { 34 35 ProjectBuildingRequest setLocalRepository(ArtifactRepository localRepository); 36 37 ArtifactRepository getLocalRepository(); 38 39 ProjectBuildingRequest setRemoteRepositories(List<ArtifactRepository> remoteRepositories); 40 41 List<ArtifactRepository> getRemoteRepositories(); 42 43 ProjectBuildingRequest setPluginArtifactRepositories(List<ArtifactRepository> pluginArtifactRepositories); 44 45 List<ArtifactRepository> getPluginArtifactRepositories(); 46 47 /** 48 * Sets the system properties to use for interpolation and profile activation. The system properties are collected 49 * from the runtime environment like {@link System#getProperties()} and environment variables. 50 * 51 * @param systemProperties The system properties, may be {@code null}. 52 * @return This request, never {@code null}. 53 */ 54 ProjectBuildingRequest setSystemProperties(Properties systemProperties); 55 56 /** 57 * Gets the system properties to use for interpolation and profile activation. The system properties are collected 58 * from the runtime environment like {@link System#getProperties()} and environment variables. 59 * 60 * @return The system properties, never {@code null}. 61 */ 62 Properties getSystemProperties(); 63 64 /** 65 * Sets the user properties to use for interpolation and profile activation. The user properties have been 66 * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command 67 * line. 68 * 69 * @param userProperties The user properties, may be {@code null}. 70 * @return This request, never {@code null}. 71 */ 72 ProjectBuildingRequest setUserProperties(Properties userProperties); 73 74 /** 75 * Gets the user properties to use for interpolation and profile activation. The user properties have been 76 * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command 77 * line. 78 * 79 * @return The user properties, never {@code null}. 80 */ 81 Properties getUserProperties(); 82 83 void setProject(MavenProject mavenProject); 84 85 MavenProject getProject(); 86 87 ProjectBuildingRequest setProcessPlugins(boolean processPlugins); 88 89 boolean isProcessPlugins(); 90 91 ProjectBuildingRequest setResolveDependencies(boolean resolveDependencies); 92 93 boolean isResolveDependencies(); 94 95 /** 96 * Controls the level of validation to perform on processed models. By default, models are validated in strict mode. 97 * 98 * @param validationLevel The level of validation to perform on processed models, e.g. 99 * {@link org.apache.maven.model.building.ModelBuildingRequest#VALIDATION_LEVEL_STRICT}. 100 * @return This configuration, never {@code null}. 101 */ 102 ProjectBuildingRequest setValidationLevel(int validationLevel); 103 104 /** 105 * Gets the level of validation to perform on processed models. 106 * 107 * @return The level of validation to perform on processed models. 108 */ 109 int getValidationLevel(); 110 111 // Profiles 112 113 /** 114 * Set any active profiles that the {@link ProjectBuilder} should consider while constructing 115 * a {@link MavenProject}. 116 */ 117 void setActiveProfileIds(List<String> activeProfileIds); 118 119 List<String> getActiveProfileIds(); 120 121 void setInactiveProfileIds(List<String> inactiveProfileIds); 122 123 List<String> getInactiveProfileIds(); 124 125 /** 126 * Add a {@link org.apache.maven.model.Profile} that has come from an external source. This may be from a custom 127 * configuration like the MavenCLI settings.xml file, or from a custom dialog in an IDE integration like M2Eclipse. 128 * 129 * @param profile 130 */ 131 void addProfile(Profile profile); 132 133 void setProfiles(List<Profile> profiles); 134 135 List<Profile> getProfiles(); 136 137 /** 138 * Gets the start time of the build. 139 * 140 * @return The start time of the build or {@code null} if unknown. 141 */ 142 @Deprecated 143 Date getBuildStartTime(); 144 145 /** 146 * Sets the start time of the build. 147 * 148 * @param buildStartTime The start time of the build, may be {@code null}. 149 */ 150 @Deprecated 151 void setBuildStartTime(Date buildStartTime); 152 153 /** 154 * Gets the start time of the build. 155 * 156 * @return The start time of the build or {@code null} if unknown. 157 */ 158 Instant getBuildStartInstant(); 159 160 /** 161 * Sets the start time of the build. 162 * 163 * @param buildStartInstant The start time of the build, may be {@code null}. 164 */ 165 void setBuildStartInstant(Instant buildStartInstant); 166 167 RepositorySystemSession getRepositorySession(); 168 169 ProjectBuildingRequest setRepositorySession(RepositorySystemSession repositorySession); 170 171 /** 172 * Sets the merge mode used to combine repositories declared in the POM with the repositories specified in this 173 * request. 174 * 175 * @param mode The repository merge mode, must not be {@code null}. 176 * @return This request for chaining, never {@code null}. 177 * @see #setRemoteRepositories(List) 178 */ 179 ProjectBuildingRequest setRepositoryMerging(RepositoryMerging mode); 180 181 /** 182 * Gets the merge mode used to combine repositories declared in the POM with the repositories specified in this 183 * request 184 * 185 * @return The merge mode, never {@code null}. 186 */ 187 RepositoryMerging getRepositoryMerging(); 188 189 /** 190 * @since 3.2.2 191 * @deprecated This got added when implementing MNG-2199 and is no longer used. 192 * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized. 193 */ 194 @Deprecated 195 boolean isResolveVersionRanges(); 196 197 /** 198 * @since 3.2.2 199 * @deprecated This got added when implementing MNG-2199 and is no longer used. 200 * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized. 201 */ 202 @Deprecated 203 ProjectBuildingRequest setResolveVersionRanges(boolean value); 204 205 /** 206 * The possible merge modes for combining remote repositories. 207 */ 208 enum RepositoryMerging { 209 210 /** 211 * The repositories declared in the POM have precedence over the repositories specified in the request. 212 */ 213 POM_DOMINANT, 214 215 /** 216 * The repositories specified in the request have precedence over the repositories declared in the POM. 217 */ 218 REQUEST_DOMINANT, 219 } 220 }