Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Libs.xxx in Gradle's resolutionStrategy #28

Closed
jmfayard opened this issue Dec 16, 2018 · 1 comment
Closed

Use Libs.xxx in Gradle's resolutionStrategy #28

jmfayard opened this issue Dec 16, 2018 · 1 comment
Assignees
Labels

Comments

@jmfayard
Copy link
Member

jmfayard commented Dec 16, 2018

Context: buildSrcVersions is a Gradle plugin that makes it easier to manage your dependencies inside your IDE. It extracts all your dependencies and search for available dependencies updates.

You can use the information from Libs.kt to simplify your resolutionStragy:

val forceDependencies = listOf(Libs.retrofit, Libs.kotlin_reflect, Libs.kotlin_stdlib_jdk7)      // Kotlin
// def forceDependencies = [Libs.retrofit, Libs.kotlin_reflect, Libs.kotlin_stdlib_jdk7]  // Groovy

allprojects {
    configurations.all {
        resolutionStrategy {
            for (dependencyVersion in forceDependencies) {
                force(dependencyVersion)
            }
        }
    }
}

The same principle can be used for the resolutionStragy of plugins

pluginManagement {
    resolutionStrategy {
        eachPlugin {
            val plugin = requested.id.id
            val module = when {
                plugin.startsWith("com.android") -> Libs.com_android_tools_build_gradle
                plugin.startsWith("kotlin")  -> Libs.kotlin_gradle_plugin
                else -> return@eachPlugin
            }
            println("resolutionStrategy for plugin=$plugin : $module")
            useModule(module)
        }
    }
}
@jmfayard jmfayard self-assigned this Dec 16, 2018
@jmfayard jmfayard changed the title Tip: Use Libs.xxx in your resolutionStrategy Use Libs.xxx in Gradle's resolutionStrategy Dec 16, 2018
@jmfayard
Copy link
Member Author

Doesn't make much sense now, the long term plan is to focus on :refreshVersions

Long term plan: focus on refreshVersions #104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant