How to get compiler warnings when creating a Jenkins plugin

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

When I create a plugin in intelliJ, I get all the compiler warnings that I expect to see (for example, failure warnings), but I cannot find a way to compile it through the command line that will show them (for example, with mvn hpi: hpi / mvn compile)

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

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

The ultimate goal of this is to compile the plugin on jenkins and provide warnings to the alert plugin.

+4
source share
2 answers

, :

1) - -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.) :

mvn clean install -Dmaven.compiler.showDeprecation=true

!

+3

TimHauschildt jenkins 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 .

0

Source: https://habr.com/ru/post/1541344/


All Articles