Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle with artifactory

I am trying to set up my own ivy repository to use for my own libraries. I found out about artifactory and decided to use that on my Ubuntu server. I followed the directions here:

http://www.jfrog.com/video/artifactory-1-min-setup/

And created this automatic script:

buildscript {
    repositories {

        ivy {
            url 'http://picard:8080/artifactory/plugins-release'

        }
    }
    dependencies {
        //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3"
    }
}

allprojects {
    apply plugin: "com.jfrog.artifactory"
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-release-local'
            maven = false
            ivy {
                ivyLayout = '[organization]/[module]/[revision]/[type]s/ivy-[revision].xml'
                artifactLayout = '[organization]/[module]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]'
                mavenCompatible = false
            }
        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            maven = false
            ivy {
                ivyLayout = '[organization]/[module]/[revision]/[type]s/ivy-[revision].xml'
                artifactLayout = '[organization]/[module]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]'
                mavenCompatible = false
            }
        }
    }
}

From this, I modified my build.gradle such:

buildscript {
    repositories {
        mavenLocal()
        ivy {
            url 'http://picard:8080/artifactory/plugins-release'
        }
    }
}

apply plugin: 'java'
apply plugin: "com.jfrog.artifactory"

archivesBaseName = 'heavyweight-software-util'

repositories {
    mavenCentral()
    ivy {
        url 'http://picard:8080/artifactory/plugins-release'
    }
}

dependencies {
    classpath("org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3")
    testCompile("junit:junit:4.11")
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.8'
}


artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-release-local'
            maven = false
            ivy {
                ivyLayout = '[organization]/[module]/[revision]/[type]s/ivy-[revision].xml'
                artifactLayout = '[organization]/[module]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]'
                mavenCompatible = false
            }
        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            maven = false
            ivy {
                ivyLayout = '[organization]/[module]/[revision]/[type]s/ivy-[revision].xml'
                artifactLayout = '[organization]/[module]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]'
                mavenCompatible = false
            }
        }
    }
}

When I execute the build, I get:

A problem occurred evaluating root project 'Utility'.
> Plugin with id 'com.jfrog.artifactory' not found.

I tried googling this error, but didn't find anything helpful. Can someone help me fix this error? I am new to gradle.

Thanks.

like image 835
Thom Avatar asked Jul 13 '15 16:07

Thom


1 Answers

Found the solution here: http://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin

Basically, I modified my build script with the following lines:

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.0"
  }
}
apply plugin: "com.jfrog.artifactory"

Which is rather different from the one generated by their build script generator. Hope this helps someone else.

like image 62
Thom Avatar answered Nov 03 '22 22:11

Thom