Is there any way to obtain a dependency into a plugin from the build.gradle file?


(David Harris) #1

Hi all,

I’m building a plugin with Gradle 2.0-rc-1 and would like to use the following syntax in the build.gradle file:

buildscript {

repositories {

maven {

url uri(’…/repo’)

}

}

dependencies {

classpath

group: ‘com.example.plugins’,

name: ‘fooPlugin’,

version: ‘1.1-SNAPSHOT’

}

}

apply plugin: ‘com.example.foo’

dependencies {

foo

group ‘com.example’

name: ‘bar’

version: ‘1.0’

}

I’m able to generate the foo plugin and have it add a foo task as follows:

package com.apple.iad.plugins

import org.gradle.api.*

class FooPlugin implements Plugin {

void apply(project) {

def configurations = project.getConfigurations()

configurations.create(‘foo’)

//thrift task has been defined below.

project.task(‘foo’) {

println ‘Hi from foo plugin!’

}

}

}

I’ve read and reread the gradle documents but cannot find the recipe to obtain this information.

To supply some context, I need the name component as an input to a second script and I also want to use the complete dependency to extract the artifact from a repository.

Thanks in advance

David