ml-archive / kotlin-template

Kotlin-template clean architecture
23 stars 8 forks source link

Extract all dependencies versions in variables #7

Closed vovahost closed 6 years ago

vovahost commented 6 years ago

Extract all dependency versions inside the project's build.gradle file. Example:

buildscript {
    ext {
        kotlin_version = '1.1.60'
        dagger_version = "2.11"
        support_library_version = '26.1.0'
        constraint_layout_version = '1.0.2'
        junit_version = '4.12'
        test_runner_version = '1.0.1'
        espresso_core_version = '3.0.1'
        nstack_kotlin_version = '1.0'
        rxkotlin_version = '2.1.0'
        rxandroid_version = '2.0.1'
        timberkt_version = '1.3.0'

        retrofit_version = '2.3.0'
        retrofit_rx_java_adapter_version = '2.3.0'
        retrofit_gson_converter_version = '2.3.0'
        ok_http_logging_interceptor_version = '3.9.0'
        gson_version = '2.8.2'
        glide_version = '4.2.0'

        circleImage_view_version = '2.2.0'
    }
}

Then you can use them inside the module's build.gradle like this:

dependencies {
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

    implementation "com.android.support:appcompat-v7:$support_library_version"
    implementation "com.android.support:recyclerview-v7:$support_library_version"
    implementation "com.android.support:design:$support_library_version"
    implementation "com.android.support:cardview-v7:$support_library_version"

    implementation "com.android.support.constraint:constraint-layout:$constraint_layout_version"
}
BrianEstrada commented 6 years ago

I've never understood the reasoning for this, I can get it when its multiple libraries using the same version numbers but it feels weird for single libraries

or I guess it comes in handy when you're using multiple modules with the same library

vovahost commented 6 years ago

Yes, also the support libraries are all using the same version and the Google Play services with GCM and a couple more are also using a common version. Then I think you have them all in one place so it's easier to change and review them all I guess.

johsoe commented 6 years ago

Do the linter work this way? Right now it suggests new versions if the current one is out of date.

vovahost commented 6 years ago

Yes, it does otherwise I wouldn't use it either.

johsoe commented 6 years ago

👍 Make the change and make a PR