@@ -0,0 +1,3024 @@
+/*-%0A * Copyright (c) 2014 Red Hat, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.fedoraproject.xmvn.connector.aether;%0A%0Aimport java.io.IOException;%0Aimport java.lang.reflect.Method;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0A%0Aimport javax.inject.Named;%0Aimport javax.inject.Singleton;%0A%0Aimport org.apache.maven.execution.MojoExecutionEvent;%0Aimport org.apache.maven.execution.MojoExecutionListener;%0Aimport org.apache.maven.plugin.Mojo;%0Aimport org.apache.maven.plugin.MojoExecution;%0A%0A/**%0A * Listens to executions of %22aggregate%22 goal of Maven Javadoc Plugin and captures Javadoc report output location.%0A * %0A * @author Mikolaj Izdebski%0A */%0A@Named%0A@Singleton%0Apublic class XMvnJavadocEcecutionListener%0A    implements MojoExecutionListener%0A%7B%0A    private static final String JAVADOC_PLUGIN_GROUPID = %22org.apache.maven.plugins%22;%0A%0A    private static final String JAVADOC_PLUGIN_ARTIFACTID = %22maven-javadoc-plugin%22;%0A%0A    private static final String JAVADOC_PLUGIN_GOAL = %22aggregate%22;%0A%0A    private static final Path XMVN_STATE_DIR = Paths.get( %22.xmvn%22 );%0A%0A    private static final Path APIDOCS_SYMLINK = XMVN_STATE_DIR.resolve( %22apidocs%22 );%0A%0A    @Override%0A    public void afterMojoExecutionSuccess( MojoExecutionEvent event )%0A    %7B%0A        try%0A        %7B%0A            Mojo mojo = event.getMojo();%0A            MojoExecution execution = event.getExecution();%0A%0A            if ( execution.getGroupId().equals( JAVADOC_PLUGIN_GROUPID )%0A                && execution.getArtifactId().equals( JAVADOC_PLUGIN_ARTIFACTID )%0A                && execution.getGoal().equals( JAVADOC_PLUGIN_GOAL ) )%0A            %7B%0A                Method method = mojo.getClass().getMethod( %22getReportOutputDirectory%22 );%0A                Path javadocDir = Paths.get( method.invoke( mojo ).toString() );%0A%0A                if ( !Files.exists( XMVN_STATE_DIR ) )%0A                    Files.createDirectory( XMVN_STATE_DIR );%0A%0A                if ( Files.isSymbolicLink( APIDOCS_SYMLINK ) )%0A                    Files.delete( APIDOCS_SYMLINK );%0A%0A                Files.createSymbolicLink( APIDOCS_SYMLINK, javadocDir );%0A            %7D%0A        %7D%0A        catch ( ReflectiveOperationException %7C IOException e )%0A        %7B%0A            throw new RuntimeException( e );%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void beforeMojoExecution( MojoExecutionEvent event )%0A    %7B%0A        // Nothing to do%0A    %7D%0A%0A    @Override%0A    public void afterExecutionFailure( MojoExecutionEvent event )%0A    %7B%0A        // Nothing to do%0A    %7D%0A%7D%0A

Save javadoc report location in .xmvn/apidocs (rhbz#1106598)