'how to ref version catalog in apply block

I want to declare in the apply block of the parent module's build.gradle file to apply the plugin to eligible submodules(use the version catalog at the same time),but it doesn't seem to be supported

subprojects{
  if $project match some conditons {
    apply {
      plugin("groovy")
      alias(libs.plugins.goJF) // !error here
    }
  }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source