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

自从我使用Maven以来,我已经能够在本地存储库中构建并安装具有不完整Javadoc标记(例如,缺少参数)的项目。

但是,由于我迁移到Java 8(1.8.0-ea-b90),因此Maven对丢失文档标记绝对严格,并且在我尝试构建或安装Javadoc不在其中的项目时向我展示许多与Javadoc问题有关的Javadoc错误。 “完善”。我试图编译并安装在本地存储库中的某些项目是我无法控制的第三方项目。因此,在我的情况下,仅修复所有这些项目中的所有Javadocs的变通办法似乎不可行。

这是我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] ^

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

<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有关的bug?如何使用Java 8使其工作(即,能够构建项目的Javadoc并将其代码安装在本地存储库中)?我已经在OSX中使用Maven 3.0.3和3.0.5进行了测试。

更新:

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

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

我在控制台中看到的带有此新配置的输出片段是:

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

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

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

回答:

最好的解决方案是修复javadoc错误。如果由于某种原因(例如:自动生成的源代码)无法执行,则可以禁用此检查。

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

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

默认情况下启用此功能,并且在生成Javadocs之前将运行大量检查。你需要为此线程中指定的Java 8关闭此功能。你必须将其添加到你的Maven配置中:

<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.0+: 替换

<additionalparam>-Xdoclint:none</additionalparam>

<doclint>none</doclint>

以上是 Javadoc标记不完整时,Maven无法在Java 8中工作 的全部内容, 来源链接: utcz.com/qa/411784.html

回到顶部