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