How to get inputs path in plugins for validation user message

plugins

(Marcel Trautwein) #1

Hi experts,

I’m developing some plugins that uses inputs, one of them is a simple Copy(Task) derived task

actually I’m tring to bring some more helpful asserts for users that inputs are empty, e.g.

MyTask() {
  project.gradle.projectsEvaluated {
      assert inputs.hasSourceFiles : "[${this.name}] CONFIG ERROR ${project.name}: no files found in :${this.name}.from path"
  }
}

e.g. it is set by

myTask {
  from project.sourceSets.findByName("dist").resources.srcDirs

As I can see, there is no real API to get back the original from / input path set by users script i.e. getting the original from srcDir(s) for a more concrete assert message which path is empty?, e.g.:

      assert inputs.hasSourceFiles : "[${this.name}] CONFIG ERROR ${project.name}: no files found in :${this.inputs.dirs} path"

are there any helpful things I didn’t found yet but without defining custom special properties on my task that are “magically” added to from, I wanted to not add more abstractions from the original input API just for some a feature “convenience message”

Thank you and with kind regards,
~Marcel