Slackbot
05/16/2022, 2:34 PMCristianGM
05/16/2022, 2:44 PMephemient
05/16/2022, 2:45 PMfeatureEnabledconfigFileconfigFile.set("...")CristianGM
05/16/2022, 2:47 PMMartin
05/16/2022, 2:52 PMmyPlugin {
  enableFeature(featureEnabled: Boolean, configFile: File)
}CristianGM
05/16/2022, 2:54 PMephemient
05/16/2022, 2:54 PMMartin
05/16/2022, 2:55 PMephemient
05/16/2022, 2:55 PMChris Lee
05/16/2022, 2:59 PMJavi
05/16/2022, 3:01 PMephemient
05/16/2022, 3:04 PMNicola Corti
05/16/2022, 3:10 PMconfigFile@InputFileconfigFile@InputFile@InputFileephemient
05/16/2022, 3:22 PMephemient
05/16/2022, 3:25 PMCristianGM
05/16/2022, 3:34 PMNicola Corti
05/17/2022, 2:25 PMyou could create yet another task that reads the config file, outputs the collection of files it references, and is untracked; then use that as the other tasks' input filesThanks for the hint @ephemient. I'm still trying to find a way to make it work correctly. Not sure how the first task should outputs the collection of files it references. The problem is that this list of file will be known only at execution time and won't be accounted for the UP-TO-DATE checks of the second task
ephemient
05/17/2022, 2:30 PMephemient
05/17/2022, 2:31 PMNicola Corti
05/17/2022, 2:53 PMand copy the referenced files to itBut then I'll end up copying over and over the files for every build no?
ephemient
05/17/2022, 2:54 PMNicola Corti
05/17/2022, 3:06 PMproject.afterEvaluateephemient
05/17/2022, 3:07 PMChris Lee
05/17/2022, 3:08 PMChris Lee
05/17/2022, 3:23 PM// extension class
abstract class ProjectsExtension @Inject constructor(private val objectFactory: ObjectFactory) {
    @get:Input
    abstract val buildFiles: DomainObjectSet<File>
}
// plugin code
val projectsExt = extensions.create("projects", ProjectsExtension::class)
projectsExt.buildFiles.whenObjectAdded {
    // do magic here
}ephemient
05/17/2022, 3:30 PMFilewhenObjectAddedallChris Lee
05/17/2022, 3:33 PMNicola Corti
05/17/2022, 4:17 PMDomainObjectSetconfigFileRegularFilePropertyDomainObjectSet<File>DomainObjectSetconfigFileChris Lee
05/17/2022, 4:23 PMJendrik Johannes
05/17/2022, 5:32 PMproject.providers.fileContents(configFile).asText.get()tasks.register<MyType>("myTaks") {
    someInputFile.set(myPluginExtension.configFile.map {
        parsePathFromFile(it)
    })
}
fun parsePathFromFile(it: Provider<RegularFile>) =
    project.layout.projectDirectory.file(
        providers.fileContents(it.get()).asText.get().substring(0, 10)) // Instead of 'substring' do the real parsingJendrik Johannes
05/17/2022, 5:35 PMprovidersChris Lee
05/17/2022, 5:36 PMget()Chris Lee
05/17/2022, 5:39 PMfun <T> Provider<T>.memoize(): Provider<T> {
    return MemoizingProvider(this as ProviderInternal<T>)
}
internal class MemoizingProvider<T>(private val provider: ProviderInternal<T>) :
    AbstractMinimalProvider<T>() {
    private var memoizedValue: ValueSupplier.Value<out T>? = null
    override fun getType(): Class<T>? {
        return provider.type
    }
    override fun calculateOwnValue(consumer: ValueSupplier.ValueConsumer): ValueSupplier.Value<out T> {
        if (memoizedValue == null) {
            memoizedValue = provider.calculateValue(consumer)
        }
        return memoizedValue as ValueSupplier.Value<out T>
    }
    override fun toString(): String {
        return "memoized($provider)"
    }
}Nicola Corti
05/17/2022, 10:36 PMJendrik Johannes
05/18/2022, 1:36 PM