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.plugin;
20  
21  import org.apache.maven.execution.MavenSession;
22  import org.apache.maven.plugin.descriptor.MojoDescriptor;
23  import org.eclipse.aether.RepositorySystemSession;
24  import org.eclipse.aether.artifact.Artifact;
25  
26  /**
27   * Component collecting plugin validation issues and reporting them.
28   *
29   * @since 3.9.2
30   */
31  public interface PluginValidationManager {
32      enum IssueLocality {
33          /**
34           * Issue is "user actionable", is internal to the currently built project and is reparable from scope of it
35           * by doing some change (for example by changing POM and fixing the problematic plugin configuration).
36           */
37          INTERNAL,
38  
39          /**
40           * Issue (present in some plugin) is "developer actionable" (of given plugin, by changing code and doing
41           * new release), is NOT local to the currently built project. It may be reparable by updating given plugin
42           * to new fixed version, or by dropping plugin use from currently built project.
43           * <p>
44           * Note: if a reactor build contains a plugin (with issues) and later that built plugin is used in build,
45           * it will be reported as "external". It is up to developer to correctly interpret output (GAV) of issues
46           * and realize that in this case he wears two hats:" "user" and "(plugin) developer".
47           */
48          EXTERNAL
49      }
50  
51      /**
52       * Reports plugin issues applicable to the plugin as a whole.
53       * <p>
54       * This method should be used in "early" phase of plugin execution, possibly even when plugin or mojo descriptor
55       * does not exist yet. In turn, this method will not record extra information like plugin occurrence or declaration
56       * location as those are not yet available.
57       */
58      void reportPluginValidationIssue(
59              IssueLocality locality, RepositorySystemSession session, Artifact pluginArtifact, String issue);
60  
61      /**
62       * Reports plugin issues applicable to the plugin as a whole.
63       * <p>
64       * This method will record extra information as well, like plugin occurrence or declaration location.
65       */
66      void reportPluginValidationIssue(
67              IssueLocality locality, MavenSession mavenSession, MojoDescriptor mojoDescriptor, String issue);
68  
69      /**
70       * Reports plugin Mojo issues applicable to the Mojo itself.
71       * <p>
72       * This method will record extra information as well, like plugin occurrence or declaration location.
73       */
74      void reportPluginMojoValidationIssue(
75              IssueLocality locality,
76              MavenSession mavenSession,
77              MojoDescriptor mojoDescriptor,
78              Class<?> mojoClass,
79              String issue);
80  }