5

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.
Raz
  • 489
  • 3
  • 8
  • 17

2 Answers2

4

Your plugin version is too old. Try to use the latest (3.1.1).

JBaruch
  • 22,610
  • 5
  • 62
  • 90
  • ok ive upgraded, my question is, do i need to remove jcenter() repository after i upgraded it? i am currently using mavenCentral() and the artifactory – Raz Aug 19 '15 at 11:02
  • if you use Artifactory with the plugin, you should have `jcenter` in `buildscript{}` and no repositories at all in the script itself. The plugin takes care of resolution and deployment. – JBaruch Aug 21 '15 at 00:05
  • currently the version is "4.4.2" – myuce Aug 16 '16 at 09:22
  • At the time of writing this post (exactly a year ago) the latest was 3.1.1. Yup, we're working :) – JBaruch Aug 16 '16 at 14:44
1

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"
Jolta
  • 2,620
  • 1
  • 29
  • 42
  • As i said, even if i remove the buildscript and leave only the apply plugin, the error remains – Raz Aug 18 '15 at 15:23
  • 1
    Yes. That's expected. Please don't remove the `buildscript` block, it is needed by Gradle to find the plugin. Just add exactly what the instructions say, and let us know that works. The whole block from the page I linked, under the heading "Build script snippet for use in all Gradle versions". You could also try the other one called "Build script snippet for use in Gradle 2.1 and above". – Jolta Aug 18 '15 at 15:24
  • I didnt understand why in the generated build script from the artifactory site, its by default tells gradle to look for the plugin in the artifactory... – Raz Sep 09 '15 at 19:09