当Javadoc标记不完整时,Maven无法在Java 8中工作 [英] Maven is not working in Java 8 when Javadoc tags are incomplete

查看:155
本文介绍了当Javadoc标记不完整时,Maven无法在Java 8中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我使用Maven,因此我能够在我的本地存储库项目中构建和安装具有不完整Javadoc标记的项目(例如,缺少参数)。

Since I use Maven I have been able to build and install in my local repository projects that have incomplete Javadoc tags (for example, a missing parameter).

但是,由于我迁移到Java 8(1.8.0-ea-b90),Maven对于缺少文档标记非常严格,并向我展示了许多与Javadoc相关的Javadoc错误当我尝试构建或安装Javadoc不是完美的项目时出现问题。我试图在我的本地存储库中编译和安装的一些项目是我无法控制的第三方项目。因此,在我的场景中修复所有这些项目中的所有Javadoc的解决方法似乎并不可行。

However, since I migrated to Java 8 (1.8.0-ea-b90) Maven is absolutely strict about missing documentation tags and show me lots of Javadoc errors related to Javadoc problems when I try to build or install a project where the Javadoc is not "perfect". Some of the projects I am trying to compile and install in my local repository are third party projects from which I do not have control. So the workaround of just fixing all the Javadocs in all these projects does not seem to be feasable in my scenario.

这是我看到的输出中的一小部分在我的项目中执行 mvn clean package install

This is a small part of the output I see when I execute mvn clean package install in my project:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.026s
[INFO] Finished at: Mon Apr 08 21:06:17 CEST 2013
[INFO] Final Memory: 27M/437M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9:jar (attach-javadocs) on project jpc: MavenReportException: Error while creating archive:
[ERROR] Exit code: 1 - /Users/sergioc/Documents/workspaces/heal/jpc/src/main/java/org/jpc/engine/prolog/PrologDatabase.java:10: error: @param name not found
[ERROR] * @param terms the terms to assert
[ERROR] ^
[ERROR] /Users/sergioc/Documents/workspaces/heal/jpc/src/main/java/org/jpc/engine/prolog/PrologDatabase.java:11: warning: no description for @return
[ERROR] * @return
[ERROR] ^

Javadoc Maven插件在我的POM中配置如下:

The Javadoc Maven plugin is configured like this in my POM:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.9</version>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

如前所述,如果我回到Java 7,一切正常。
也许这是与Java 8中运行的Maven相关的错误?
如何使用Java 8使其工作(即,能够构建项目的Javadoc并在我的本地存储库中安装其代码)?
我已经在OSX中测试了Maven 3.0.3和3.0.5。

As I said before, everything is working fine if I go back to Java 7. Maybe is this a bug related to Maven running in Java 8? How could I make it work (i.e., being able to build the Javadoc of the project and install its code in my local repository) with Java 8? I have tested with both Maven 3.0.3 and 3.0.5 in OSX.

更新:

如果我用< failOnError> false< / failOnError> 更改我的Javadoc插件配置(感谢Martin):

If I change my Javadoc plugin configuration with <failOnError>false</failOnError> (thanks Martin):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.9</version>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

然后项目安装在我的本地存储库中。但是,仍然没有生成Javadoc JAR。

Then the project is installed in my local repository. However, the Javadoc JAR is still not generated.

我在控制台中看到的具有这种新配置的输出片段是:

A fragment of the output I see in the console with this new configuration is:


[错误] MavenReportException:创建存档时出错:退出
代码:1 - /Users/....java:18:warning:no @param ..命令行
是:/ Library / Java / Home / bin / javadoc @options @packages

[ERROR] MavenReportException: Error while creating archive: Exit code: 1 - /Users/....java:18: warning: no @param ... Command line was: /Library/Java/Home/bin/javadoc @options @packages

请参阅
中生成的Javadoc文件/ Users / sergioc / Documents / workspaces / heal / minitoolbox / target / apidocs'
dir。

Refer to the generated Javadoc files in '/Users/sergioc/Documents/workspaces/heal/minitoolbox/target/apidocs' dir.

at
org.apache.maven.plugin .javadoc.AbstractJavadocMojo.executeJavadocCommandLine(AbstractJavadocMojo.java:5043)
at
org.apache.maven.plugin.javadoc.AbstractJavadocMojo.executeReport(AbstractJavadocMojo.java:1990)
at
org.apache.maven.plugin.javadoc.JavadocJar.execute(JavadocJar.java:181)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java: 101)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at
org.apache.maven.lifecycle.internal。 MojoExecutor.execute(MojoExecutor.java:153)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at
org。 apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter) .java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)at
org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)at
org.apache.maven.cli.MavenCli.main(mavenCli.java:141)at
sun.reflect。 NativeMethodAccessorImpl.invoke0(Native Method)at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:491)at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java) :409)
at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

at org.apache.maven.plugin.javadoc.AbstractJavadocMojo.executeJavadocCommandLine(AbstractJavadocMojo.java:5043) at org.apache.maven.plugin.javadoc.AbstractJavadocMojo.executeReport(AbstractJavadocMojo.java:1990) at org.apache.maven.plugin.javadoc.JavadocJar.execute(JavadocJar.java:181) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:491) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

有关如何构建源代码,安装项目以及生成Javadoc JAR的任何解决方法,因为它是w使用Java 7进行orking?

Any workaround about how to build the sources, install the project and generate the Javadoc JAR in one step as it was working with Java 7?

推荐答案

最好的解决方案是修复javadoc错误。如果由于某种原因不可能(即:自动生成的源代码),那么您可以禁用此检查。

The best solution would be to fix the javadoc errors. If for some reason that is not possible (ie: auto generated source code) then you can disable this check.

DocLint是Java 8中的一项新功能,总结如下:


提供一种方法,可以在
开发周期的早期检测Javadoc注释中的错误,并且可以轻松链接回
源代码。

Provide a means to detect errors in Javadoc comments early in the development cycle and in a way that is easily linked back to the source code.

默认情况下启用此选项,并在生成Javadoc之前运行大量检查。您需要按照指定的关闭Java 8。在这个帖子中。您必须将此添加到您的maven配置中:

This is enabled by default, and will run a whole lot of checks before generating Javadocs. You need to turn this off for Java 8 as specified in this thread. You'll have to add this to your maven configuration:

<profiles>
  <profile>
    <id>java8-doclint-disabled</id>
    <activation>
      <jdk>[1.8,)</jdk>
    </activation>
    <properties>
      <javadoc.opts>-Xdoclint:none</javadoc.opts>
    </properties>
  </profile>
</profiles>
<build>
  <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.9</version>
        <executions>
            <execution>
                <id>attach-javadocs</id>
                <goals>
                    <goal>jar</goal>
                </goals>
                <configuration>
                    <additionalparam>${javadoc.opts}</additionalparam>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <reportPlugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-javadoc-plugin</artifactId>
              <configuration>
                <additionalparam>${javadoc.opts}</additionalparam>
              </configuration>
            </plugin>
          </reportPlugins>
        </configuration>
      </plugin>
   </plugins>
</build>

对于maven-javadoc-plugin 3.0.x:
替换

<additionalparam>-Xdoclint:none</additionalparam>

with

<doclint>none</doclint>

这篇关于当Javadoc标记不完整时,Maven无法在Java 8中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆