diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java index cb68f865f..b18df3a56 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -293,6 +293,9 @@ public abstract class AbstractJavadocMojo @Component private DependencyResolver dependencyResolver; + @Component + private List javadocInvocators; + /** * Project builder * @@ -5721,7 +5724,16 @@ private void executeJavadocCommandLine( Commandline cmd, File javadocOutputDirec CommandLineUtils.StringStreamConsumer out = new JavadocUtil.JavadocOutputStreamConsumer(); try { - int exitCode = CommandLineUtils.executeCommandLine( cmd, out, err ); + getLog().debug( "javadocInvocators: " + javadocInvocators ); + int exitCode; + if ( javadocInvocators.isEmpty() ) + { + exitCode = CommandLineUtils.executeCommandLine( cmd, out, err ); + } + else + { + exitCode = javadocInvocators.get( 0 ).execute( cmd, out, err ); + } String output = ( StringUtils.isEmpty( out.getOutput() ) ? null : '\n' + out.getOutput().trim() ); diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocImplementation.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocImplementation.java new file mode 100644 index 000000000..11431d615 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocImplementation.java @@ -0,0 +1,39 @@ +package org.apache.maven.plugins.javadoc; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; + +/** + * Alternative way to invoke Javadoc. By default the system uses + * {@link CommandLineUtils#executeCommandLine} + * to invoke the {@code javadoc} command. By registering a different + * implementation of {@code JavadocImplementation}, one can change the way + * the {@code javadoc} tool is invoked. + */ +public interface JavadocImplementation +{ + int execute( + org.codehaus.plexus.util.cli.Commandline cmd, + org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer out, + org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer err + ) throws CommandLineException; +}