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

Migrate project to Gradle 6 - acessing the buildSrc project and its dependencies #109

Closed
wangerekaharun opened this issue May 22, 2020 · 6 comments
Labels
enhancement New feature or request ✍️ready to grab You can start working on this issue

Comments

@wangerekaharun
Copy link

Hi @igorwojda thanks for this project, its super awesome and have used your approach a couple of times on my projects while setting up modules and more so i particularly like your Kotlin Gradle DSL Setup, couldn't find any other complete sample.

However i think you should check on accessing the buildSrc project and its dependencies in settings scripts as it has been deprecated in Gradle v 6.0.

Am currently looking on a work around for the same. In case i find a workaround before you update, will definitely create a PR for this :]

Screenshot from 2020-05-22 13-39-13

@igorwojda igorwojda added enhancement New feature or request ✍️ready to grab You can start working on this issue labels May 22, 2020
@igorwojda
Copy link
Owner

I am happy this project is helpful for you :-)

I am aware of Gradle 6 problem - the main issue comes from the fact settings is now evaluated before buildSrc, so current approach is no longer possible.

Some research is required to address that

@igorwojda igorwojda changed the title Acessing the buildSrc project and its dependencies Migrate project to Gradle 6 - acessing the buildSrc project and its dependencies May 22, 2020
@wangerekaharun
Copy link
Author

Yes i would agree with you a bit of research is needed, from the docs i see the approach is just having them used as normal Strings, what's your take on this?

@igorwojda
Copy link
Owner

Ideally I would want to keep old way, but if not possible we will have to use strings 🙄

@ininmm
Copy link

ininmm commented Jun 2, 2020

Hey @igorwojda, I had stocked in the same question, then I resolved the issue with the Settings properties.

Here is my solution:

# -------gradle.properties------
kotlinVersion=1.3.72
androidVersion=4.0.0

kotlinJVMId=org.jetbrains.kotlin.jvm
kotlinAndroid=org.jetbrains.kotlin.android
kotlinAndroidExt=org.jetbrains.kotlin.android.extensions
kotlinKapt=org.jetbrains.kotlin.kapt
androidAppId=com.android.application
androidLibraryId=com.android.library
androidGradle=com.android.tools.build:gradle:4.0.0
pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        jcenter()
    }

    plugins {
        val kotlinVersion: String by settings
        val androidVersion: String by settings

        val kotlinJVMId: String by settings
        val kotlinAndroid: String by settings
        val kotlinAndroidExt: String by settings
        val kotlinKapt: String by settings
        val androidAppId: String by settings
        val androidLibraryId: String by settings

        id(kotlinJVMId) version kotlinVersion
        id(kotlinAndroid) version kotlinVersion
        id(kotlinAndroidExt) version kotlinVersion
        id(kotlinKapt) version kotlinVersion
        id(androidAppId) version androidVersion
        id(androidLibraryId) version androidVersion
    }

    resolutionStrategy {
        val androidAppId: String by settings
        val androidLibraryId: String by settings
        val androidGradle: String by settings
        eachPlugin {
            when (requested.id.id) {
                androidAppId, androidLibraryId -> useModule(androidGradle)
            }
        }
    }
}

It is not the best way but that should be something for now, we should keep the old solution if possible.

@fleficher
Copy link

One other way to fix this issue is to use composite builds in which files can be accessed from settings & modules gradle.kts files. See: https://proandroiddev.com/stop-using-gradle-buildsrc-use-composite-builds-instead-3c38ac7a2ab3

@igorwojda
Copy link
Owner

igorwojda commented Feb 9, 2021

Hello after a long break. So finally I had time to update Gradle - it is updated to Gradle 7 #129.

I think @ininmm solution is the best one - I know it's not perfect, but Gradle quite problematic when it comes to version sharing.

I have created issue in Gradle project gradle/gradle#16077, so hopefully this will be adressed soon with version catalogs.

I will close this issue for now, but feel free to drop a comment if you find a proper solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ✍️ready to grab You can start working on this issue
Projects
None yet
Development

No branches or pull requests

4 participants