How to reuse sources of a bunch of NativeLibrarySpec components?

Hello everybody,
My question is: How to reduce the size of my ‘build-gradle/moduleA.gradle’ script by reusing code without affecting components of another gradle scripts in the building?

I’m starting to use gradle in my native projects (I used CMake before) and I’m getting troubles with the following problem.
In my build.gradle script I have:

apply from: 'build-gradle/moduleA.gradle'
apply from: 'build-gradle/moduleB.gradle'
apply from: 'build-gradle/moduleC.gradle'
......
apply from: 'build-gradle/moduleZ.gradle'

apply plugin: 'c'
model {
  buildTypes {
    debug
    release
  }
  platforms {
    x86 {
      architecture "x86"
    }
    
    x64 {
      architecture "x86_64"
    }
  }
  binaries {
    all {
      cCompiler.args "-std=c99"
    }
  }
}

Then, I’m trying to build a lot of NativeLibrarySpec in ‘module A’ with their sources at the same directories. The script in ‘build-gradle/moduleA.gradle’ looks like

model {
  components {
    lib1(NativeLibrarySpec) {
      sources {
        c {
          source {
            srcDirs "src/moduleA"
            nclude "lib1.c"
          }
          exportedHeaders {
            srcDirs "include/moduleA"
          }
         lib library: 'some_libA'
         lib library: 'some_libB'
       }
    }
    lib2(NativeLibrarySpec) {
      sources {
        c {
          source {
            srcDirs "src/moduleA"
            include "lib2.c"
          }
          exportedHeaders {
            srcDirs "include/moduleA"
          }
         lib library: 'some_libA'
         lib library: 'some_libB'
       }
    }
    ... [MANY MANY NativeLibrarySpec HERE]
    libN(NativeLibrarySpec) {
      sources {
        c {
          source {
            srcDirs "src/moduleA"
            include "libN.c"
          }
          exportedHeaders {
            srcDirs "include/moduleA"
          }
         lib library: 'some_libA'
         lib library: 'some_libB'
       }
    }
  }
}

Trying to reduce the size of the file by reusing some lines I wrote the following in ‘build-gradle/moduleA.gradle’:

model {
  components {
    all {
      sources{
        c {
          source {
            srcDirs "src/moduleA"
          }
          exportedHeaders {
            srcDirs "include/moduleA"
          }
         lib library: 'some_libA'
         lib library: 'some_libB'
       }
    }
    lib1(NativeLibrarySpec) {
      sources {
        c {
          source {
            include "lib1.c"
          }
       }
    }
    lib2(NativeLibrarySpec) {
      sources {
        c {
          source {
            include "lib2.c"
          }
       }
    }
    ... [MANY MANY NativeLibrarySpec HERE]
    libN(NativeLibrarySpec) {
      sources {
        c {
          source {
            include "libN.c"
          }
       }
    }
  }
}

but the selector ‘components { all {} }’ took also the components of another modules.