Gradle构建失败

时间:2018-08-28 13:35:49

标签: java gradle build publish artifactory

我对gradle world来说还很陌生,我正在尝试构建一个Java项目并将生成的工件发布到存储库中。

在构建过程中,我收到以下错误消息,有关如何解决以下问题的一些指示会有所帮助。

Gradle Build:

$ 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

1 个答案:

答案 0 :(得分:1)

此错误是因为您正在尝试配置Artifactory插件( artifactory 块),但未将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