Is it possible to extend a gradle build script configured in a binary plugin?

Hi,

I’ve created a Gradle plugin below:

class CommandServiceProjectPlugin implements Plugin<Project> {
   public void apply(Project project) {
    project.buildscript{
        repositories {
    maven: {
     url: 'http://localhost:8081/artifactory/zailab-virtual-repo'
     credentials: {
      username = "admin"
      password = "password"
     }
    }
   }
        /*Spring Boot Gradle plugin */
   dependencies {
     classpath: 'org.springframework.boot:spring-boot-gradle-plugin:1.1.6.RELEASE'
    }
    }
      project.apply plugin: 'spring-boot'
  project.apply plugin: 'java'
  project.apply plugin: 'eclipse'
      project.repositories {
   maven: {
    url: 'http://localhost:8081/artifactory/zailab-virtual-repo'
   }
  }
    project.dependencies
{
     /*Spring Boot dependencies */
   compile: 'org.springframework.boot:spring-boot-starter-test'
   compile: 'org.springframework.boot:spring-boot-starter-aop'
   compile: 'org.springframework.boot:spring-boot-starter-data-mongodb'
   compile: 'org.springframework.boot:spring-boot-starter-integration'
   compile: 'org.springframework.boot:spring-boot-starter-amqp'
     /*Axon dependencies */
   compile: 'org.axonframework:axon-core:2.3.1'
   compile: 'org.axonframework:axon-mongo:2.3.1'
  }
 }
}

I then apply the plugin within another project as below, but it seems the buildscript definitions override/conflict as the ‘spring-boot’ plugin cannot be found. Am I attempting the impossible or is there perhaps another way to achieve what I am trying to do?

buildscript {
 repositories {
  maven {
   url 'http://localhost:8081/artifactory/zailab-virtual-repo'
   credentials {
    username = "admin"
    password = "password"
   }
  }
 }
 dependencies {
  classpath(group: 'com.zailab', name: 'zailab-command-service-build', version: '1.0.0-SNAPSHOT')
 }
}
  apply plugin: 'com.zailab.command.service.project'

Thanks, Roscoe

Hi,

Your plugin should add a dependency on the Spring Boot plugin jar, rather than trying to depend on it by using buildscript {} in your plugin.