Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip Dependencies in javadocs - Maven javadoc stuck because of invalid repository URL

My Maven POM uses

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.9</version>
    <configuration>
        <show>public</show>
        <failOnError>false</failOnError>
    </configuration>
</plugin>

in the reporting part. Everything seems to be ok, but at some point it tries to generate the dependencies report and it gets stuck forever because it cannot access a repository URL (that is not up). Getting this error:

[INFO] Generating "Dependencies" report    --- maven-project-info-reports-plugin:2.5.1
[WARNING] The repository url 'file://${basedir}/stage' is invalid - Repository 'local-mime4j-stage-repository' will be blacklisted.
[WARNING] The repository url 'http://antlr.org/antlr-snapshot' is invalid - Repository 'antlr-snapshot' will be blacklisted.

After that, it keeps waiting forever causing I don't have build. So my question is how can I tell javadoc to exclude this step and not try to generate dependencies report?

like image 318
antonio.fornie Avatar asked Feb 13 '13 14:02

antonio.fornie


People also ask

How do I fix javadoc errors?

You need to call mvn javadoc:fix to fix main Java source files (i.e. inside src/main/java directory) or mvn javadoc:test-fix to fix test Java source files (i.e. inside src/test/java directory).

Which will prevent javadoc from being generated while using Doclint?

The magic incantation you need is -Xdoclint:none . This goes on the command line invoking Javadoc.

How do I publish a javadoc?

In the Goals field, place javadoc:javadoc —this will tell Maven to generate the Javadoc documentation. Now go to the “Post-build Action” and tick the “Publish Javadoc” checkbox. This project is a multimodule project, so a separate subdirectory is generated for each module (core, services, web and so forth).


2 Answers

http://www.java-tutorial.ch/maven/maven-site-build-slow-due-to-dependency-report-plugin has a pretty good description of how to turn off dependency location checking from either the command line or in your POM file.

To summarize:

  1. Commandline:

    mvn -Ddependency.locations.enabled=false site
    
  2. POM:

    <plugin>
      <artifactId>maven-project-info-reports-plugin</artifactId>
      <configuration>
         <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
      </configuration>
    </plugin>
    
like image 98
Thomas Taylor Avatar answered Sep 27 '22 02:09

Thomas Taylor


Actually the problem was not related to the maven-javadoc-plugin, but it seemed so when reading the logs. It was in the default goals when running the site lifecycle. Even if I removed all my plugins I would have this problem when running $mvn site.

This was because of the site generation trying to get information about my projects dependencies. It seems the best way to avoid this could be disabling the retrieval of this information (since some of the repository urls where not valid) by putting some property to false... BUT nothing like this really worked for me. Only the following worked:

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>2.6</version>
                    <reportSets>
                        <reportSet>
                            <reports>
                                <report>index</report>
                                <report>help</report>
                                <report>project-team</report>
                                <report>modules</report>
                                <report>plugins</report>
                                <report>cim</report>
                                <report>issue-tracking</report>
                                <report>scm</report>
                                <report>license</report>
                                <report>plugin-management</report>
                                <report>distribution-management</report>
                                <report>summary</report>
                                <report>mailing-list</report>
                                <report>issue-tracking</report>
                                <!--
                                <report>dependencies</report>
                                -->
                            </reports>
                        </reportSet>
                    </reportSets>
                </plugin>

Which means, I tell the site plugins not to create anything related to my dependencies in the site. You see that from the original list of reports in the site I only dded the ones I want. But if you look for site generation with the maven-project-info-reports-plugin many people had also this problems about the build taking way too much time and how to solve it. I hope this helps the next victim.

like image 20
antonio.fornie Avatar answered Sep 25 '22 02:09

antonio.fornie