简体   繁体   English

Maven Javadoc - 无法生成Javadoc

[英]Maven Javadoc - Unable to generate Javadoc

I have the following dependency and build in my pom file. 我有以下依赖项并在我的pom文件中构建。 I'm able to manually create the javadoc with a Maven command. 我可以使用Maven命令手动创建javadoc。 I can also succesfully perform a build. 我也可以成功地执行构建。 The output doesn't mention javadoc at all. 输出根本没有提到javadoc。 I've also tried leaving out the output directory paths. 我也试过省略输出目录路径。 POM File Dependency section: POM文件依赖部分:

<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>

The Maven Javadoc plugin doesn't run by default and needs to be bound to one of the default Maven lifecycle phases. Maven Javadoc插件默认不运行,需要绑定到默认的Maven生命周期阶段之一。

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. 注意我是如何在执行中添加额外的phase元素的。 This will bind it to the "site" goal so that javadocs are generated when you run mvn site . 这会将其绑定到“站点”目标,以便在运行mvn site时生成javadoc。 Check Introduction to the Build Lifecycle if you want one of the default Java build phases. 如果您需要一个默认的Java构建阶段,请检查构建生命周期简介

Also note that I ditched the version parameter; 还要注意我抛弃了version参数; by default, it should use your POM's version anyway. 默认情况下,它应该使用您的POM版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM