This message was deleted.
# plugin-development
s
This message was deleted.
v
Maybe you should not do that, but simply register one task instance per pair?
s
@Vampire not sure how to implement that. tasks are defined by the plugin, so the user can't just
Copy code
tasks.getByName<MyPluginTask("secondConfig") { ...
...
i guess i'll RTFM first as to not make a fool of myself ...
v
The user can just register additional tasks if he likes or needs. Or you could provide some means like a function in an exetension to which you give the input and output that then register the additional task. Or a named domain object collection, like for example the Java plugin does. When you create or register a new
sourceSet
, the Java plugin automatically registers and wires compilation tasks for it. Or when you create or register a new test suite, the jvm test suite plugin registers new test tasks for it, and so on.
s
i think i like the function in the extension best. i guess that'd look like this, then:
Copy code
tasks.getByName<MyPluginTask>("myplugin") {
    addConfig("foo") {
        inputDirectory = "$projectDir/src/main/xyz"
        outputDirectory = "$buildDir/generated-sources/myplugin-xyz"
    }
    addConfig("bar") {
        inputDirectory = "$projectDir/src/main/abc"
        outputDirectory = "$buildDir/generated-sources/myplugin-abc"
    }
}
v
That is a function in the task, not an extension. But could work too of course if properly done.
s
ok, i'll try that. thanks for your help! you don't have, by chance, example code for this at hand?
v
As I made various suggestions, hard to tell which you refer to. 🙂 But probably nothing at hand right now anyway, no. 😞
s
okay, i misinterpreted
That is a function in the task, not an extension.
as i said, i'll read the docs first and try to understand the components better. then i'll revisit your suggestions. if i haven't found a solution by then i'll come back here.
👌 1
JFYI: i managed to change my code so it can be configured like this:
Copy code
myplugin {
  add {
    foo = bar
    boo = baz
  }
  add {
    // another
  }
}
i think i got it right. anyway, it works for me. thanks for your help, @Vampire
👌 1