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.cling.executor;
20  
21  import java.util.Map;
22  
23  import org.apache.maven.api.annotations.Nullable;
24  import org.apache.maven.api.cli.ExecutorException;
25  import org.apache.maven.api.cli.ExecutorRequest;
26  
27  /**
28   * A tool implementing some common Maven operations.
29   */
30  public interface ExecutorTool {
31      /**
32       * Performs a diagnostic dump of the environment.
33       *
34       * @param request never {@code null}
35       */
36      Map<String, String> dump(ExecutorRequest.Builder request) throws ExecutorException;
37  
38      /**
39       * Returns the location of local repository, as detected by Maven. The {@code userSettings} param may contain
40       * some override (equivalent of {@code -s settings.xml} on CLI).
41       *
42       * @param request never {@code null}
43       */
44      String localRepository(ExecutorRequest.Builder request) throws ExecutorException;
45  
46      /**
47       * Returns relative (to {@link #localRepository(ExecutorRequest.Builder)}) path of given artifact in local repository.
48       *
49       * @param request never {@code null}
50       * @param gav the usual resolver artifact GAV string, never {@code null}
51       * @param repositoryId the remote repository ID in case "remote artifact" is asked for
52       */
53      String artifactPath(ExecutorRequest.Builder request, String gav, @Nullable String repositoryId)
54              throws ExecutorException;
55  
56      /**
57       * Returns relative (to {@link #localRepository(ExecutorRequest.Builder)}) path of given metadata in local repository.
58       * The metadata coordinates in form of {@code [G]:[A]:[V]:[type]}. Absence of {@code A} implies absence of {@code V}
59       * as well (in other words, it can be {@code G}, {@code G:A} or {@code G:A:V}). The absence of {@code type} implies
60       * it is "maven-metadata.xml". The simplest spec string is {@code :::}.
61       * <p>
62       * Examples:
63       * <ul>
64       *     <li>{@code :::} is root metadata named "maven-metadata.xml"</li>
65       *     <li>{@code :::my-metadata.xml} is root metadata named "my-metadata.xml"</li>
66       *     <li>{@code G:::} equals to {@code G:::maven-metadata.xml}</li>
67       *     <li>{@code G:A::} equals to {@code G:A::maven-metadata.xml}</li>
68       * </ul>
69       *
70       * @param request never {@code null}
71       * @param gav the resolver metadata GAV string
72       * @param repositoryId the remote repository ID in case "remote metadata" is asked for
73       */
74      String metadataPath(ExecutorRequest.Builder request, String gav, @Nullable String repositoryId)
75              throws ExecutorException;
76  }