Clojure based simple plugin fails at getInputs

I am trying to create simple greeter plugin for gradle written in clojure. Currently i am filing misserably. Despite my all good intentions and big amount of debugging i am unable to pass apply stage of plugin.
Stacktrace is looking like:

Caused by: java.lang.UnsupportedOperationException
    at org.gradle.api.internal.AbstractTask.getInputs(
    at ru.aardvark.gradle.plugin.GreetingTask.getInputs(Unknown Source)
    at ru.aardvark.gradle.plugin.GreetingTask_Decorated.getInputs(Unknown Source)
    at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.autoWire(
    at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.createTask(
    at org.gradle.api.internal.tasks.DefaultTaskContainer.create(
    at org.gradle.api.internal.project.AbstractProject.task(
    at clojure_gradle_plugin.greeting.plugin$_apply.invoke(plugin.clj:9)
    at ru.aardvark.gradle.plugin.GreetingPlugin.apply(Unknown Source)
    at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(

Is there something i am doing wrong? If am using simple groovy plugin (ones that come with distribution, everything works fine)

Clojure implementation code:

(ns clojure-gradle-plugin.greeting.plugin
  (:import (org.gradle.api Project Plugin Task))
   :name ru.aardvark.gradle.plugin.GreetingPlugin 
   :implements [org.gradle.api.Plugin]))
(defn -apply [this ^org.gradle.api.Project target]
  (.task target {"type" ru.aardvark.gradle.plugin.GreetingTask} "clojureHello" ))

(ns clojure-gradle-plugin.greeting.task
  (:import (org.gradle.api DefaultTask)
           (org.gradle.api.tasks TaskAction))
   :extends org.gradle.api.DefaultTask
   :name ru.aardvark.gradle.plugin.GreetingTask
   :methods [[greet ^{TaskAction {}} [] String]]))

(defn -greet []
  print "hello from ClojureGreetingTask")

Gradle build code:

buildscript {
    repositories {
        maven {
            url uri("repo")
        maven {
            url uri('../repo')
    dependencies {
        classpath group: 'clojure-gradle-plugin', name: 'clojure-gradle-plugin', version: '0.1.0-SNAPSHOT'
        classpath group: 'org.gradle', name: 'customPlugin', version: '1.0-SNAPSHOT'
apply plugin: 'org.samples.greeting'
apply plugin: 'ru.aardvark.clojure.greeting'

If anyone have some assumption why this may fails i am open to all suggestions.

The method getInputs in AbstractTasks is just:

    public TaskInputs getInputs() {
        // Decoration takes care of the implementation
        throw new UnsupportedOperationException();

With dependency injection, the TaskInputs ends up getting set to the implementation DefaultTaskInputs.
My guess is that the closure implemented tasks is unable to use the annotation, as it stands now, and therefore doesn’t go out to locate the TaskInputs implementation to use.

I’ll have to do some research on Closure and annotations.

for some reasons it seems that the Task classes don’t get decorated as they are usually decorated by the gradle runtime. The exception you’re seeing comes from an invoked gradle build or from a testcase? I would need to take a closer look in our decoration logic to see where the root cause for this behaviour is.


Exception comes from runtime. I didn’t try to use tests to check this one. Maybe I should as this can be different behaviour path.

Can you point me to some classes that do decoration? I think I can use naive approach and set debug point and see what happens.