View Javadoc

1   package org.apache.maven.project;
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 org.apache.maven.artifact.Artifact;
23  import org.apache.maven.artifact.repository.ArtifactRepository;
24  import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
25  import org.apache.maven.artifact.resolver.ArtifactResolutionException;
26  import org.apache.maven.profiles.ProfileManager;
27  import org.apache.maven.project.interpolation.ModelInterpolationException;
28  import org.apache.maven.wagon.events.TransferListener;
29  
30  import java.io.File;
31  import java.util.List;
32  
33  public interface MavenProjectBuilder
34  {
35      String ROLE = MavenProjectBuilder.class.getName();
36  
37      String STANDALONE_SUPERPOM_GROUPID = "org.apache.maven";
38  
39      String STANDALONE_SUPERPOM_ARTIFACTID = "super-pom";
40  
41      String STANDALONE_SUPERPOM_VERSION = "2.0";
42  
43      MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager )
44          throws ProjectBuildingException;
45  
46      MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager,
47                          boolean checkDistributionManagementStatus )
48          throws ProjectBuildingException;
49  
50      // ----------------------------------------------------------------------
51      // These methods are used by the MavenEmbedder
52      // ----------------------------------------------------------------------
53  
54      MavenProject buildWithDependencies( File project, ArtifactRepository localRepository,
55                                          ProfileManager globalProfileManager, TransferListener transferListener )
56          throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException;
57  
58      MavenProject buildWithDependencies( File project, ArtifactRepository localRepository,
59                                          ProfileManager globalProfileManager )
60          throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException;
61  
62      // ----------------------------------------------------------------------
63      //
64      // ----------------------------------------------------------------------
65  
66      /**
67       * Build the artifact from the local repository, resolving it if necessary.
68       *
69       * @param artifact the artifact description
70       * @param localRepository the local repository
71       * @param remoteArtifactRepositories the remote repository list
72       * @return the built project
73       * @throws ProjectBuildingException
74       */
75      MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
76                                        ArtifactRepository localRepository )
77          throws ProjectBuildingException;
78  
79      /**
80       * Build the artifact from the local repository, resolving it if necessary.
81       *
82       * @param artifact the artifact description
83       * @param localRepository the local repository
84       * @param remoteArtifactRepositories the remote repository list
85       * @param allowStubModel return a stub if the POM is not found
86       * @return the built project
87       * @throws ProjectBuildingException
88       */
89      MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
90                                        ArtifactRepository localRepository, boolean allowStubModel )
91          throws ProjectBuildingException;
92  
93      /**
94       * @deprecated Use {@link MavenProjectBuilder#buildStandaloneSuperProject(ProjectBuilderConfiguration)} instead.
95       */
96      MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository )
97          throws ProjectBuildingException;
98  
99      /**
100      * need to pass a profilemanager with correct context (eg. with execution properties)
101      * @deprecated Use {@link MavenProjectBuilder#buildStandaloneSuperProject(ProjectBuilderConfiguration)} instead.
102      */
103     MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager )
104         throws ProjectBuildingException;
105 
106     MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config )
107         throws ProjectBuildingException;
108 
109     MavenProject build( File pom,
110                         ProjectBuilderConfiguration config )
111         throws ProjectBuildingException;
112 
113     MavenProject build( File pom,
114                         ProjectBuilderConfiguration config,
115                         boolean checkDistributionManagementStatus )
116         throws ProjectBuildingException;
117 
118  // ----------------------------------------------------------------------------
119  // API BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM.
120  // ----------------------------------------------------------------------------
121 
122     /**
123      * Variant of {@link MavenProjectBuilder#calculateConcreteState(MavenProject, ProjectBuilderConfiguration, boolean)}
124      * which assumes that project references should be processed. This is provided for performance reasons, for cases
125      * where you know all projects in the reactor will be processed, making traversal of project references unnecessary.
126      */
127     void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config )
128         throws ModelInterpolationException;
129 
130     /**
131      * Up to this point, the build section of the POM remains uninterpolated except for the artifact coordinates
132      * it contains. This method will interpolate the build section and associated project-instance data
133      * structures. Along with the {@link MavenProjectBuilder#restoreDynamicState(MavenProject, ProjectBuilderConfiguration, boolean)}
134      * method, this method allows expressions in these areas of the POM and project instance to
135      * be reevaluated in the event that a mojo changes one the build-path values, or a project property.
136      * <br/><br/>
137      * This method will process the following:
138      * <ol>
139      *   <li>the specified project's parent project (if not null)</li>
140      *   <li>specified project</li>
141      *   <li>its execution project (if not null)</li>
142      *   <li>any project references (iff processReferences == true)</li>
143      * </ol>
144      */
145     void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config, boolean processReferences )
146         throws ModelInterpolationException;
147 
148 //    /**
149 //     * Variant of {@link MavenProjectBuilder#restoreDynamicState(MavenProject, ProjectBuilderConfiguration, boolean)}
150 //     * which assumes that project references should be processed. This is provided for performance reasons, for cases
151 //     * where you know all projects in the reactor will be processed, making traversal of project references unnecessary.
152 //     */
153 //    void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config )
154 //        throws ModelInterpolationException;
155 //    
156 //    /**
157 //     * In the event that a mojo execution has changed one or more build paths, or changed the project properties,
158 //     * this method can restore the build section of the POM to its uninterpolated form, to allow reevaluation of
159 //     * any expressions that may depend on this changed information. This method will short-circuit if the project
160 //     * is not in a concrete state (see {@link MavenProjectBuilder#calculateConcreteState(MavenProject, ProjectBuilderConfiguration, boolean)}
161 //     * or if the properties and build paths of the project remain unchanged.
162 //     * <br/><br/>
163 //     * This method will process the following:
164 //     * <ol>
165 //     *   <li>the specified project's parent project (if not null)</li>
166 //     *   <li>specified project</li>
167 //     *   <li>its execution project (if not null)</li>
168 //     *   <li>any project references (iff processReferences == true)</li>
169 //     * </ol>
170 //     */
171 //    void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config, boolean processReferences )
172 //        throws ModelInterpolationException;
173 }