构建Jenkins插件时如何获取编译器警告 [英] How to get compiler warnings when building a Jenkins plugin

查看:523
本文介绍了构建Jenkins插件时如何获取编译器警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写Jenkins插件,但是Java和Maven都是新手.

I'm writing a Jenkins plugin but am new to both Java and Maven.

当我在intelliJ中构建插件时,会收到我希望看到的所有编译器警告(例如,弃用警告),但是我找不到通过命令行显示这些内容的编译方法(例如,使用mvn hpi :hpi/mvn编译)

When I build the plugin in intelliJ I get all of the compiler warnings I expect to see (deprecation warnings for example) but I can't find a way to compile via the command line that will show these (eg with mvn hpi:hpi / mvn compile)

我尝试将以下行添加到Maven设置文件的maven-compiler-plugin部分,但无济于事:

I've tried adding the following lines to the maven-compiler-plugin section of a Maven settings file but to no avail:

<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>

此操作的最终目的是在jenkins上编译插件,并将警告输入警告插件.

The ultimate aim of this is to compile the plugin on jenkins and feed the warnings into the warnings plugin.

推荐答案

您可以尝试以下两种建议:

Two suggestions you can try:

1)添加编译器参数-Xlint:all:

1) Add the compiler-argument -Xlint:all:

<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <version>3.0</version>
 <configuration>
      <source>1.6</source>
      <target>1.6</target>
      <compilerArgument>-Xlint:all</compilerArgument>
      <showWarnings>true</showWarnings>
      <showDeprecation>true</showDeprecation>
  </configuration>
</plugin>

2.)尝试像这样通过命令行传递参数:

2.) Try passing the arguments via command line like this:

mvn clean install -Dmaven.compiler.showDeprecation=true

祝你好运!

这篇关于构建Jenkins插件时如何获取编译器警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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