Model rules are unbound error

I’m getting the following error in a native project being migrated to Gradle

> The following model rules are unbound:
    model.components > named(sources)
        - components.sources (org.gradle.platform.base.ComponentSpec)

I have no idea what it means in this context. I think it applies to the following section in the build script

model {
  buildTypes {
 components {
   'name-of-lib'(NativeLibrarySpec) {
      targetPlatform 'x64'
   sources {
     cpp {
       source {
         srcDir projectDir
         include '*.cpp'
       exportedHeaders {
         srcDir projectDir
         include '*.hpp'

The reason the srcDir is projectDir is that I do not want to move any code around at this point in time.

The issue is that the sources block needs to be inside the ‘name-of-lib’ component definition. The rule is “unbound” because it is attempting to configure a component named “sources” which has never been created.

1 Like

Thank you. That solved it.