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

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)
  }
}

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

Hi Luke,

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

Thanks

Peter

Hi Luke,

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

Peter

Perhaps I didn’t make the class public initially