2014-05-20 91 views
3

我在寫一個Jenkins插件,但對Java和Maven都是新手。如何在構建Jenkins插件時獲得編譯器警告

當我在intelliJ中構建插件時,我得到了所有我期望看到的編譯器警告(例如,棄用警告),但我找不到通過命令行進行編譯的方式(例如使用mvn HPI:HPI/MVN編譯)

我已經嘗試添加下列行到一個Maven設置文件的行家編譯-插件部但沒有效果:

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

的這個最終目的是在jenkins上編譯插件並將警告提供給警告插件。

+0

我正在嘗試同樣的事情。你有沒有成功? – k2col

+0

還沒有,但是如果我知道的話,我會確保回覆。 – user3658295

回答

2

兩個建議你可以試試:

1)添加編譯器參數的-Xlint:所有:

<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)嘗試通過命令行傳遞的參數是這樣的:

mvn clean install -Dmaven.compiler.showDeprecation=true 

祝你好運!

0

基於TimHauschildt的答案,我不得不改變我的詹金斯pom.xml文件看起來像這樣:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
    <groupId>org.jenkins-ci.plugins</groupId> 
    <artifactId>plugin</artifactId> 
    <version>1.509.4</version> 
    </parent> 

    <groupId>org.jenkins-ci.plugins</groupId> 
    <artifactId>test-plugin</artifactId> 
    <version>1.00</version> 
    <name>Test Plugin</name> 
    <packaging>hpi</packaging> 

    <repositories> 
    <repository> 
     <id>repo.jenkins-ci.org</id> 
     <url>http://repo.jenkins-ci.org/public/</url> 
    </repository> 
    </repositories> 

    <pluginRepositories> 
    <pluginRepository> 
     <id>repo.jenkins-ci.org</id> 
     <url>http://repo.jenkins-ci.org/public/</url> 
    </pluginRepository> 
    </pluginRepositories> 

    <build> 
    <pluginManagement> 
     <plugins> 
     <plugin> 
      <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> 
     </plugins> 
    </pluginManagement> 
    </build> 

</project> 

然後跑mvn compile。 之後,Jenkins中的警告插件可以提取警告。

-Dmaven.compiler.showDeprecation=true選項也運行良好,但輸出量取決於jenkins/maven默認選擇的編譯器插件版本。