gpt4 book ai didi

java - 如何在 jenkins 插件中包含针对 JDK 1.8 的依赖项?

转载 作者:行者123 更新时间:2023-12-02 11:12:11 24 4
gpt4 key购买 nike

我已关注official tutorial用于创建 Jenkins 插件:我已运行 mvn -U org.jenkins-ci.tools:maven-hpi-plugin:create 来生成初始 POM

然后我添加了 Guava 作为依赖项。

但是,当我执行 mvn package 时,我得到:

[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

如何在我的 Jenkins 插件中包含针对 JDK 1.8 的依赖项?

这是我的完整 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>

最佳答案

将以下属性添加到 POM 就足够了:

<java.level>8</java.level>

关于java - 如何在 jenkins 插件中包含针对 JDK 1.8 的依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44997108/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com