Gradle-git - external library trouble!


(Marek Counts) #1

I’m super new to gradle (basically what I have been able to read today)… and thus I’m sorry if I’m missing something really stupid.

I want to use the project gradle-git from ajoberstar, and wrote this build script.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.ajoberstar:gradle-git:0.8.0'
    }
}

now. if i go to the directory and do a

gradle dependencies

it downloads the project. but then does not list it as a dependancy in any of the categories. further more I can’t use it, below if my full code and if you try to run task cloneGitRepo it says it can’t find GitClone. Also the import is all underlined red as intelliJ tells me that cannot resolve symbol ‘ajoberstar’… but I did not know if this was a limitation of the IDE’s integration with gradle or not… but i don’t think it is.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.ajoberstar:gradle-git:0.8.0'
    }
}
  apply plugin: 'java'
apply plugin: 'maven'
  group = 'org.ajoberstar'
description = 'Git plugins for Gradle'
version = '0.8.0'
  import org.ajoberstar.gradle.git.tasks.*
  task cloneGitRepo(type: GitClone) {
    def destination = file("destination_folder")
    uri = "your_git_repo_uri"
    destinationPath = destination
    bare = false
    enabled = !destination.exists() //to clone only once
}

I apologize as I’m probably just doing something really stupid or not understanding something simple. Thanks in advanced for any help!


(Justin Ryan) #2

The reason you don’t see the dependency is because it’s on the “classpath” configuration, which is not shown by the dependencies command. To show the buildscript classpath you have to do something like:

task show << {

buildscript.configurations.classpath.each { println it }

}

Concerning the gradle-git commands, you’re referring to the docs for 0.6.0. That specific plugin experienced a major rewrite recently, and I don’t think the import line is correct anymore. If you change the version to 0.6.0, your script will work the way it is.


(Marek Counts) #3

Thanks for the info on the Classpath, that helped. As for getting it to work I changed the version of the plugin to 0.6.0 and the script will still not run as the import still says that org.ajoberstar is not there… :frowning: Can I not use the class in the same file I declared it in. but maybe in one of the sub build files?


(Marek Counts) #4

Thanks, sorry, after a little working with it I was able to get it up and working. thanks for your help!