Depend on model task output file

This is a native software question.

My software component requires the curl library. I am using an exec model task in Gradle to build the curl library using the makefile provided with the curl source. I have set the generated library file as an output file for the exec task.

I am then defining a gradle prebuilt library and assigning the task output file as the sharedLibraryFile for the prebuilt library.

model {
  repositories {
    libs(PrebuiltLibraries) {
      curl {
        headers.srcDir "${sourceDirectory}/include"
        binaries.withType(SharedLibraryBinary) {
          sharedLibraryFile = $.tasks.make_curl.getOutputs().getFiles().getSingleFile()
        }
      }
    }
  }
}

I can then link against the curl library in my project like so.

lib project: ':third_party:curl', library: 'curl', linkage: 'shared'

This works fine and it finds the task output file. I can build my project and it links fine if I have already run the “make_curl” task, but fails if the “make curl” task has not been run to generate the library first.

My expectation was that using the “$.” notation to reference a model element that it was guaranteed to exist and would create a dependency on the “make_curl” task if the library file wasn’t present.

I know I could add an explicit task dependency, but it doesn’t seem like I should need to.

Is it possible to create a dependency on a model task output? If so, how would I do that?

Thanks