我对 gradle 世界相当陌生,我正在尝试构建一个 java 项目并将生成的 Artifactory 发布到存储库。
作为构建的一部分,我收到以下错误消息,一些有关如何解决以下问题的指示将会有所帮助。
Gradle 构建:
$ gradle build --info
Initialized native services in: /var/lib/jenkins/.gradle/native
The client will now receive all logging from the daemon (pid: 4587). The daemon log file: /var/lib/jenkins/.gradle/daemon/4.9/daemon-4587.out.log
Starting 42nd build in daemon [uptime: 4 hrs 26 mins 46.465 secs, performance: 99%]
Using 4 worker leases.
Starting Build
Settings evaluated using settings file '/var/lib/jenkins/gradle_projects/settings.gradle'.
Projects loaded. Root project using build file '/var/lib/jenkins/gradle_projects/build.gradle'.
Included projects: [root project 'hello-world']
> Configure project :
Evaluating root project 'hello-world' using build file '/var/lib/jenkins/gradle_projects/build.gradle'.
FAILURE: Build failed with an exception.
* Where:
Build file '/var/lib/jenkins/gradle_projects/build.gradle' line: 32
* What went wrong:
A problem occurred evaluating root project 'hello-world'.
> Could not find method artifactory() for arguments [build_en65a4pmtkipo6cwvlcm8w7ky$_run_closure3@3ea141a7] on root project 'hello-world' of type org.gradle.api.Project.
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 0s
最佳答案
此错误是因为您尝试配置 Artifactory 插件(artifactory block ),但没有将 Artifactory 插件应用到您的项目中。 尝试按如下方式导入插件:
buildscript {
// EDIT
repositories {
// ...
jcenter()
}
dependencies {
// ...
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release" // <- this line is missing in your script
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory" // <-- this one is missing in your script
完整配置示例请参阅插件官方文档:https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin
关于java - Gradle 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52059272/