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

com.freeletics.gradle.monorepo.tasks.CheckDependencyRules.kt Maven / Gradle / Ivy

package com.freeletics.gradle.monorepo.tasks

import com.freeletics.gradle.monorepo.util.ProjectType
import com.freeletics.gradle.monorepo.util.toAppType
import com.freeletics.gradle.monorepo.util.toProjectType

internal fun checkDependencyRules(
    projectPath: String,
    dependencyPath: String,
    allowedProjectTypes: List,
    allowedDependencyProjectTypes: List,
): List {
    val errors = mutableListOf()

    val projectType = projectPath.toProjectType()
    val projectAppType = projectPath.toAppType()

    if (!allowedProjectTypes.contains(projectType)) {
        errors += "$projectPath is a ${projectType.fullName} project but the current plugin only allows " +
            allowedProjectTypes.joinToString(separator = ", ") { it.fullName }
    }

    val dependencyProjectType = dependencyPath.toProjectType()
    val dependencyAppType = dependencyPath.toAppType()

    if (!allowedDependencyProjectTypes.contains(dependencyProjectType)) {
        errors += "$projectPath is not allowed to depend on ${dependencyProjectType.fullName} module $dependencyPath"
    }

    if (dependencyAppType != null && dependencyAppType != projectAppType) {
        errors += "$projectPath is not allowed to depend on ${dependencyAppType.name} module $dependencyPath"
    }

    return errors
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy