问题
My gradle version is 2.2.1.
I am trying to use the artifactory plugin in gradle (apply plugin: 'artifactory')
This is my code:
buildscript {
repositories {
maven {
url 'http://172.14.3.93/artifactory/plugins-release'
}
}
dependencies {
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.9')
}
}
allprojects {
apply plugin: 'artifactory'
}
artifactory {
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'libs-release-local'
maven = true
}
}
resolve {
repository {
repoKey = 'libs-release'
maven = true
}
}
}
When i run gradle build, this is what i get:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Workspace\GradleConfiguration\build.gradle' line: 100
* What went wrong:
A problem occurred evaluating root project 'GradleConfiguration'.
> Failed to apply plugin [id 'artifactory']
> Could not find method add() for arguments [artifactoryPublish, class org.jfrog.gradle.plugin.artifactory.extractor.BuildInfoTask] on task set.
* Try:
Run with --info or --debug option to get more log output.
Also, when i delete all the code that is related to the artifactory and leave only apply plugin: 'artifactory', i get this error:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\OnRights_Workspace\GradleConfiguration\build.gradle' line: 86
* What went wrong:
A problem occurred evaluating root project 'GradleConfiguration'.
> Failed to apply plugin [id 'artifactory']
> Plugin with id 'artifactory' not found.
* Try:
Run with --info or --debug option to get more log output.
回答1:
Your plugin version is too old. Try to use the latest (3.1.1).
回答2:
The buildscript block tells Gradle where it should be looking for plugins. You've told it that it should only search at http://172.14.3.93/artifactory/plugins-release.
Are you 100% sure that the "artifactory" plugin is actually hosted there?
If you put jcenter in there, like the instructions say, does it work better?
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.0"
}
}
apply plugin: "com.jfrog.artifactory"
来源:https://stackoverflow.com/questions/32072698/gradle-artifactory-plugin-error