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

Support for Gradle Kotlin DSL #355

Open
maksym-moroz opened this issue Mar 26, 2024 · 2 comments
Open

Support for Gradle Kotlin DSL #355

maksym-moroz opened this issue Mar 26, 2024 · 2 comments

Comments

@maksym-moroz
Copy link

Expected behaviour

Shot is the last plugin on our project that is not providing a way to use a new plugins block and alias. It would be nice if it was fixed

Actual behaviour

Right now the only way I found is via classpath. Surely there is a lengthy workaround to overcome this by copying everything manually but I feel like Kotlin DSL is the staple for Gradle and Shot snould provide this out of the box

Steps to reproduce

Try to add Shot

Version of the library

Any

@NinoDLC
Copy link

NinoDLC commented Jul 22, 2024

FYI, this is the kind of API I expect to add this plugin to my codebase : https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block

@ArkeshGKalathiya
Copy link

Here is the way I was able to add it in my project ( Haven't tested it if this works, but I was able to do gradle sync successfully )

CREDIT GOES TO : https://www.caravellecode.fr/android-gradle-plugin-resolution/

settings.gradle.kts

pluginManagement {
    repositories {
        google {
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        mavenCentral()
        gradlePluginPortal()
    }
    ##### ADDED THIS SECTION #####
    resolutionStrategy{
        eachPlugin{
            when(requested.id.id){
                "shot" -> {
                    useModule("com.karumi:shot:${requested.version}")
                }
            }
        }
    }
}

libs.versions.toml

[versions]
shot="6.0.0"

## make sure id is "shot", I set it "com.karumi.shot" first time, but id from resolved repo ( i.e "shot" ) did not match with the "com.karumi.shot"
[plugins]
shot = { id="shot", version.ref="shot" }

Project level build.gradle.kts

plugins {
    ## not sure why I have done this, but assumed from other integrations ( my 1st week in native android development )
    alias(libs.plugins.shot) apply false
}

app/module level build.gradle.kts

plugins {
    alias(libs.plugins.shot)
}

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

No branches or pull requests

4 participants
@NinoDLC @ArkeshGKalathiya @maksym-moroz and others