View Javadoc
1   package org.apache.maven.shared.dependency.graph;
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.resolver.filter.ArtifactFilter;
23  import org.apache.maven.project.MavenProject;
24  
25  import java.util.Collection;
26  
27  /**
28   * Maven project dependency graph builder API, neutral against Maven 2 or Maven 3.
29   *
30   * @author Hervé Boutemy
31   * @since 2.0
32   */
33  public interface DependencyGraphBuilder
34  {
35      /**
36       * Build the dependency graph.
37       *
38       * @param project the project
39       * @param filter artifact filter (can be <code>null</code>)
40       * @return the dependency graph
41       * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
42       */
43      DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter )
44          throws DependencyGraphBuilderException;
45  
46      /**
47       * Build the dependency graph, with a hack to include dependencies contained in the reactor projects
48       * but that are not yet compiled, which is the minimum prerequisite for Maven core's
49       * ReactorReader to find them. Notice that this hack hasn't been done for Maven 2.
50       * <p>Notice: If Maven core did collect instead of resolving dependencies (ie did not try to get the
51       * artifacts but only the poms), probably this hack wouldn't be necessary even for people requiring
52       * the dependency graph before compiling. TODO: for Maven 3, use Aether to collect dependencies.</p>
53       *
54       * @param project the project
55       * @param filter artifact filter (can be <code>null</code>)
56       * @param reactorProjects Collection of those projects contained in the reactor (can be <code>null</code>).
57       * @return the dependency graph
58       * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
59       */
60      DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
61                                           Collection<MavenProject> reactorProjects )
62          throws DependencyGraphBuilderException;
63  }