Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MJAVADOC-697] Allowing to register alternative Javadoc implementation #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ public abstract class AbstractJavadocMojo
@Component
private DependencyResolver dependencyResolver;

@Component
private List<JavadocImplementation> javadocInvocators;

/**
* Project builder
*
Expand Down Expand Up @@ -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() );

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}