Javadoc标记不完整时,Maven无法在Java 8中工作

本文翻译自:Maven is not working in Java 8 when Javadoc tags are incomplete

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). 自从我使用Maven以来,我已经能够在本地存储库中构建并安装具有不完整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". 但是,由于我迁移到Java 8(1.8.0-ea-b90),因此Maven对缺少文档标签的要求绝对严格,并在尝试构建或安装Javadoc不在其中的项目时向我展示许多与Javadoc问题有关的Javadoc错误。 “完善”。 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. 因此,在我的情况下,仅修复所有这些项目中的所有Javadocs的变通办法似乎不可行。

This is a small part of the output I see when I execute mvn clean package install in my project: 这是我在项目中执行mvn clean package install时看到的输出的一小部分:

[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] ^

The Javadoc Maven plugin is configured like this in my POM: 在我的POM中,Javadoc Maven插件的配置如下:


    org.apache.maven.plugins
    maven-javadoc-plugin
    2.9
    
        
            attach-javadocs
            
                jar
            
        
    

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? 如前所述,如果我回到Java 7,一切都会正常进行,也许这是与Java 8中运行的Maven有关的bug? How could I make it work (ie, being able to build the Javadoc of the project and install its code in my local repository) with Java 8? 如何使它与Java 8一起工作(即,能够构建项目的Javadoc并将其代码安装在本地存储库中)? I have tested with both Maven 3.0.3 and 3.0.5 in OSX. 我已经在OSX中使用Maven 3.0.3和3.0.5进行了测试。

UPDATE: 更新:

If I change my Javadoc plugin configuration with false (thanks Martin): 如果我使用false更改Javadoc插件配置(感谢Martin):


    org.apache.maven.plugins
    maven-javadoc-plugin
    2.9
    
        
            attach-javadocs
            
                jar
            
        
    

Then the project is installed in my local repository. 然后将项目安装在我的本地存储库中。 However, the Javadoc JAR is still not generated. 但是,仍未生成Javadoc JAR。

A fragment of the output I see in the console with this new configuration is: 我在控制台中看到的具有此新配置的输出片段是:

[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 [错误] MavenReportException:创建存档时出错:退出代码:1-/Users/....java:18:警告:否@param ...命令行为:/ Library / Java / Home / bin / javadoc @options @包装

Refer to the generated Javadoc files in '/Users/sergioc/Documents/workspaces/heal/minitoolbox/target/apidocs' dir. 请参考“ / Users / sergioc / Documents / workspaces / heal / minitoolbox / target / apidocs”目录中生成的Javadoc文件。

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.Lifecyc 在org.apache.maven.plugin上org.apache.maven.plugin.javadoc.AbstractJavadocMojo.executeReport(AbstractJavadocMojo.java:1990)上org.apache.maven.plugin.javadoc.AbstractJavadocMojo.executeJavadocCommandLine(AbstractJavadocMojo.java:5043) org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)的.javadoc.JavadocJar.execute(JavadocJar.java:181)org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java :209),位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153),位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)。位于org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)的maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)位于org.apache.maven.lifecycle.internal.LifecycleStarter。在org.apache.maven.lifecycle.internal.Lifecyc上的singleThreadedBuild(LifecycleStarter.java:183) leStarter.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) org.apache.maven上的leStarter.execute(LifecycleStarter.java:161).org.apache.maven上的DefaultMaven.doExecute(DefaultMaven.java:320)。org.apache.maven上的DefaultMaven.execute(DefaultMaven.java:156) .cli.MavenCli.execute(MavenCli.java:537)在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)在org.apache.maven.cli.MavenCli.main(MavenCli.java:141) )处sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处java.lang.reflect处sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)处sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)处在org.codehaus.plexus.classworlds.launcher.Launcher.launch上的Method.invoke(Method.java:491)在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java: 230)在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

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? 关于如何构建源代码,安装项目以及在与Java 7一起工作的一步中生成Javadoc JAR的任何变通办法?


#1楼

参考:https://stackoom.com/question/14ejB/Javadoc标记不完整时-Maven无法在Java-中工作


#2楼

You could try setting the failOnError property (see plugin documentation ) to false : 您可以尝试将failOnError属性(请参阅插件文档 )设置为false


    org.apache.maven.plugins
    maven-javadoc-plugin
    2.9
    
        
            attach-javadocs
            
                jar
            
            
              false
            
        
    

As you can see from the docs, the default value is true . 从文档中可以看到,默认值为true


#3楼

The best solution would be to fix the javadoc errors. 最好的解决方案是修复javadoc错误。 If for some reason that is not possible (ie: auto generated source code) then you can disable this check. 如果由于某种原因(例如:自动生成的源代码)是不可能的,则可以禁用此检查。

DocLint is a new feature in Java 8 , which is summarized as: DocLint是Java 8中的一项新功能,总结为:

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注释中的错误的方法,并且可以轻松地将其链接回源代码。

This is enabled by default, and will run a whole lot of checks before generating Javadocs. 默认情况下启用此功能,并且在生成Javadocs之前将运行大量检查。 You need to turn this off for Java 8 as specified in this thread . 您需要为此线程中指定的Java 8关闭此功能 。 You'll have to add this to your maven configuration: 您必须将其添加到您的Maven配置中:


  
    java8-doclint-disabled
    
      [1.8,)
    
    
      -Xdoclint:none
    
  


  
    
        org.apache.maven.plugins
        maven-javadoc-plugin
        2.9
        
            
                attach-javadocs
                
                    jar
                
                
                    ${javadoc.opts}
                
            
        
    
    
        org.apache.maven.plugins
        maven-site-plugin
        3.3
        
          
            
              org.apache.maven.plugins
              maven-javadoc-plugin
              
                ${javadoc.opts}
              
            
          
        
      
   

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

-Xdoclint:none

with

none

#4楼

The easiest approach to get things working with both java 8 and java 7 is to use a profile in the build: 使Java 8和Java 7都能正常工作的最简单方法是在构建中使用配置文件:


  
    doclint-java8-disable
    
      [1.8,)
    

    
      
        
          org.apache.maven.plugins
          maven-javadoc-plugin
          
            -Xdoclint:none
          
        
      
    
  


#5楼

Overriding maven-javadoc-plugin configuration only, does not fix the problem with mvn site (used eg during the release stage). 仅覆盖maven-javadoc-plugin配置不能解决mvn site的问题(例如,在发布阶段使用)。 Here's what I had to do: 这是我必须要做的:


  doclint-java8-disable
  
    [1.8,)
  
  
    
      
        org.apache.maven.plugins
        maven-javadoc-plugin
        
          -Xdoclint:none
        
      
      
        org.apache.maven.plugins
        maven-site-plugin
        3.3
        
          
            
              org.apache.maven.plugins
              maven-javadoc-plugin
              
                -Xdoclint:none
              
            
          
        
      
    
  


#6楼

Here is the most concise way I am aware of to ignore doclint warnings regardless of java version used. 这是我知道的最简洁的方法,无论使用什么Java版本,都可以忽略doclint警告。 There is no need to duplicate plugin configuration in multiple profiles with slight modifications. 只需稍作修改,就无需在多个配置文件中重复插件配置。


  
    doclint-java8-disable
    
      [1.8,)
    
    
      -Xdoclint:none
    
  



  
    
      org.apache.maven.plugins
      maven-javadoc-plugin
      2.9.1
      
        
          attach-javadocs 
          
            ${javadoc.opts}
          
        
      
    
    ...
  

Tested on oracle/open jdk 6, 7, 8 and 11. 在oracle / open jdk 6、7、8和11上测试

你可能感兴趣的:(java,maven,migration,java-8,javadoc)