Could not find property 'MyCustomTask' on root project 'test'


(Peter Kahn) #1

Is there something I need to do to expose a task from a plugin? I have a tiny plugin with a simple custom task but I can’t create new tasks from it. I can use it as a defined plugin but I want to create tasks using its type in my build file.

Please let me know if you know what I need to do to expose this properly.

Thanks Peter

apply plugin: 'mycustomplugin'
  buildscript {
    classpath 'com.peterdkahn.customPlugin:0-0-1-SNAPSHOT'
  }
 ...
}
task mytask(type: MyCustomTask) {
}

Plugin

package com.peterdkahn.gradle;
  import org.gradle.api.*
  class MyCustomPlugin implements Plugin<Project> {
 def void apply(Project project) {
  project.task('mycustomtask', type: MyCustomTask)
  }
}

(Luke Daley) #2

You need to import the class like you normally do in Java.


(Peter Kahn) #3

Hi Luke,

I thought I tried that but it seems I’m mistaken.

Thanks

Peter


(Peter Kahn) #4

Hi Luke,

I thought I tried that but it seems I’m mistaken. Thanks

Peter


(Peter Kahn) #5

Perhaps I didn’t make the class public initially