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