All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mill.scalalib.internal.JavaModuleUtils.scala Maven / Gradle / Ivy

There is a newer version: 0.12.0-RC2-17-07e173
Show newest version
package mill.scalalib.internal

import mill.define.Module
import mill.scalalib.JavaModule

@mill.api.internal
object JavaModuleUtils {

  /**
   * Compute all transitive modules from module children and via moduleDeps + compileModuleDeps
   */
  def transitiveModules(module: Module, accept: Module => Boolean = _ => true): Seq[Module] = {
    def loop(mod: Module, found: Seq[Module]): Seq[Module] = {
      if (!accept(mod) || found.contains(mod))
        found
      else {
        val subMods = mod.millModuleDirectChildren ++ (mod match {
          case jm: JavaModule => jm.moduleDepsChecked ++ jm.compileModuleDepsChecked
          case other => Seq.empty
        })
        subMods.foldLeft(found ++ Seq(mod)) { (all, mod) => loop(mod, all) }
      }
    }

    loop(module, Seq.empty)
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy