Subprojects var type in dsl

62
April 23, 2022, at 07:40 AM

I am transitioning my code to Kotlin DSL and as i have multimodule app i have some hack to transition gralde tasks like clean, build etc to other modules. So i have following method in gradle:

private static def getSubProjectTasks(subprojects, taskName) {
    def tasks = []
    subprojects.each { Project project ->
        if (project.subprojects.size() == 0) {
            def relativeModulePath = project.path.replace(":feature:", "")
            tasks.add("$relativeModulePath:$taskName")
        }
    }
    return tasks
}

Now trying to transition into kotlin dsl i started with this way

fun getSubProjectTasks(subproject: Unit, taskName: String) {
    for(project in subproject) {
        if(project.subprojects.size() == 0) {
        }
    }
}

I am not really sure in Kotlin DSL what type subproject is? Is this just a collection or Unit or how to transition this method.

Answer 1

Have you tried Iterable<Project>, List<Project> or Array<Project>?

I am judging based on your groovy lambda each.

You can also change your for for a map and have a single line doing everything:

fun getSubprojectTasks(subprojects: List<Subproject>, taskName: String) = subproject.mapNotNull { project ->
  if(project.subprojects.size == 0) {
    null
  } else {
    "${project.path.replace(":feature:", "")}$taskName"
  }
}
Rent Charter Buses Company
READ ALSO
Android Gradle Failed

Android Gradle Failed

I am trying to build a VPN application and when I try to build the application and run it on my phone, I keep getting these errors listed belowI tried upgrading the library dependencies, running it on offline mode,

174
GENEXUS Instalation Erro Android SDK &quot;Android SDK for Genexus Setup error&quot;

GENEXUS Instalation Erro Android SDK "Android SDK for Genexus Setup error"

I have error with Android SDK Installation for Genexus

93
calling parent fragment from DialogFragment called using navigation component

calling parent fragment from DialogFragment called using navigation component

My fragment calls a DialogFragment using navigation component like this

102
Incoming call notification in Android like whatsapp

Incoming call notification in Android like whatsapp

I am an android developerI didn't get any idea how to show notification when call is generate from server using opentok api

76