javadoc:错误 - 无效标志:-Xdoclint:none,当我使用 java 7 时,但它适用于 java 8

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27728733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 12:17:39  来源:igfitidea点击:

javadoc: error - invalid flag: -Xdoclint:none, when I use java 7, but it works in java 8

javamavenjava-8

提问by Piyush Jajoo

Maven works fine when I run my pom having <additionalparam>-Xdoclint:none</additionalparam>with JAVA 8, since -Xdoclintwas added in JAVA 8. However, it throws an error when I run maven with JAVA 7 since it is not there in JAVA 7.

当我<additionalparam>-Xdoclint:none</additionalparam>使用 JAVA 8运行我的 pom 时,Maven 工作正常,因为它-Xdoclint是在 JAVA 8 中添加的。但是,当我使用 JAVA 7 运行 maven 时它会引发错误,因为它在 JAVA 7 中不存在。

But I want to make the pom generalized for JAVA 7 and JAVA 8, i.e. if JAVA 8 I should be able to use the specified "additionalparam" but when using JAVA 7, it should exclude that parameter.

但是我想让 pom 泛化为 JAVA 7 和 JAVA 8,即如果 JAVA 8 我应该能够使用指定的“additionalparam”,但是在使用 JAVA 7 时,它应该排除该参数。

回答by Piyush Jajoo

Found Solution -

找到解决方案 -

  <profiles>
    <profile>
      <id>doclint-java8-disable</id>
      <activation>
        <jdk>[1.8,)</jdk>
      </activation>
      <properties>
        <javadoc.opts>-Xdoclint:none</javadoc.opts>
      </properties>
    </profile>
  </profiles>

And then use ${javadoc.opts}

然后使用 ${javadoc.opts}

Credit - https://stackoverflow.com/a/26806103

信用 - https://stackoverflow.com/a/26806103

回答by jcgarciam

Instead of using the

而不是使用

<properties>
   <javadoc.opts>-Xdoclint:none</javadoc.opts>
</properties>

I used:

我用了:

       <profile>
            <id>doclint-java8-disable</id>
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.10.2</version>
                        <configuration>
                            <additionalparam>-Xdoclint:none</additionalparam>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>