Question around rule source example

Hi,

I was trying to incorporate part of an example from the new nightly build into my build file but I get this error when I try to use it:
Exception thrown while executing model rule: model.tasks

$() syntax cannot be used when model {} block is not a top level statement in the script

apply plugin: 'cpp'
    model {
        components {
            someLib (NativeLibrarySpec) {
                sources {
                    targetPlatform "macosx32"
                    flexOutput(CppSourceSet) {
                        generatedBy tasks.flex
                        generatedBy tasks.bison
                        source {
                            include "**/*.cpp"
                        }
                        exportedHeaders {
                            srcDirs "some header dir"
                        }
                    }
    
                    bisonOutput(CppSourceSet) {
                        generatedBy tasks.bison
                        source {
                            include "**/*.cpp"
                        }
                        exportedHeaders {
                            srcDirs "some header"
                        }
                    }
    
                    cpp.lib sources.bisonOutput
    
                    cpp.lib sources.flexOutput
                    cppSource(CppSourceSet) {
                        source {
                            srcDirs "sourceDir"
                        }
                        exportedHeaders{
                            srcDirs "header dir"
                        }
                    }
    
                }
    
                binaries.all {
                    cppCompiler.define "some defines"
                    cppCompiler.args "some flags"
                }
            }
        }
        tasks { t ->
            $("components.hlslang").binaries { binaries ->
                binaries.values().each { binary ->
                    def stripTask = "strip${binary.name.capitalize()}"
                    t.create(stripTask) {
                        dependsOn binary.tasks.link
                        doFirst {
                            print binary.metaClass.methods*.name.sort().unique() + "\n"
                        }
                    }
                }
            }
        }

this is part of my build file, later I have toolchains, platforms and buildtypes defined. I also have some custom tasks in there.
My question is what I am doing wrong?

Regards,
Ante

The reported error is a bit of a red herring. The use of the $() syntax is hidden behind a feature toggle. You’ll have to add -Dorg.gradle.model.dsl=true to the command line in order to use it.

Thanks Mark, forgot about that one :slight_smile: