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.model.building;
20  
21  import org.apache.maven.model.locator.ModelLocator;
22  
23  /**
24   * Enhancement to the {@link ModelSource2} to support locating POM files using the {@link ModelLocator}
25   * when pointing to a directory.
26   */
27  public interface ModelSource3 extends ModelSource2 {
28      /**
29       * Returns model source identified by a path relative to this model source POM. Implementation <strong>MUST</strong>
30       * accept <code>relPath</code> parameter values that
31       * <ul>
32       * <li>use either / or \ file path separator</li>
33       * <li>have .. parent directory references</li>
34       * <li>point either at file or directory</li>
35       * </ul>
36       * If the given path points at a directory, the provided {@code ModelLocator} will be used
37       * to find the POM file, else if no locator is provided, a file named 'pom.xml' needs to be
38       * used by the requested model source.
39       *
40       * @param locator locator used to locate the pom file
41       * @param relPath path of the requested model source relative to this model source POM
42       * @return related model source or <code>null</code> if no such model source
43       */
44      ModelSource3 getRelatedSource(ModelLocator locator, String relPath);
45  
46      /**
47       * When using a ModelSource3, the method with a {@code ModelLocator} argument should
48       * be used instead.
49       *
50       * @deprecated use {@link #getRelatedSource(ModelLocator, String)} instead
51       */
52      @Deprecated
53      default ModelSource3 getRelatedSource(String relPath) {
54          return getRelatedSource(null, relPath);
55      }
56  }