Unable to acces ProjectSourceSet via rule based model

Hello and good morning from germany.

I want to read the ProjectSourceSet via the rule based model. Running gradle model tells me, that my ProjectSourceSet contains two entries, and that the rule in which i try to read the ProjectSourceSet was applied to the ProjectSourceSet model object. However, within the rule, the ProjectSourceSet contains zero entries.

I tried to anotate my rule with @Mutate, @Validate and @Finalize, to no success. My understanding is, that the ProjectSourceSet model object should be complete in rules with @Validate or @Finalize, but obviously i have not figured out the big picture yet. What else could i do to access the ProjectSourceSet?

From gradle model:

+ sources
| Type:           org.gradle.language.base.ProjectSourceSet
| Value:          [C++ source 'mathematics:cpp', C++ source 'myLib:cpp']
| Creator:        LanguageBasePlugin.Rules#sources
| Rules:
   ? MyPlugin.RuleSourceInnerClass#read

Source code of Rule:

public static class RuleSourceInnerClass extends RuleSource {

    @Validate
    void read(ProjectSourceSet projectSourceSet) {
        println 'Rule fired'
        println projectSourceSet.size() // <-- results to 0
    }
}

This is a bug. The rule you have there should work, so that when the read() method is called, the projectSourceSet collection you get should not be empty, and should contain all of the source sets defined in the project (for all components and binaries).

Thanks for the feedback. I will try it again with the next version.