<commit_before># Feature: basic usability

## Story: Transformed DSL is enabled by default

- Allow transformed DSL rules to access project and script, for now.
- Update user guide to mention syntax.
    - Can use `$('p')` in any expression inside rule closure.
    - Can use in rule closure parameters.
- Update release notes to mention potential breaking change.

## Story: DSL rule references input using path expression syntax

- Replace `$('path')` with `$.path`

## Story: DSL rule references input relative to subject 

- Allow a closure parameter to be declared, this lvar can be used to reference inputs
- Improve error message when extracted input cannot be bound
- Update user guide and samples to use this syntax
- Update release notes to mention potential breaking change.
- Report actual expression used for input reference in error messages.

For example:

    model { m ->
        components { c ->
            mylib(JavaLibrarySpec) {
                targetPlatform m.platforms.java6 // resolve path relative to subject `m`
            }
            test {
                targetPlatform c.test.targetPlatform
            }
        }
        tasks { t ->
            thing(MyTask) {
                dependsOn t.otherTask // resolve path relative to subject `t`
            }
        }
    }

### Test cases

- Can configure a component using a sibling component as input.

## Story: DSL rule references input relative to another input reference 

    model {
        thing {
            def c = $.a.b.c
            all {
                value = c.d.e // reference to a.b.c.d.e
            }
        }
    }

## Story: DSL rule configures element of ModelMap 

- Allow input references using subject parameter
- Named, all, with type, before, after, etc


    model {
        components {
            all {
                targetPlatform platforms.java6
            }
        }
    }
    
## Story: DSL rule configures child of a structure
 
- Allow input references using subject parameter


    model {
        components {
            main {
                sources {
                    ...
                }
                binaries {
                    ...
                }
            }
        }
    }

## Story: DSL rule configures task action 

- Allow input references using subject parameter


    model {
        tasks {
            myTask(Task) {
                doLast { // TBD - perhaps use a new syntax here or at least a better name
                    ...
                }
            }
        }
    }
    
## Story: Deprecate access to project and script from DSL rules<commit_msg>Updated DSL spec, just shuffled a couple of stories around.<commit_after># Feature: basic usability

## Story: Transformed DSL is enabled by default

- Allow transformed DSL rules to access project and script, for now.
- Update user guide to mention syntax.
    - Can use `$('p')` in any expression inside rule closure.
    - Can use in rule closure parameters.
- Update release notes to mention potential breaking change.

## Story: DSL rule references input using path expression syntax

- Replace `$('path')` with `$.path`

## Story: DSL rule configures elements of ModelMap 

- Apply to creation, configure by name, configure all, configure all with type, before each, after each, etc.
- Apply to chained withType and rule method calls
- Allow arbitrary code to do:
    - for each in collection, apply a rule
    - if some condition is true, apply a rule
- Allow configuration of an element to take the configuration of a sibling as input.
- Out-of-scope: allow configuration of an element to take the configuration of siblings with type as input.


    model {
        components {
            main(JavaLibrary) {
                // Can reference other elements, this is treated as an input to the inner rule, not the outer components { } rule.
                targetPlatform = $.platforms.java9
            }
            test {
                // Can reference a sibling as input
                targetPlatform = $.components.main.targetPlatform
            }
            beforeEach {
                targetPlatform = $.platforms.java6
            }
            withType(SpecialLibrary).beforeEach {
                targetPlatform = $.platforms.java7
            }
            if (somecode) {
                // Conditional creation
                otherLib(JavaApplication) {
                    targetPlatform = $.platforms.java12
                }
            }
            for (def item: [some, collection]) {
                // For each item in a collection create a library
                create("${item}Lib", JavaLibrary) {
                    targetPlatform = $.platforms.java7
                }
            }
            [some, collection].each { create(...) { ... } } // out-of-scope for this story, won't work
        }
    }
    
## Story: DSL rule configures child of a structure
 
- Defer configuration, apply only to rule targets, eg nested structured or nested model containers.
- Allow configuration for a nested structure to take configuration for a sibling as input.
- Allow arbitrary code to conditionally configure a nested target.


    model {
        components {
            main {
                sources {
                    baseDir = $.project.projectDir('src')
                }
                binaries {
                    outputDir = $.sources.baseDir
                }
            }
        }
    }    

## Story: DSL rule references input relative to subject 

- Allow a closure parameter to be declared, this lvar can be used to reference inputs
- Improve error message when extracted input cannot be bound
- Update user guide and samples to use this syntax
- Update release notes to mention potential breaking change.
- Report actual expression used for input reference in error messages.

For example:

    model { m ->
        components { c ->
            mylib(JavaLibrarySpec) {
                targetPlatform m.platforms.java6 // resolve path relative to subject `m`
            }
            test {
                targetPlatform c.test.targetPlatform
            }
        }
        tasks { t ->
            thing(MyTask) {
                dependsOn t.otherTask // resolve path relative to subject `t`
            }
        }
    }

### Test cases

- Can configure a component using a sibling component as input.

## Story: DSL rule references input relative to another input reference 

    model {
        thing {
            def c = $.a.b.c
            all {
                value = c.d.e // reference to a.b.c.d.e
            }
        }
    }

## Story: DSL rule configures task action 

- Allow input references using subject parameter


    model {
        tasks {
            myTask(Task) {
                doLast { // TBD - perhaps use a new syntax here or at least a better name
                    ...
                }
            }
        }
    }
    
## Story: Deprecate access to project and script from DSL rules
{'fraction_non_alphanumeric': 0.06825646151649294, 'fraction_numerical': 0.0012851635013565615, 'mean_word_length': 1.6600835548803645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3804918', 'n_tokens_mistral': 1710, 'n_tokens_neox': 1614, 'n_words': 711}