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.io.File; 022import java.net.URI; 023import java.util.Collection; 024import java.util.List; 025import java.util.Set; 026 027import org.apache.maven.artifact.Artifact; 028import org.apache.maven.plugin.descriptor.PluginDescriptor; 029import org.apache.maven.project.MavenProject; 030import org.apache.maven.settings.Settings; 031import org.eclipse.aether.RepositorySystemSession; 032 033/** 034 * Request that encapsulates all information relevant to the process of extracting 035 * {@link org.apache.maven.plugin.descriptor.MojoDescriptor MojoDescriptor} 036 * instances from metadata for a certain type of mojo. 037 * 038 * @author jdcasey 039 * @since 2.5 040 */ 041public interface PluginToolsRequest { 042 043 /** 044 * @return Return the current {@link MavenProject} instance in use. 045 */ 046 MavenProject getProject(); 047 048 /** 049 * @param project the current {@link MavenProject} 050 * @see PluginToolsRequest#getProject() 051 * @return This request. 052 */ 053 PluginToolsRequest setProject(MavenProject project); 054 055 /** 056 * @return Return the {@link PluginDescriptor} currently being populated as part of the build of the 057 * current plugin project. 058 */ 059 PluginDescriptor getPluginDescriptor(); 060 061 /** 062 * @see PluginToolsRequest#getPluginDescriptor() 063 * @param pluginDescriptor the {@link PluginDescriptor} 064 * @return This request. 065 */ 066 PluginToolsRequest setPluginDescriptor(PluginDescriptor pluginDescriptor); 067 068 /** 069 * Gets the file encoding of the source files. 070 * 071 * @return The file encoding of the source files, never <code>null</code>. 072 */ 073 String getEncoding(); 074 075 /** 076 * Sets the file encoding of the source files. 077 * 078 * @param encoding The file encoding of the source files, may be empty or <code>null</code> to use the platform's 079 * default encoding. 080 * @return This request. 081 */ 082 PluginToolsRequest setEncoding(String encoding); 083 084 /** 085 * By default an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the 086 * descriptor generator mojo is bound to generate-resources phase. 087 * But for annotations, the compiled classes are needed, so skip error 088 * @param skipErrorNoDescriptorsFound <code>true</code> to skip errors because of not found descriptors 089 * @return This request. 090 * @since 3.0 091 */ 092 PluginToolsRequest setSkipErrorNoDescriptorsFound(boolean skipErrorNoDescriptorsFound); 093 094 /** 095 * @return <code>true</code> if no descriptor found should not cause a failure 096 * @since 3.0 097 */ 098 boolean isSkipErrorNoDescriptorsFound(); 099 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}