001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.maven.tools.plugin;
020
021import java.net.URI;
022import java.util.List;
023import java.util.Set;
024
025import org.apache.maven.artifact.Artifact;
026import org.apache.maven.plugin.descriptor.PluginDescriptor;
027import org.apache.maven.project.MavenProject;
028import org.apache.maven.settings.Settings;
029import org.eclipse.aether.RepositorySystemSession;
030
031/**
032 * Request that encapsulates all information relevant to the process of extracting
033 * {@link org.apache.maven.plugin.descriptor.MojoDescriptor MojoDescriptor}
034 * instances from metadata for a certain type of mojo.
035 *
036 * @author jdcasey
037 * @since 2.5
038 */
039public interface PluginToolsRequest {
040
041    /**
042     * @return Return the current {@link MavenProject} instance in use.
043     */
044    MavenProject getProject();
045
046    /**
047     * @param project the current {@link MavenProject}
048     * @see PluginToolsRequest#getProject()
049     * @return This request.
050     */
051    PluginToolsRequest setProject(MavenProject project);
052
053    /**
054     * @return Return the {@link PluginDescriptor} currently being populated as part of the build of the
055     * current plugin project.
056     */
057    PluginDescriptor getPluginDescriptor();
058
059    /**
060     * @see PluginToolsRequest#getPluginDescriptor()
061     * @param pluginDescriptor the {@link PluginDescriptor}
062     * @return This request.
063     */
064    PluginToolsRequest setPluginDescriptor(PluginDescriptor pluginDescriptor);
065
066    /**
067     * Gets the file encoding of the source files.
068     *
069     * @return The file encoding of the source files, never <code>null</code>.
070     */
071    String getEncoding();
072
073    /**
074     * Sets the file encoding of the source files.
075     *
076     * @param encoding The file encoding of the source files, may be empty or <code>null</code> to use the platform's
077     *                 default encoding.
078     * @return This request.
079     */
080    PluginToolsRequest setEncoding(String encoding);
081
082    /**
083     * By default an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the
084     * descriptor generator mojo is bound to generate-resources phase.
085     * But for annotations, the compiled classes are needed, so skip error
086     * @param skipErrorNoDescriptorsFound <code>true</code> to skip errors because of not found descriptors
087     * @return This request.
088     * @since 3.0
089     */
090    PluginToolsRequest setSkipErrorNoDescriptorsFound(boolean skipErrorNoDescriptorsFound);
091
092    /**
093     * @return <code>true</code> if no descriptor found should not cause a failure
094     * @since 3.0
095     */
096    boolean isSkipErrorNoDescriptorsFound();
097
098    /**
099     * 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}