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.tools.plugin;
20  
21  import java.net.URI;
22  import java.util.List;
23  import java.util.Set;
24  
25  import org.apache.maven.artifact.Artifact;
26  import org.apache.maven.plugin.descriptor.PluginDescriptor;
27  import org.apache.maven.project.MavenProject;
28  import org.apache.maven.settings.Settings;
29  import org.eclipse.aether.RepositorySystemSession;
30  
31  /**
32   * Request that encapsulates all information relevant to the process of extracting
33   * {@link org.apache.maven.plugin.descriptor.MojoDescriptor MojoDescriptor}
34   * instances from metadata for a certain type of mojo.
35   *
36   * @author jdcasey
37   * @since 2.5
38   */
39  public interface PluginToolsRequest {
40  
41      /**
42       * @return Return the current {@link MavenProject} instance in use.
43       */
44      MavenProject getProject();
45  
46      /**
47       * @param project the current {@link MavenProject}
48       * @see PluginToolsRequest#getProject()
49       * @return This request.
50       */
51      PluginToolsRequest setProject(MavenProject project);
52  
53      /**
54       * @return Return the {@link PluginDescriptor} currently being populated as part of the build of the
55       * current plugin project.
56       */
57      PluginDescriptor getPluginDescriptor();
58  
59      /**
60       * @see PluginToolsRequest#getPluginDescriptor()
61       * @param pluginDescriptor the {@link PluginDescriptor}
62       * @return This request.
63       */
64      PluginToolsRequest setPluginDescriptor(PluginDescriptor pluginDescriptor);
65  
66      /**
67       * Gets the file encoding of the source files.
68       *
69       * @return The file encoding of the source files, never <code>null</code>.
70       */
71      String getEncoding();
72  
73      /**
74       * Sets the file encoding of the source files.
75       *
76       * @param encoding The file encoding of the source files, may be empty or <code>null</code> to use the platform's
77       *                 default encoding.
78       * @return This request.
79       */
80      PluginToolsRequest setEncoding(String encoding);
81  
82      /**
83       * By default an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the
84       * descriptor generator mojo is bound to generate-resources phase.
85       * But for annotations, the compiled classes are needed, so skip error
86       * @param skipErrorNoDescriptorsFound <code>true</code> to skip errors because of not found descriptors
87       * @return This request.
88       * @since 3.0
89       */
90      PluginToolsRequest setSkipErrorNoDescriptorsFound(boolean skipErrorNoDescriptorsFound);
91  
92      /**
93       * @return <code>true</code> if no descriptor found should not cause a failure
94       * @since 3.0
95       */
96      boolean isSkipErrorNoDescriptorsFound();
97  
98      /**
99       * Returns the list of {@link Artifact} used in class path scanning for annotations
100      *
101      * @return the dependencies
102      * @since 3.0
103      */
104     Set<Artifact> getDependencies();
105 
106     /**
107      * @param dependencies the dependencies
108      * @return This request.
109      * @since 3.0
110      */
111     PluginToolsRequest setDependencies(Set<Artifact> dependencies);
112 
113     /**
114      * Return a Repository Session
115      *
116      * @return a Repository Session
117      * @since 3.8.2
118      */
119     RepositorySystemSession getRepoSession();
120 
121     /**
122      * Set a Repository Session
123      *
124      * @param repoSession a Repository Session
125      * @since 3.8.2
126      */
127     void setRepoSession(RepositorySystemSession repoSession);
128 
129     /**
130      * @param baseUrl may be relative to the current site's root
131      * @return This request.
132      * @since 3.7.0
133      */
134     PluginToolsRequest setInternalJavadocBaseUrl(URI baseUrl);
135 
136     /**
137      * @return the javadoc base url for the internal classes
138      * @since 3.7.0
139      */
140     URI getInternalJavadocBaseUrl();
141 
142     /**
143      *
144      * @param javadocVersion
145      * @return This request.
146      * @since 3.7.0
147      */
148     PluginToolsRequest setInternalJavadocVersion(String javadocVersion);
149 
150     /**
151      * @return the javadoc version used to create the internal javadoc site
152      * @since 3.7.0
153      */
154     String getInternalJavadocVersion();
155 
156     /**
157      *
158      * @param javadocLinks
159      * @return This request.
160      * @since 3.7.0
161      */
162     PluginToolsRequest setExternalJavadocBaseUrls(List<URI> javadocLinks);
163 
164     /**
165      * @return the list of external javadoc base urls to consider
166      * @since 3.7.0
167      */
168     List<URI> getExternalJavadocBaseUrls();
169 
170     /**
171      * @param settings the Maven settings
172      * @return This request.
173      * @since 3.7.0
174      */
175     PluginToolsRequest setSettings(Settings settings);
176 
177     /**
178      * @return the Maven settings
179      * @since 3.7.0
180      */
181     Settings getSettings();
182 
183     /**
184      *
185      * @param requiredJavaVersion the required Java version for this plugin or {@code null} if unknown.
186      *  Must be a value according to semantics of {@link org.eclipse.aether.version.VersionConstraint}.
187      * @return This request.
188      * @since 3.8.0
189      */
190     PluginToolsRequest setRequiredJavaVersion(String requiredJavaVersion);
191 
192     /**
193      *
194      * @return the required Java version for this plugin or {@code null} if unknown.
195      *  Is a value according to semantics of {@link org.eclipse.aether.version.VersionConstraint}.
196      * @since 3.8.0
197      */
198     String getRequiredJavaVersion();
199 
200     /**
201      *
202      * @param mavenApiVersion
203      * @return his request.
204      * @since 3.8.0
205      */
206     PluginToolsRequest setUsedMavenApiVersion(String mavenApiVersion);
207 
208     /**
209      *
210      * @return the Maven API version being referenced or {@code null} if unknown
211      * @since 3.8.0
212      */
213     String getUsedMavenApiVersion();
214 }