Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle custom plugin's build throws "unable to resolve class"

Tags:

plugins

gradle

I'm trying to build a gradle custom plugin that in turn depends on other plugin. In particular, the plugin depends on com.bmuschko.docker-remote-api plugin (that again depends on java library com.github.docker-java:docker-java:2.1.1).

So I tried with the following gradle.build file

apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'com.bmuschko.docker-remote-api'

buildscript {
  repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.bmuschko:gradle-docker-plugin:2.6.1'
    }
}

group = 'com.example'
version = '1.0'

dependencies {
    compile gradleApi()
    compile localGroovy()
    compile group: 'com.github.docker-java', name: 'docker-java', version: '2.1.1'
}

and the following plugin file:

package com.example.build

import org.gradle.api.Project
import org.gradle.api.Plugin

import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
class BndPlugin implements Plugin<Project> {

    @Override
    void apply(Project project) {
        task buildDockerImage(type: DockerBuildImage) {
            println file("${projectDir}/docker/")
        }
    }
}

but what I get with gradle build is just the error

unable to resolve class com.bmuschko.gradle.docker.tasks.image.DockerBuildImage

Question:

how to properly manage custom plugin's dependencies?

You can get the full plugin project on github.

like image 443
matteo rulli Avatar asked Jan 26 '16 23:01

matteo rulli


1 Answers

If you're going to use classes from the plugin, as opposed to just applying it, you should also include the plugin binaries as compile dependency in your lower dependencies section.

like image 90
RaGe Avatar answered Sep 28 '22 02:09

RaGe