Android Custom Gradle Plugin - How to apply dependencies like Ktlint (BuildScr)

64 Views Asked by At

Sooo I work on a multi module project and I didn't want to copy paste my settings 100 times so I wrote a custom gradle plugin to share those. Now the problem is I can't apply dependencies like ktlint to my Android Configuration - It is just not working....

I have a BuildScr folder Here I have my build.gradle.kts which looks sth like this:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

    plugins {
        `kotlin-dsl`
    }
    
    repositories {
        google()
        mavenCentral()
    }
    
    dependencies {
        //Some dependencies
    }

And my class SharedSettings: Plugin<Project> has the following snippet:

    project.extensions.getByType(LibraryExtension::class.java).apply {
        ktlint {

        }
    }

Error: Unresolved reference: ktlint

I tried to apply ktlint everywhere. In build.gradle.kts in my custom gradle plugin SharedSettings nothing worked. Does anyone of you has an idea how to do it?

I don't want to copy paste code. Thank you so much for your help!

0

There are 0 best solutions below