How to include dependencies targeting JDK 1.8 in jenkins plugin?

Viewed 1349

I have followed the official tutorial for creating Jenkins plugins: I have run mvn -U org.jenkins-ci.tools:maven-hpi-plugin:create to generate initial POM

Then I added guava as a dependency.

However, when I perform mvn package I get:

[INFO] --- maven-enforcer-plugin:1.4.2.jenkins-1:enforce (display-info) @ flaky-tests ---
[INFO] Restricted to JDK 1.7 yet com.google.guava:guava:jar:22.0:compile contains com/google/common/annotations/Beta.class targeted to JDK 1.8
...
[WARNING] Rule 2: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message:
Found Banned Dependency: com.google.guava:guava:jar:22.0
Use 'mvn dependency:tree' to locate the source of the banned dependencies.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

How can I include dependencies targeting JDK 1.8 in my Jenkins plugin?

Here's my full POM:

<?xml version="1.0" encoding="UTF-8"?>
<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>2.32</version>
        <relativePath/>
    </parent>

    <groupId>com.github.dzieciou.testing</groupId>
    <artifactId>flaky-tests</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>hpi</packaging>

    <properties>
        <jenkins.version>2.68</jenkins.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <repositories>
        <repository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </pluginRepository>
    </pluginRepositories>

    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>22.0</version>
        </dependency>
    </dependencies>

</project>
1 Answers
Related