Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Javadoc - Unable to generate Javadoc

I have the following dependency and build in my pom file. I'm able to manually create the javadoc with a Maven command. I can also succesfully perform a build. The output doesn't mention javadoc at all. I've also tried leaving out the output directory paths. POM File Dependency section:

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.8</version>
</dependency>

and then the build section:

<build>
    <finalName>D</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.8</version>
            <configuration> 
                <outputDirectory>${project.build.directory}/javadoc</outputDirectory>
                <reportOutputDirectory>${project.reporting.outputDirectory}/javadoc</reportOutputDirectory>
                <version>2.8</version>
            </configuration>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
like image 744
user994165 Avatar asked Dec 04 '25 19:12

user994165


1 Answers

The Maven Javadoc plugin doesn't run by default and needs to be bound to one of the default Maven lifecycle phases.

Here's how I would write the plugin's configuration:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.8</version>
        <configuration> 
            <outputDirectory>${project.build.directory}/javadoc</outputDirectory>
            <reportOutputDirectory>${project.reporting.outputDirectory}/javadoc</reportOutputDirectory>
        </configuration>
        <executions>
            <execution>
                <id>attach-javadocs</id>
                <phase>site</phase>
                <goals>
                    <goal>aggregate</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

Notice how I added an extra phase element to the execution. This will bind it to the "site" goal so that javadocs are generated when you run mvn site. Check Introduction to the Build Lifecycle if you want one of the default Java build phases.

Also note that I ditched the version parameter; by default, it should use your POM's version anyway.

like image 61
JBert Avatar answered Dec 06 '25 08:12

JBert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!