Skip to content

Commit 5d4d7f3

Browse files
committed
Documentation fixes and more straightforward policy for showing or not the stack trace.
#323
1 parent 195a809 commit 5d4d7f3

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
import org.apache.maven.api.services.DependencyResolver;
7373
import org.apache.maven.api.services.DependencyResolverRequest;
7474
import org.apache.maven.api.services.DependencyResolverResult;
75+
import org.apache.maven.api.services.MavenException;
7576
import org.apache.maven.api.services.MessageBuilder;
7677
import org.apache.maven.api.services.MessageBuilderFactory;
7778
import org.apache.maven.api.services.ProjectManager;
@@ -344,8 +345,8 @@ final Charset charset() {
344345
* @see <a href="https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing">javac Annotation Processing</a>
345346
* @since 3.5
346347
*
347-
* @deprecated Replaced by ordinary dependencies with {@code <type>} element
348-
* set to {@code proc}, {@code classpath-proc} or {@code modular-proc}.
348+
* @deprecated Replaced by ordinary dependencies with {@code <type>} element set to
349+
* {@code processor}, {@code classpath-processor} or {@code modular-processor}.
349350
*/
350351
@Parameter
351352
@Deprecated(since = "4.0.0")
@@ -1075,8 +1076,7 @@ public void execute() throws MojoException {
10751076
.builder()
10761077
.strong("COMPILATION ERROR: ")
10771078
.a(message);
1078-
// Do not log stack trace for `CompilationFailureException` because they are not unexpected.
1079-
logger.error(mb.toString(), e instanceof CompilationFailureException ? null : e);
1079+
logger.error(mb.toString(), verbose ? e : null);
10801080
if (tipForCommandLineCompilation != null) {
10811081
logger.info(tipForCommandLineCompilation);
10821082
tipForCommandLineCompilation = null;
@@ -1102,9 +1102,10 @@ public void execute() throws MojoException {
11021102
* provided that the {@link #logger} is thread-safe.
11031103
*
11041104
* @param listener where to send compilation warnings, or {@code null} for the Maven logger
1105-
* @throws MojoException if this method identifies an invalid parameter in this <abbr>MOJO</abbr>
11061105
* @return the task to execute for compiling the project using the configuration in this <abbr>MOJO</abbr>
1106+
* @throws MojoException if this method identifies an invalid parameter in this <abbr>MOJO</abbr>
11071107
* @throws IOException if an error occurred while creating the output directory or scanning the source directories
1108+
* @throws MavenException if an error occurred while fetching dependencies
11081109
*/
11091110
public ToolExecutor createExecutor(DiagnosticListener<? super JavaFileObject> listener) throws IOException {
11101111
var executor = new ToolExecutor(this, listener);
@@ -1398,6 +1399,8 @@ final String parseModuleInfoName(Path source) throws IOException {
13981399
* any filename-based dependency and this MOJO is compiling the main code, then a warning will be logged.
13991400
*
14001401
* @param hasModuleDeclaration whether to allow placement of dependencies on the module-path.
1402+
* @throws IOException if an I/O error occurred while fetching dependencies
1403+
* @throws MavenException if an error occurred while fetching dependencies for a reason other than I/O.
14011404
*/
14021405
final DependencyResolverResult resolveDependencies(boolean hasModuleDeclaration) throws IOException {
14031406
DependencyResolver resolver = session.getService(DependencyResolver.class);
@@ -1460,8 +1463,8 @@ final DependencyResolverResult resolveDependencies(boolean hasModuleDeclaration)
14601463
* @param addTo the modifiable map and lists where to append more paths to annotation processor dependencies
14611464
* @throws MojoException if an error occurred while resolving the dependencies
14621465
*
1463-
* @deprecated Replaced by ordinary dependencies with {@code <type>} element
1464-
* set to {@code proc}, {@code classpath-proc} or {@code modular-proc}.
1466+
* @deprecated Replaced by ordinary dependencies with {@code <type>} element set to
1467+
* {@code processor}, {@code classpath-processor} or {@code modular-processor}.
14651468
*/
14661469
@Deprecated(since = "4.0.0")
14671470
final void resolveProcessorPathEntries(Map<PathType, List<Path>> addTo) throws MojoException {

src/main/java/org/apache/maven/plugin/compiler/ToolExecutor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.apache.maven.api.plugin.Log;
5353
import org.apache.maven.api.plugin.MojoException;
5454
import org.apache.maven.api.services.DependencyResolverResult;
55+
import org.apache.maven.api.services.MavenException;
5556

5657
/**
5758
* A task which configures and executes a Java tool such as the Java compiler.
@@ -193,6 +194,7 @@ public class ToolExecutor {
193194
* @param listener where to send compilation warnings, or {@code null} for the Maven logger
194195
* @throws MojoException if this constructor identifies an invalid parameter in the <abbr>MOJO</abbr>
195196
* @throws IOException if an error occurred while creating the output directory or scanning the source directories
197+
* @throws MavenException if an error occurred while fetching dependencies
196198
*
197199
* @see AbstractCompilerMojo#createExecutor(DiagnosticListener)
198200
*/

0 commit comments

Comments
 (0)